From e5b72c1d2cfaf8a2ff7ae814baaf7f8c9c58de76 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Tue, 23 Mar 2021 07:54:23 +0100 Subject: [PATCH] Add the flow-over-heated-plate for nearest-projection (#159) * Add the flow-over-heated-plate for nearest-projection * Remove OpenFOAM merch header * Remove OpenFOAM merch header pt 2 * Update run.sh script documentation * Move parts from this tutorial to the adapter docs * Update flow-over-heated-plate-nearest-projection/README.md Co-authored-by: Gerasimos Chourdakis Co-authored-by: Gerasimos Chourdakis --- .../README.md | 72 +++++++++++ .../clean.sh | 49 ++++++++ .../fluid-openfoam/0.orig/T | 53 ++++++++ .../fluid-openfoam/0.orig/U | 48 ++++++++ .../fluid-openfoam/0.orig/alphat | 54 +++++++++ .../fluid-openfoam/0.orig/epsilon | 54 +++++++++ .../fluid-openfoam/0.orig/k | 54 +++++++++ .../fluid-openfoam/0.orig/nut | 54 +++++++++ .../fluid-openfoam/0.orig/p | 58 +++++++++ .../fluid-openfoam/0.orig/p_rgh | 48 ++++++++ .../fluid-openfoam/constant/g | 15 +++ .../constant/thermophysicalProperties | 42 +++++++ .../constant/turbulenceProperties | 19 +++ .../fluid-openfoam/fluid-openfoam.foam | 0 .../fluid-openfoam/removeObsoleteFolders.sh | 22 ++++ .../fluid-openfoam/run.sh | 39 ++++++ .../fluid-openfoam/system/blockMeshDict | 114 ++++++++++++++++++ .../fluid-openfoam/system/controlDict | 52 ++++++++ .../fluid-openfoam/system/decomposeParDict | 16 +++ .../fluid-openfoam/system/fvSchemes | 52 ++++++++ .../fluid-openfoam/system/fvSolution | 59 +++++++++ .../fluid-openfoam/system/preciceDict | 51 ++++++++ .../precice-config.xml | 76 ++++++++++++ .../solid-openfoam/0.orig/T | 40 ++++++ .../constant/transportProperties | 14 +++ .../solid-openfoam/removeObsoleteFolders.sh | 22 ++++ .../solid-openfoam/run.sh | 39 ++++++ .../solid-openfoam/solid-openfoam.foam | 0 .../solid-openfoam/system/blockMeshDict | 81 +++++++++++++ .../solid-openfoam/system/controlDict | 52 ++++++++ .../solid-openfoam/system/decomposeParDict | 16 +++ .../solid-openfoam/system/fvSchemes | 43 +++++++ .../solid-openfoam/system/fvSolution | 28 +++++ .../solid-openfoam/system/preciceDict | 57 +++++++++ perpendicular-flap/fluid-openfoam/run.sh | 7 +- 35 files changed, 1494 insertions(+), 6 deletions(-) create mode 100644 flow-over-heated-plate-nearest-projection/README.md create mode 100755 flow-over-heated-plate-nearest-projection/clean.sh create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/0.orig/T create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/0.orig/U create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/0.orig/alphat create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/0.orig/epsilon create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/0.orig/k create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/0.orig/nut create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/0.orig/p create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/0.orig/p_rgh create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/constant/g create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/constant/thermophysicalProperties create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/constant/turbulenceProperties create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/fluid-openfoam.foam create mode 100755 flow-over-heated-plate-nearest-projection/fluid-openfoam/removeObsoleteFolders.sh create mode 100755 flow-over-heated-plate-nearest-projection/fluid-openfoam/run.sh create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/system/blockMeshDict create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/system/controlDict create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/system/decomposeParDict create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/system/fvSchemes create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/system/fvSolution create mode 100644 flow-over-heated-plate-nearest-projection/fluid-openfoam/system/preciceDict create mode 100644 flow-over-heated-plate-nearest-projection/precice-config.xml create mode 100644 flow-over-heated-plate-nearest-projection/solid-openfoam/0.orig/T create mode 100644 flow-over-heated-plate-nearest-projection/solid-openfoam/constant/transportProperties create mode 100755 flow-over-heated-plate-nearest-projection/solid-openfoam/removeObsoleteFolders.sh create mode 100755 flow-over-heated-plate-nearest-projection/solid-openfoam/run.sh create mode 100644 flow-over-heated-plate-nearest-projection/solid-openfoam/solid-openfoam.foam create mode 100644 flow-over-heated-plate-nearest-projection/solid-openfoam/system/blockMeshDict create mode 100644 flow-over-heated-plate-nearest-projection/solid-openfoam/system/controlDict create mode 100644 flow-over-heated-plate-nearest-projection/solid-openfoam/system/decomposeParDict create mode 100644 flow-over-heated-plate-nearest-projection/solid-openfoam/system/fvSchemes create mode 100644 flow-over-heated-plate-nearest-projection/solid-openfoam/system/fvSolution create mode 100644 flow-over-heated-plate-nearest-projection/solid-openfoam/system/preciceDict diff --git a/flow-over-heated-plate-nearest-projection/README.md b/flow-over-heated-plate-nearest-projection/README.md new file mode 100644 index 000000000..0dd77c0f4 --- /dev/null +++ b/flow-over-heated-plate-nearest-projection/README.md @@ -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: +``` + + + + + + +``` +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 `` 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 ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/flow-over-heated-plate-nearest-projection/solid-openfoam/0.orig/T b/flow-over-heated-plate-nearest-projection/solid-openfoam/0.orig/T new file mode 100644 index 000000000..96fc74129 --- /dev/null +++ b/flow-over-heated-plate-nearest-projection/solid-openfoam/0.orig/T @@ -0,0 +1,40 @@ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 310; + +boundaryField +{ + interface + { + type fixedValue; + value $internalField; + } + left + { + type zeroGradient; + } + right + { + type zeroGradient; + } + bottom + { + type fixedValue; + value $internalField; + } + defaultFaces + { + type empty; + } +} + +// ************************************************************************* // diff --git a/flow-over-heated-plate-nearest-projection/solid-openfoam/constant/transportProperties b/flow-over-heated-plate-nearest-projection/solid-openfoam/constant/transportProperties new file mode 100644 index 000000000..2a7a60f85 --- /dev/null +++ b/flow-over-heated-plate-nearest-projection/solid-openfoam/constant/transportProperties @@ -0,0 +1,14 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +DT DT [ 0 2 -1 0 0 0 0 ] 1; + + +// ************************************************************************* // diff --git a/flow-over-heated-plate-nearest-projection/solid-openfoam/removeObsoleteFolders.sh b/flow-over-heated-plate-nearest-projection/solid-openfoam/removeObsoleteFolders.sh new file mode 100755 index 000000000..167e40f61 --- /dev/null +++ b/flow-over-heated-plate-nearest-projection/solid-openfoam/removeObsoleteFolders.sh @@ -0,0 +1,22 @@ +#! /bin/bash + +echo "Looking for any time directories without results (e.g. stray functionObjectProperties files, see issue #26 on GitHub)..." + +for f in [0-9]* [0-9]*.[0-9]*; do + if ! [ -f $f/U ] && ! [ -f $f/T ]; then + rm -rfv $f + fi +done +if [ -d processor0 ]; then + for g in processor*; do + cd $g + for f in [0-9]* [0-9]*.[0-9]*; do + if ! [ -f $f/U ] && ! [ -f $f/T ]; then + rm -rfv $f + fi + done + cd .. + done +fi +cd .. + diff --git a/flow-over-heated-plate-nearest-projection/solid-openfoam/run.sh b/flow-over-heated-plate-nearest-projection/solid-openfoam/run.sh new file mode 100755 index 000000000..c39667789 --- /dev/null +++ b/flow-over-heated-plate-nearest-projection/solid-openfoam/run.sh @@ -0,0 +1,39 @@ +#!/bin/bash +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions + +# Fluid participant + +# Run this script in one terminal in order to start this participant. +# Run this script with "-parallel" for parallel simulations + +# 1 for true, 0 for false +parallel=0 +if [ "$1" = "-parallel" ]; then + parallel=1 +fi + +echo "Preparing and running the Fluid participant..." + +rm -rfv 0/ +cp -r 0.orig/ 0/ +blockMesh +checkMesh + +# Run +solver=$(getApplication) +procs=$(getNumberOfProcessors) + +if [ $parallel -eq 1 ]; then + decomposePar -force + mpirun -np $procs $solver -parallel + reconstructPar +else + $solver +fi + +# Workaround for issue #26 +./removeObsoleteFolders.sh + +echo "" +echo "### NOTE ### Make sure to use the correct solver for your OpenFOAM version! (pimpleFoam for OpenFOAM v1806, OpenFOAM 6, or newer, vs pimpleDyMFoam for older) You may change this in your Fluid/system/controlDict file, if needed." diff --git a/flow-over-heated-plate-nearest-projection/solid-openfoam/solid-openfoam.foam b/flow-over-heated-plate-nearest-projection/solid-openfoam/solid-openfoam.foam new file mode 100644 index 000000000..e69de29bb diff --git a/flow-over-heated-plate-nearest-projection/solid-openfoam/system/blockMeshDict b/flow-over-heated-plate-nearest-projection/solid-openfoam/system/blockMeshDict new file mode 100644 index 000000000..d0fb694e6 --- /dev/null +++ b/flow-over-heated-plate-nearest-projection/solid-openfoam/system/blockMeshDict @@ -0,0 +1,81 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 1; + +vertices +( + + (0 -.25 0) + (1 -.25 0) + (1 0 0) + (0 0 0) + + (0 -.25 .01) + (1 -.25 .01) + (1 0 .01) + (0 0 .01) + +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (32 16 1) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + + left + { + type wall; + faces + ( + (4 7 3 0) + ); + } + + right + { + type wall; + faces + ( + (1 2 6 5) + ); + } + + interface + { + type wall; + faces + ( + (7 6 2 3) + ); + } + + bottom + { + type wall; + faces + ( + (4 0 1 5) + ); + } + +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/flow-over-heated-plate-nearest-projection/solid-openfoam/system/controlDict b/flow-over-heated-plate-nearest-projection/solid-openfoam/system/controlDict new file mode 100644 index 000000000..0920237a7 --- /dev/null +++ b/flow-over-heated-plate-nearest-projection/solid-openfoam/system/controlDict @@ -0,0 +1,52 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application laplacianFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 1; + +deltaT 0.01; + +writeControl runTime; + +writeInterval 0.2; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable false; + +functions +{ + preCICE_Adapter + { + type preciceAdapterFunctionObject; + libs ("libpreciceAdapterFunctionObject.so"); + } +} + + + +// ************************************************************************* // diff --git a/flow-over-heated-plate-nearest-projection/solid-openfoam/system/decomposeParDict b/flow-over-heated-plate-nearest-projection/solid-openfoam/system/decomposeParDict new file mode 100644 index 000000000..ad99cf6c5 --- /dev/null +++ b/flow-over-heated-plate-nearest-projection/solid-openfoam/system/decomposeParDict @@ -0,0 +1,16 @@ +FoamFile { + version 2.0; + class dictionary; + object decomposeParDict; + format ascii; +} + +numberOfSubdomains 2; + +method simple; + +simpleCoeffs +{ + n (2 1 1); + delta 0.001; +} diff --git a/flow-over-heated-plate-nearest-projection/solid-openfoam/system/fvSchemes b/flow-over-heated-plate-nearest-projection/solid-openfoam/system/fvSchemes new file mode 100644 index 000000000..da42ee4e0 --- /dev/null +++ b/flow-over-heated-plate-nearest-projection/solid-openfoam/system/fvSchemes @@ -0,0 +1,43 @@ +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; + grad(T) Gauss linear; +} + +divSchemes +{ + default none; +} + +laplacianSchemes +{ + default none; + laplacian(DT,T) Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + + +// ************************************************************************* // diff --git a/flow-over-heated-plate-nearest-projection/solid-openfoam/system/fvSolution b/flow-over-heated-plate-nearest-projection/solid-openfoam/system/fvSolution new file mode 100644 index 000000000..74d1bdfd5 --- /dev/null +++ b/flow-over-heated-plate-nearest-projection/solid-openfoam/system/fvSolution @@ -0,0 +1,28 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + T + { + solver PCG; + preconditioner DIC; + tolerance 1e-06; + relTol 0; + } +} + +SIMPLE +{ + nNonOrthogonalCorrectors 2; +} + + +// ************************************************************************* // diff --git a/flow-over-heated-plate-nearest-projection/solid-openfoam/system/preciceDict b/flow-over-heated-plate-nearest-projection/solid-openfoam/system/preciceDict new file mode 100644 index 000000000..3d3e6ebaa --- /dev/null +++ b/flow-over-heated-plate-nearest-projection/solid-openfoam/system/preciceDict @@ -0,0 +1,57 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object preciceDict; +} + +preciceConfig "../precice-config.xml"; + +participant Solid; + +modules (CHT); + +interfaces +{ + Interface1 + { + mesh Solid-Mesh-Centers; + locations faceCenters; + connectivity false; + patches (interface); + + readData + ( + Temperature + ); + + writeData + ( + ); + }; + + Interfaces2 + { + mesh Solid-Mesh-Nodes; + locations faceNodes; + connectivity true; + patches (interface); + + readData + ( + ); + + writeData + ( + Heat-Flux + ); + }; +}; + +CHT +{ + k [ 1 1 -3 -1 0 0 0 ] 100; + solverType "basic"; +}; diff --git a/perpendicular-flap/fluid-openfoam/run.sh b/perpendicular-flap/fluid-openfoam/run.sh index 29c9416f4..c39667789 100755 --- a/perpendicular-flap/fluid-openfoam/run.sh +++ b/perpendicular-flap/fluid-openfoam/run.sh @@ -4,14 +4,9 @@ cd ${0%/*} || exit 1 # Run from this directory # Fluid participant -# Run this script in one terminal and the "runSolid" script in another terminal. -# These scripts present how the two participants would be started manually. -# Alternatively, you may execute the "Allrun" script in one terminal. - +# Run this script in one terminal in order to start this participant. # Run this script with "-parallel" for parallel simulations -# The script "Allclean" cleans-up the result and log files. - # 1 for true, 0 for false parallel=0 if [ "$1" = "-parallel" ]; then