OpenFoam

OpenFoam is a popular open source CFD software. There are two main forks of the same software available:

There are various installations of these installed in Triton.

OpenFOAM installations

Below is a list of installed OpenFOAM versions:

OpenFOAM provider

Version

Module name

openfoam.com

v1906

openfoam/1906-openmpi-metis

openfoam.org

9

openfoam-org/9-openmpi-metis

openfoam.org

8

openfoam-org/8-openmpi-metis

openfoam.org

7

openfoam-org/7-openmpi-metis

Running OpenFOAM

OpenFOAM installations are built using OpenMPI and thus one should reserve the resources following the MPI instructions.

When running the MPI enabled programs, one should launch them with srun. This enables SLURM to allocate the tasks correctly.

Some programs included in the OpenFOAM installation (such as blockMesh and decomposePar) do simulation initialization in a serial fashion and should be called without using srun.

Examples

Running damBreak example

One popular simple example is an example of a dam breaking in two dimensions. For more information on the example, see this article.

First, we need to take our own copy of the example:

module load openfoam-org/9-openmpi-metis
cp -r $FOAM_TUTORIALS/multiphase/interFoam/laminar/damBreak/damBreak .

Second, we need to write a Slurm script run_dambreak.sh:

#!/bin/bash -l
#SBATCH --time=00:05:00
#SBATCH --mem=4G
#SBATCH --ntasks=4
#SBATCH --output=damBreak.out

set -e

module load openfoam-org/9-openmpi-metis

cd damBreak

blockMesh
decomposePar

srun interFoam -parallel

After this we can submit the Slurm script to the queue with sbatch run_dambreak.sh. The program will run in the queue and we will get results in damBreak.out and in the simulation folder.

Do note that some programs (blockMesh, decomposePar) do not require multiple MPI tasks. Thus these are run without srun. By contrast, the program call that does the main simulation (interFoam -parallel) uses multiple MPI tasks and thus is called via srun.