The TwoPhaseFlow library adds new surface tension and phase change models to OpenFOAM and provides benchmark cases for verification.
The available models and solvers are documented in the paper:
Scheufler, H., & Roenby, J. (2023). "TwoPhaseFlow: A Framework for Developing Two Phase Flow Solvers in OpenFOAM". OpenFOAM® Journal, 3, 200–224. https://doi.org/10.51560/ofj.v3.80
For examples of applications and extensions of the TwoPhaseFlow library, have a look at the citing articles on google scholar.
Requires an installed OpenCFD version of OpenFOAM (v1812 or later) from https://www.openfoam.com.
The master branch currently (april 2026) compiles with OpenFOAM-v2406 to v2512. For older OpenFOAM versions (down to v1812) please checkout the appropriate branch. Don't expect older branches to be regularly updated or bug fixed. Use a newer OpenFOAM version if possible.
OpenFOAM.org versions are not supported.
git clone https://github.com/DLR-RY/TwoPhaseFlow
cd TwoPhaseFlow
# To compile e.g. with OpenFOAM-v2112 checkout the appropriate branch with:
# git checkout of2112
./Allwmake
./get-gmsh.sh # will install gmsh version 306 as gmshv306
# For AMR with DLB:
git submodule update --init --recursive
cd modules/multiDimAMR/
./AllwmakeMake sure that the desired OpenFOAM installation is sourced e.g. v2512 and that python is installed with a version >= 3.6 (miniconda is a great option, but anaconda works as well)
python -m venv env # creats virtual python enviroments (optional step)
pip install oftest
py.test # runs the tests
py.test --writeNSteps=1 run/ # test all testcases in run- Henning Scheufler
This project is licensed under the GPL v3 License - see the LICENSE.md file for details.
./get-gmsh.sh # Install gmsh
pip install casefoam
The run/benchmark cases are run with
cd run/benchmark/phaseChange/suckingInterface/
python genCases.py # Generates the study cases based and template case (here StefanProblem)
./Allrun # Runs all the created testcases
python getResults.py # See resultsAlternatively, the runAll.sh can be executed in the folder.
Note:
Some cases use the slurm queuing system and call sbatch Allrun_Slurm in the
Allrun script, so you might need to modify it in the template case.
For some of the solvers, depending on the libraries loaded with libs(...) in the controlDict, the log file may contain:
Duplicate entry isoAlpha in runtime table reconstructionSchemes
[stack trace]
=============
#1 platforms/linux64GccDPInt32Opt/lib/libgeometricVoF.so
...
This is because both the TwoPhaseFlow library libVoF.so and the OpenFOAM library libgeometricVoF.so add the reconstrucionSchemes to the runTime selection table. If for instance some loaded library links libincompressibleMultiphaseSystems.so, this loads libgeometricVoF.so and we get the conflict. The solver will, however, use the libVoF.so version as it should so the warnings can be safely ignored.
AMR with multiple regions does not work in version of1812 but it is fixed in newer versions.
To fix this, apply the patches (assumes OpenFOAM is already source):
cp patches/multiRegionAMR.patch $WM_PROJECT_DIR
cp patches/tableBase.patch $WM_PROJECT_DIR
cp patches/surfaceFieldValue.patch $WM_PROJECT_DIR
cd $WM_PROJECT_DIR
git apply multiRegionAMR.patch
git apply tableBase.patch
git apply surfaceFieldValue.patch
./AllwmakeImportant note: These patches are only possible if you have write access to your OpenFOAM-v1812 installation. After applying the pathes your OpenFOAM-v1812 installation will no longer be identical to the official OpenFOAM-v1812 release.
For details see: