Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the flow-over-heated-plate for nearest-projection #159

Merged
merged 6 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions flow-over-heated-plate-nearest-projection/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: Flow over heated plate nearest projection
permalink: tutorials-flow-over-heated-plate-nearest-projection.html
keywords: OpenFOAM, nearest-projection, CHT
summary: This tutorial introduces an example simulation setup for a nearest-projection mapping. At the moment, it only contains an example with the OpenFOAM adapter. The demonstrated "flow over a heated plate" scenario is exactly the same as in the `buoyantPimpleFoam-laplacianFoam` tutorial.
---

## Setup

The setup is exactly the same as described in our [flow-over-heated-plate tutorial](tutorials-flow-over-heated-plate.html).

## Available solvers

Fluid participant:

* OpenFOAM (buoyantPimpleFoam). For more information, have a look at the [OpenFOAM adapter documentation](adapter-openfoam-overview.html).

Solid participant:

* OpenFOAM (laplacianFoam). For more information, have a look at the [OpenFOAM adapter documentation](adapter-openfoam-overview.html).

The solvers are currently only OpenFOAM related. For information regarding the nearest-projection mapping, have a look in the [OpenFOAM configuration section](adapter-openfoam-config.html).


## Running the Simulation

Open two separate terminals and start each participant by calling the respective run script.

```
cd fluid-openfoam
./run.sh
```
and
```
cd solid-openfoam
./run.sh
```

You can also run OpenFOAM in parallel by `./run.sh -parallel`. If you are using OpenFOAM v1712 / 5.x or older have a look in the `fluid-openfoam/system/controlDict` file and set the appropriate solver name.

## Changes in the Simulation Setup

As we are defining two meshes for each participant, we need to define them in the `precice-config.xml` and `preciceDict` configuration files. Additionally, we need to enable the `connectivity` switch for the adapter.

### Changes in `precice-config.xml`
In order to map from face nodes to face centers, both meshes need to be specified. The nodes-based mesh uses the write data and the centers-based mesh uses the read data. Have a look in the given `precice-config.xml` in this tutorial. Example: `Temperature` is calculated by the `Fluid` participant and passed to the `Solid` participant. Therefore, it is the write data of the participant `Fluid` and the read data of the participant `Solid`. This results in the following two meshes for this data:
```
<mesh name="Fluid-Mesh-Nodes">
<use-data name="Temperature"/>
</mesh>
<mesh name="Solid-Mesh-Centers">
<use-data name="Temperature"/>
</mesh>
```
All further changes follow from this interface splitting. Have a look in the given config files for all details.

### Notes on 2D Cases

From the preCICE point of view, the simulation here is in 3D, as opposed to the original 2D case, as is often the case with 3D solvers (such as OpenFOAM). In such cases, we recommend keeping the out-of-plane thickness of the domain small and comparable to the in-plane cell size. Otherwise, the face centers will have a large distance to the face nodes, which might trigger a preCICE warning and preCICE may even filter out one of the meshes, especially in parallel simulations.


## Post-processing

Have a look at the [flow-over heated-plate](tutorials-flow-over-heated-plate.html) tutorial for the general aspects of post-processing.
Since we now defined mesh connectivity on our interface, we can export the coupling interface with the tag `<export:vtk directory="preCICE-output" />` in our `precice-config.xml`.
Visualizing these files (e.g. using ParaView) will show a triangular mesh, even though you use hexahedral meshes. This has nothing to do with your mesh and is just caused by the way the connectivity is defined in preCICE. As described above, the function `setMeshTriangles` is used to define the connectivity. Hence, every interface cell/face is represented by two triangles. The following image should give you an impression of a possible triangulated coupling mesh, which consists purely of hexahedral cells:

