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

Restructure runscripts and related resources #181

Merged
merged 19 commits into from
Apr 12, 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
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# preCICE Tutorials

This repository contains ready-to-run tutorial cases for the coupling library [preCICE](http://www.precice.org/).
The purpose of these cases are not to teach you how to use preCICE, but to serve as starting points for setting up similar simulation cases.

You may find step-by-step instructions for each case in the [preCICE wiki](https://github.com/precice/precice/wiki). *More tutorials come with each adapter* and you can also find them in the wiki.
Each folder in this directory represents a stand-alone tutorial case containing:
* a `README.md` with general instructions on how to run the simulation. This is the same content you see on the [preCICE tutorials](https://www.precice.org/tutorials.html) documentation section.
* multiple participant folders with the format `<participant>-<solver>`. Pick a solver for each participant and start them to run the simulation.
* a `clean.sh` script to clean each individual participant case, a `clean-tutorial.sh` to clean all participants of a tutorial case, a `clean-all.sh` to clean all tutorial cases.

As a general rule, you can start each participant from inside their `<participant>-<solver>` using `./run.sh`. Look into these short scripts and copy the parts you need for your new case.

Each folder in this directory represents a stand-alone tutorial containing:
* a `README.md` with general instructions on how to run the simulation
* multiple participant folders with the format `<participant>_<solver>`. Pick a solver for each participant and start them to run the simulation.
## For contributors


The website import relies on the following rules:
The [preCICE tutorials](https://www.precice.org/tutorials.html) documentation section displays material from this repository. This website import relies on the following rules:
* tutorials use dashes to separate words `flow-over-heated-plate`.
* a tutorial contains a `REAMDE.md` with a Jekyll front-matter and a `permalink: /tutorials-flow-over-heated-plate.html`.
* a tutorial may contain a folder `images/` with images to be displayed in the `README.md`.
Expand Down
1 change: 0 additions & 1 deletion elastic-tube-3d/fluid-openfoam/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ set -e -u
. ../../tools/cleaning-tools.sh

clean_openfoam .
rm -rfv ./0/ # in run.sh, 0.orig/ is copied to 0/
39 changes: 3 additions & 36 deletions elastic-tube-3d/fluid-openfoam/run.sh
Original file line number Diff line number Diff line change
@@ -1,41 +1,8 @@
#!/bin/bash
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
#!/bin/sh
set -e -u

# Fluid participant

# Run this script in one terminal and the execute the coupled_elasto_dynamics bindary
# in another terminal.
# These scripts present how the two participants would be started manually.

# 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
parallel=1
fi

echo "Preparing and running the Fluid participant..."

rm -rfv 0/
cp -r 0.orig/ 0/
cp -r constant/polyMesh.orig constant/polyMesh
checkMesh
touch fluid-openfoam.foam

# 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 (OF-adapter, relevant for OF .com versions)
../../tools/run-openfoam.sh "$@"
. ../../tools/openfoam-remove-empty-dirs.sh && openfoam_remove_empty_dirs
2 changes: 1 addition & 1 deletion elastic-tube-3d/fluid-openfoam/system/controlDict
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ timeFormat general;

timePrecision 8;

runTimeModifiable yes;
runTimeModifiable false;

adjustTimeStep no;

Expand Down
2 changes: 1 addition & 1 deletion elastic-tube-3d/solid-calculix/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e -u

. ../../tools/cleaning-tools.sh

clean_calculix .
clean_calculix .
17 changes: 5 additions & 12 deletions elastic-tube-3d/solid-calculix/run.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
#!/bin/bash
cd ${0%/*} || exit 1 # Run from this directory
#!/bin/sh
set -e -u

# This script prepares and runs the CalculiX solver

# =============== Participant: Solid ===========================
Solver="ccx_preCICE"

# Run and get the process id
echo "Starting the CalculiX..."
export OMP_NUM_THREADS=1
export CCX_NPROC_EQUATION_SOLVER=1
${Solver} -i tube -precice-participant Calculix
export OMP_NUM_THREADS=1
export CCX_NPROC_EQUATION_SOLVER=1
ccx_preCICE -i tube -precice-participant Calculix
2 changes: 1 addition & 1 deletion flow-over-heated-plate-nearest-projection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ Visualizing these files (e.g. using ParaView) will show a triangular mesh, even

![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.
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." %}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ set -e -u
. ../../tools/cleaning-tools.sh

clean_openfoam .
rm -rfv ./0/ # in run.sh,0.orig/ is copied to 0/
38 changes: 3 additions & 35 deletions flow-over-heated-plate-nearest-projection/fluid-openfoam/run.sh
Original file line number Diff line number Diff line change
@@ -1,40 +1,8 @@
#!/bin/bash
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
#!/bin/sh
set -e -u

# 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
touch fluid-openfoam.foam

# 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
../../tools/run-openfoam.sh "$@"
. ../../tools/openfoam-remove-empty-dirs.sh && openfoam_remove_empty_dirs

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."
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ set -e -u
. ../../tools/cleaning-tools.sh

clean_openfoam .
rm -rfv ./0/ # in run.sh,0.orig/ is copied to 0/
38 changes: 3 additions & 35 deletions flow-over-heated-plate-nearest-projection/solid-openfoam/run.sh
Original file line number Diff line number Diff line change
@@ -1,40 +1,8 @@
#!/bin/bash
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
#!/bin/sh
set -e -u

# 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
touch solid-openfoam.foam

# 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
../../tools/run-openfoam.sh "$@"
. ../../tools/openfoam-remove-empty-dirs.sh && openfoam_remove_empty_dirs

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."
8 changes: 3 additions & 5 deletions flow-over-heated-plate-steady-state/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ summary: Using a steady-state OpenFOAM solver for a CHT coupling with Code_Aster

## Setup

The setup for this tutorial is similar to the [flow over a heated plate](tutorials-flow-over-heated-plate.html) using OpenFOAM. In this tutorial OpenFOAM is used as the solver for the fluid domain, and Code-Aster is the solver for the solid domain. A difference here is that we are using a steady-state OpenFOAM solver for demonstration purposes, therefore the results between the two tutorials are not comparable.
The setup for this tutorial is similar to the [flow over a heated plate](tutorials-flow-over-heated-plate.html) using OpenFOAM. In this tutorial OpenFOAM is used as the solver for the fluid domain, and code_aster is the solver for the solid domain. A difference here is that we are using a steady-state OpenFOAM solver for demonstration purposes, therefore the results between the two tutorials are not comparable.


## Available solvers
Expand All @@ -20,7 +20,7 @@ Fluid participant:

Solid participant:

* Code_Aster. The [Code_Aster adapter documentation](adapter-code_aster.html) is oriented on this tutorial case. In particular the described configuration settings.
* Code_Aster. The [code_aster adapter documentation](adapter-code_aster.html) is oriented on this tutorial case. In particular the described configuration settings.

## Running the Simulation

Expand All @@ -30,12 +30,10 @@ Open two separate terminals and start each participant by calling the respective

Firstly, enable the ParaViS view in Salome-Meca by selecting the icon in the top of the screen.

For visualizing the results of the fluid solver, go to `File -> Open ParaView File` and select the `.foam` file. If you're asked to choose a reader, please select `OpenFOAMReader` and click `Apply` to visualize the result.
For visualizing the results of the fluid solver, go to `File -> Open ParaView File` and select the `fluid-openfoam.foam` file. If you're asked to choose a reader, please select `OpenFOAMReader` and click `Apply` to visualize the result.

For visualizing the result of the solid solver, press again `Open ParaView File` and select the `output-..rmed` group. Again, click `Apply` to visualize the result. After setting the temperature scale for both domains to 300-310 K, the following result is given for timestep 200:

![post-processing](images/tutorials-flow-over-heated-plate-steady-state-post-processing.png)

{% 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." %}

{% include disclaimer.html content="This offering is not approved or endorsed by Électricité de France (EDF), producer and distributor of the Code_Aster software via www.code-aster.org, and owner of the Code_Aster trademark." %}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ set -e -u
. ../../tools/cleaning-tools.sh

clean_openfoam .
rm -rfv ./0/ # in run.sh,0.orig/ is copied to 0/
39 changes: 3 additions & 36 deletions flow-over-heated-plate-steady-state/fluid-openfoam/run.sh
Original file line number Diff line number Diff line change
@@ -1,41 +1,8 @@
#!/bin/bash
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
#!/bin/sh
set -e -u

# Fluid participant

# Run this script in one terminal and the execute the coupled_elasto_dynamics bindary
# in another terminal.
# These scripts present how the two participants would be started manually.

# 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
parallel=1
fi

echo "Preparing and running the Fluid participant..."

rm -rfv 0/
cp -r 0.orig/ 0/
blockMesh
checkMesh
touch fluid-openfoam.foam

# 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 (OF-adapter, relevant for OF .com versions)
../../tools/run-openfoam.sh "$@"
. ../../tools/openfoam-remove-empty-dirs.sh && openfoam_remove_empty_dirs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e -u

. ../../tools/cleaning-tools.sh

clean_codeaster .
clean_codeaster .
14 changes: 10 additions & 4 deletions flow-over-heated-plate-steady-state/solid-codeaster/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/bash
export TUTORIAL_ROOT=${PWD}
export PRECICE_PARTICIPANT=Solid
as_run --run solid.export
#!/bin/sh
set -e -u

echo "Warning: this case requires a manual preparation step for code_aster."
echo "See the tutorial and code_aster adapter documentation pages for more:"
echo "https://www.precice.org/adapter-code_aster.html\n"

export TUTORIAL_ROOT=${PWD}
export PRECICE_PARTICIPANT=Solid
as_run --run solid.export
10 changes: 5 additions & 5 deletions flow-over-heated-plate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ summary: This tutorial describes how to run a conjugate heat transfer coupled si

## Setup

This scenario consists of one fluid and one solid participant and it is inspired by Vynnycky et al. [1]. A fluid enters a channel with temperature `T_\infty`, where it comes in contact with a solid plate. The plate is heated at its bottom and has a constant temperature of `T_hot`.
This scenario consists of one fluid and one solid participant and it is inspired by Vynnycky et al. [1]. A fluid enters a channel with temperature $$ T_\infty $$, where it comes in contact with a solid plate. The plate is heated at its bottom and has a constant temperature of $$ T_{hot} $$.

![img](images/tutorials-flow-over-heated-plate-example.png)

The test case is two-dimensional and a serial-implicit coupling with Aitken underrelaxation is used for the coupling.

The inlet velocity is `u_\infty = 0.1 m/s`, the inlet temperature is `T_\infty = 300K`. The fluid and solid have the same thermal conductivities `k_S = k_F = 100 W/m/K`. Further material properties of the fluid are its viscosity `mu = 0.0002 kg/m/s` and specific heat capacity `c_p = 5000 J/kg/K`. The Prandtl number `Pr = 0.01` follows from thermal conductivity, viscosity and specific heat capacity. The solid has the thermal diffusivity `\alpha = 1 m^2/s`. The gravitational acceleration is `g = 9.81 m/s^2`.
The inlet velocity is $$ u_{\infty} = 0.1 m/s $$, the inlet temperature is $$ T_{\infty} = 300K $$. The fluid and solid have the same thermal conductivities $$ k_S = k_F = 100 W/m/K $$. Further material properties of the fluid are its viscosity $$ mu = 0.0002 kg/m/s $$ and specific heat capacity $$ c_p = 5000 J/kg/K $$. The Prandtl number $$ Pr = 0.01 $$ follows from thermal conductivity, viscosity and specific heat capacity. The solid has the thermal diffusivity $$ \alpha = 1 m^2/s $$. The gravitational acceleration is $$ g = 9.81 m/s^2 $$.

## Available solvers

Expand Down Expand Up @@ -45,18 +45,18 @@ and
cd solid-fenics
./run.sh
```
in order to use OpenFOAM and FEniCS for this test case.
in order to use OpenFOAM and FEniCS for this test case. Feel free to try different combinations, they should all run and give approximately similar results.

## Post-processing

How to visualize the simulation results depends on the selected solvers. Most of the solvers generate `vtk` files which can visualized using, e.g., ParaView.
How to visualize the simulation results depends on the selected solvers. Most of the solvers generate VTK files which can visualized using ParaView or similar tools.
An example of the visualized expected results looks as follows:

![result](images/tutorials-flow-over-heated-plate-result-openfoam.png)

Observe that the temperature at the bottom of the plate is 310K and at the inlet 300K. On the interface, the temperature is between these values. An area of higher temperature is formed above the plate, which is shifted towards the front, driven by the flow.

You may use additional filters, such as the Calculator and the Plot Over Line, to obtain the distribution of the non-dimensional temperature (T-T_inlet)/(T_solid-T_inlet):
You may use additional filters, such as the Calculator and the Plot Over Line, to obtain the distribution of the non-dimensional temperature $$ (T-T_{inlet})/(T_{solid}-T_{inlet}) $$:

![graph](images/tutorials-flow-over-heated-plate-graph-result.png)

Expand Down
1 change: 0 additions & 1 deletion flow-over-heated-plate/fluid-openfoam/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ set -e -u
. ../../tools/cleaning-tools.sh

clean_openfoam .
rm -rfv ./0/ # in run.sh,0.orig/ is copied to 0/
Loading