Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4e308c2
added tutorial for foam-extend
hoehnp Jul 4, 2025
33776ae
Update quickstart/fluid-foam-extend/system/controlDict
hoehnp Jul 5, 2025
24d8a43
added missing variable
hoehnp Jul 5, 2025
4fc127b
add blockMeshDict in right folder
hoehnp Aug 5, 2025
85510a1
remove blockMeshDict from old location
hoehnp Aug 5, 2025
dbfdeb9
fix path for preciceDict in quickstart for foam-extend
hoehnp Aug 6, 2025
da48510
add missing keyword
hoehnp Aug 6, 2025
50ba26c
added missing keywords for foam-extend-5.0
hoehnp Aug 6, 2025
49c1e05
add missing scheme
hoehnp Aug 6, 2025
2085c00
add relaxationFactors for foam-extend-4.0
hoehnp Aug 8, 2025
dacad27
also add Ufinal for foam-extend-4.0
hoehnp Aug 8, 2025
af9e813
fix typo
hoehnp Aug 8, 2025
c153c42
add changes to combine foam-extend and openfoam for the quickstart tu…
hoehnp Sep 8, 2025
d911b72
make run-foam-extend.sh executable
hoehnp Sep 8, 2025
f132044
remove the too late creation of blockMeshDict for OpenFOAM
hoehnp Sep 8, 2025
0306949
adding missing values for foam-extend
hoehnp Sep 8, 2025
6a02f4f
add fix to adjust to limited version of getApplications in foam-extend
hoehnp Sep 8, 2025
7082467
add changes before deleting folder
hoehnp Sep 8, 2025
02ddabb
remove no longer required folder for foam-extend
hoehnp Sep 8, 2025
6baea22
run-foam-extend.sh: Back up original files
MakisH Sep 13, 2025
3f11c0c
Add comments in the controlDict
MakisH Sep 13, 2025
fea3aaa
Add comments for lines only relevant to foam-extend
MakisH Sep 13, 2025
6f4053c
Add a note in README.md
MakisH Sep 13, 2025
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
6 changes: 6 additions & 0 deletions quickstart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ You can also run OpenFOAM in parallel: `./run.sh -parallel`.

In serial, the simulation should take less than a minute to compute (simulated time: 2.5s).

{% note %}
While we recommend starting with the latest OpenFOAM version from openfoam.com,
this case can alternatively be executed with foam-extend.
For that, replace `run-openfoam.sh` with `run-foam-extend.sh` in the `run.sh` script.
{% endnote %}

## Visualizing the results

You can visualize the simulation results of the `Fluid` participant using ParaView and loading the (empty) file `fluid-openfoam/fluid-openfoam.foam`. The rigid body does not generate any readable output files, but the OpenFOAM data should be enough for now: click "play" in ParaView, the flap should already be moving! 🎉
Expand Down
3 changes: 3 additions & 0 deletions quickstart/fluid-openfoam/0/U
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ boundaryField
top
{
type noSlip;
value uniform (0 0 0);
// Note: Values in noSlip are only needed for foam-extend
}

bottom
{
type noSlip;
value uniform (0 0 0);
}

inlet
Expand Down
2 changes: 2 additions & 0 deletions quickstart/fluid-openfoam/constant/dynamicMeshDict
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ motionSolverLibs ("libfvMotionSolvers.so");
solver displacementLaplacian;
// OpenFOAM9 or newer: rename "solver" to "motionSolver"

diffusivity uniform; // Only relevant to foam-extend

displacementLaplacianCoeffs {
diffusivity quadratic inverseDistance (flap);
}
18 changes: 16 additions & 2 deletions quickstart/fluid-openfoam/system/controlDict
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ FoamFile
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}

// Note: This file is prepared to run with the latest supported version of OpenFOAM.com.
// The tutorials/tools/run-foam-extend.sh script can modify this and other files to run with foam-extend.
// The format of the file (e.g., linked libraries in one line each) is at parts important to the script.

application pimpleFoam; // latest OpenFOAM
// application pimpleDyMFoam; // OpenFOAM v1712, OpenFOAM 5.x, or older


startFrom startTime;

startTime 0;
Expand All @@ -36,7 +40,10 @@ timeFormat general;

timePrecision 8;

