Skip to content

OpenFOAM

OpenFOAM (Open-source Field Operation And Manipulation) is a toolbox for the development of customised numerical solvers, and pre/post-processing utilities for the solution of continuum mechanics problems, most prominently including computational fluid dynamics (CFD).

OpenFOAM is available as a module on Apocrita.

Versions

There are two different forks of OpenFOAM available on the cluster: from OpenFOAM.com and OpenFOAM.org.

For the OpenFOAM.com version, load the openfoam module, and for the OpenFOAM.org version, load the openfoam-org module.

Usage

To run the default version of OpenFOAM, simply load the openfoam module:

module load openfoam

command

The command must be a valid OpenFOAM command. A few examples are listed below:

foamNew
blockMesh
pisoFoam

Add the -help parameter after any OpenFOAM command for usage information and examples.

Example jobs

In both examples below, substitute FOAM_PROJECT with your actual OpenFOAM project directory.

Serial job

Here is an example job running on 1 core and 5GB of memory:

#!/bin/bash
#SBATCH --ntasks=1        # (or -n 1) Request 1 core
#SBATCH --mem-per-cpu=5G  # Request 5GB RAM per core (5GB total)
#SBATCH --time=1:0:0      # (or -t 1:0:0) Request 1 hour runtime

module load openfoam

cd FOAM_PROJECT
blockMesh
pisoFoam

Parallel job

Here is an example job running on 96 cores across 2 ddy nodes with MPI:

#!/bin/bash
#SBATCH --partition=parallel  # (or -p parallel) Request the parallel partition
#SBATCH --nodes=2             # (or -N 2) Request 2 nodes
#SBATCH --ntasks=96           # (or -n 96) Request 96 cores
#SBATCH --time=240:0:0        # (or -t 240:0:0) Request 240 hours runtime
#SBATCH --exclusive           # Request all CPUs per node
#SBATCH --mem=0               # Request all available memory per node

module load openfoam

cd FOAM_PROJECT
blockMesh

# Slurm knows how many tasks to use for mpirun, detected automatically from
# ${SLURM_NTASKS}. Use -- to ensure arguments are passed to the application
# and not mpirun
mpirun -- \
  interFoam

References