![triangulated](https://user-images.githubusercontent.com/33414590/55974257-96b07d80-5c87-11e9-9965-972b922c483d.png)

Note: Connectivity is defined on meshes associated with mesh nodes, which are named respectively e.g. `Fluid-Mesh-Nodes`. In this case, you could directly see the interface without applying filters by loading the `.vtk` files. In order to visualize additionally center based meshes, where no connectivity is provided, select a Glyph filter in ParaView. Furthermore, it makes a difference, on which participant the `<export...` tag is defined in your `precice-config.xml` file. Each participant exports interface meshes, which he provides or receives. The receiving participant filters out mesh parts that it does not need (for the mapping). Hence, a received mesh might look incomplete.

{% include disclaimer.html content="This offering is not approved or endorsed by OpenCFD Limited, producer and distributor of the OpenFOAM software via www.openfoam.com, and owner of the OPENFOAM® and OpenCFD® trade marks." %}
49 changes: 49 additions & 0 deletions flow-over-heated-plate-nearest-projection/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory

echo "Cleaning..."

clean_case(){
cd ${1}
# Clean the result and auxiliary files
rm -fv *.vtk
rm -fv ${1}.log
rm -fv precice-*.log \
rm -fv precice-postProcessingInfo.log \
rm -fv precice-*-events.json
}

finished_clean(){
cd ..
}

# Openfoam
Name="fluid-openfoam"
clean_case ${Name}
# Clean specialized files
if [ -n "${WM_PROJECT}" ];
then
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
cleanCase
rm -rfv ./0
touch ${Name}.foam
fi
finished_clean

Name="solid-openfoam"
clean_case ${Name}
# Clean specialized files
if [ -n "${WM_PROJECT}" ];
then
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
cleanCase
rm -rfv ./0
touch ${Name}.foam
fi
finished_clean

# Remove the preCICE address files
rm -rfv precice-run

echo "Cleaning complete!"
#------------------------------------------------------------------------------
53 changes: 53 additions & 0 deletions flow-over-heated-plate-nearest-projection/fluid-openfoam/0.orig/T
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object T;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [ 0 0 0 1 0 0 0 ];

internalField uniform 300;

boundaryField
{
interface
{
type fixedGradient;
gradient uniform 0;
}
inlet
{
type fixedValue;
value $internalField;
}
outlet
{
type zeroGradient;
}
top
{
type zeroGradient;
}
bottom
{
type zeroGradient;
}
slip-bottom
{
type zeroGradient;
}
outerWall
{
type zeroGradient;
}
defaultFaces
{
type empty;
}
}


// ************************************************************************* //
48 changes: 48 additions & 0 deletions flow-over-heated-plate-nearest-projection/fluid-openfoam/0.orig/U
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [ 0 1 -1 0 0 0 0 ];

internalField uniform ( 0.1 0 0 );

boundaryField
{
interface
{
type noSlip;
}
inlet
{
type fixedValue;
value $internalField;
}
outlet
{
type zeroGradient;
}
top
{
type slip;
}
bottom
{
type noSlip;
}
slip-bottom
{
type slip;
}
defaultFaces
{
type empty;
}
}


// ************************************************************************* //
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object alphat;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [ 1 -1 -1 0 0 0 0 ];

internalField uniform 0;

boundaryField
{
interface
{
type compressible::alphatWallFunction;
value uniform 0;
}
inlet
{
type compressible::alphatWallFunction;
value uniform 0;
}
outlet
{
type compressible::alphatWallFunction;
value uniform 0;
}
top
{
type compressible::alphatWallFunction;
value uniform 0;
}
bottom
{
type compressible::alphatWallFunction;
value uniform 0;
}
slip-bottom
{
type compressible::alphatWallFunction;
value uniform 0;
}
defaultFaces
{
type empty;
}
}


// ************************************************************************* //
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [ 0 2 -3 0 0 0 0 ];

internalField uniform 0.01;

boundaryField
{
interface
{
type epsilonWallFunction;
value uniform 0.01;
}
inlet
{
type epsilonWallFunction;
value uniform 0.01;
}
outlet
{
type epsilonWallFunction;
value uniform 0.01;
}
top
{
type epsilonWallFunction;
value uniform 0.01;
}
bottom
{
type epsilonWallFunction;
value uniform 0.01;
}
slip-bottom
{
type epsilonWallFunction;
value uniform 0.01;
}
defaultFaces
{
type empty;
}
}


// ************************************************************************* //
54 changes: 54 additions & 0 deletions flow-over-heated-plate-nearest-projection/fluid-openfoam/0.orig/k
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [ 0 2 -2 0 0 0 0 ];

internalField uniform 0.1;

boundaryField
{
interface
{
type kqRWallFunction;
value uniform 0.1;
}
inlet
{
type kqRWallFunction;
value uniform 0.1;
}
outlet
{
type kqRWallFunction;
value uniform 0.1;
}
top
{
type kqRWallFunction;
value uniform 0.1;
}
slip-bottom
{
type kqRWallFunction;
value uniform 0.1;
}
bottom
{
type kqRWallFunction;
value uniform 0.1;
}
defaultFaces
{
type empty;
}
}


// ************************************************************************* //
Loading