libs ("libpreciceAdapterFunctionObject.so");
libs
(
"libpreciceAdapterFunctionObject.so"
);
functions
{
forces
Expand All @@ -47,6 +54,13 @@ functions
rho rhoInf;
log true;
rhoInf 10;
// The following entries are only relevant to foam-extend
functionObjectLibs ( "libforces.so" );
outputControl timeStep;
outputInterval 1;
pName p;
UName U;
rhoName rhoInf;
CofR (0 0 0);
}

Expand Down
1 change: 1 addition & 0 deletions quickstart/fluid-openfoam/system/fvSchemes
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ divSchemes
{
default none;
div(phi,U) Gauss linearUpwind grad(U);
div((nuEff*dev(T(grad(U))))) Gauss linear; // Only relevant to foam-extend
div((nuEff*dev2(T(grad(U))))) Gauss linear;
}

Expand Down
18 changes: 18 additions & 0 deletions quickstart/fluid-openfoam/system/fvSolution
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ solvers
tolerance 1e-6;
relTol 1e-4;
smoother DICGaussSeidel;
// The following entries are only relevant to foam-extend
agglomerator faceAreaPair;
nCellsInCoarsestLevel 10;
mergeLevels 1;
}

pFinal
Expand Down Expand Up @@ -78,3 +82,17 @@ potentialFlow
{
nNonOrthogonalCorrectors 1;
}

// The relaxationFactors and fieldBounds are only relevant to foam-extend
relaxationFactors
{
U 0.7;
UFinal 1;
}

fieldBounds
{
p -1e5 1e5;
U 100;
}

1 change: 1 addition & 0 deletions quickstart/fluid-openfoam/system/preciceDict
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ interfaces
FSI
{
rho rho [1 -3 0 0 0 0 0] 1000;
nu nu [0 2 -1 0 0 0 0] 0.001; // Only relevant to foam-extend
}
47 changes: 47 additions & 0 deletions tools/run-foam-extend.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env sh
set -e # Not setting -u as it gets triggered by the OpenFOAM RunFunctions

# Prepare an (intentionally empty) .foam file for the ParaView OpenFOAM reader
CASENAME="$(pwd | xargs basename)"
touch "$CASENAME.foam"

# Keep a backup of the files to modify
echo "backing up the original files (copies: 0/U.orig, system/controlDict.orig, constant/dynamicMeshDict.orig)"
cp 0/U 0/U.orig
cp system/controlDict system/controlDict.orig
cp constant/dynamicMeshDict constant/dynamicMeshDict.orig

# Modify code for foam-extend
echo "modifying everything now"
sed -i "s/noSlip;/noSlipWall;/g" 0/U
sed -i "s,application pimpleFoam;,//application pimpleFoam;,g" system/controlDict
sed -i "s,// application pimpleDyMFoam;,application pimpleDyMFoam;,g" system/controlDict
sed -i '41i\ \ \ \ "liblduSolvers.so"' system/controlDict
sed -i '41i\ \ \ \ "libforces.so"' system/controlDict
sed -i "s,writeCompression off,writeCompression uncompressed,g" system/controlDict

sed -i "s/libfvMotionSolvers\./libfvMotionSolver\./g" constant/dynamicMeshDict

# OpenFOAM run functions: getApplication, getNumberOfProcessors
# shellcheck disable=SC1090 # This is an OpenFOAM file which we don't need to check
. "${WM_PROJECT_DIR}/bin/tools/RunFunctions"
solver=$(getApplication | cut -f 1 -d " " | sed '\~//~d')
if [ "${1:-}" = "-parallel" ]; then
procs=$(getNumberOfProcessors)
decomposePar -force
mpirun -np "${procs}" "${solver}" -parallel
reconstructPar
else
${solver}
fi

# Reverse code for OpenFOAM
#rm -rf constant/polyMesh
#sed -i "s/noSlipWall;/noSlip;/g" 0/U
#sed -i "s,application pimpleDyMFoam;,// application pimpleDyMFoam;,g" system/controlDict
#sed -i "s,//application pimpleFoam;,application pimpleFoam;,g" system/controlDict
#sed -i '/ "liblduSolvers.so"/d' system/controlDict
#sed -i '/ "libforces.so/d' system/controlDict
#sed -i "s,writeCompression uncompressed,writeCompression off,g" system/controlDict
#
#sed -i "s/libfvMotionSolver\./libfvMotionSolvers\./g" constant/dynamicMeshDict