Skip to content
NAISS Logo
Allocations Support Training Software naiss.se

Openfoam

Support tier: 3

Read information about support tiers.

Installed versions

Resource Version
Arrhenius-GPU/cpe25.09 v2606
Arrhenius/cpe25.09 v2512
Dardel-GH/cpe25.03 v2606
Dardel/cpe26.03 v2512, v2506, v2406, 13, 12

Read information about how to load this software in your environment by searching for Lmod module.

General information

General information

OpenFOAM is a free, open source CFD software package.

See also http://www.openfoam.com and http://www.openfoam.org

As the current versions of OpenFOAM are very easily to generate massive small files, you mast consider questions before running OpenFOAM such as:

  • How often do you save your solution?
  • What trace/history of your iterations do you write to file(s)?

To control this behavior you need to modify the corresponding parameters in system/controlDict

writeControl    timeStep;
writeInterval   10000;
i.e. specify the number of timeStep for writeInterval as large as possible.

Moreover, setting writeCompression to compressed would really do a damper on the file system. We already know that if someone set runTimeModifiable to yes that will have an adverse effect on performance since OpenFOAM then will check a lot of files at every single iteration. As a result, you should adapt the simulations to the system by tweaking the following parameters:

writeCompression                    uncompressed;
runTimeModifiable                   no;
It is highly recommended that you run OpenFoam on your project directory to avoid any disk quota problems

How to use OpenFOAM on Arrhenius

On Arrhenius, some of the versions of the installations of openfoam are setup with cray-mpich, as can be identified from the suffix in the module name. The versions installed with cray-mpich would require that the container for the cray environment is activated in the first place. One can use the command hpc_container_shell cpe_25_09 to launch an interactive shell with the container. Once the container is activated, the available versions can be checked using module avail OpenFOAM.

Running on the Batch system

A sample job script for running openfoam simulations on Arrhenius (cray-mpich version) can be found below

#!/bin/bash
#SBATCH -n <#NTasks>
#SBATCH -N 1
#SBATCH -t <wall-time>
#SBATCH -A <allocation>
#SBATCH -p <partition>
#SBATCH -J <job-name>

hpc_container_exec cpe_25_09  bash -c 'module load OpenFOAM/2512-cray-mpich && source $FOAM_BASHRC && \
blockMesh > blockMesh.out && \
checkMesh -allTopology -allGeometry -constant > checkMesh.out &&\
decomposePar > decomposePar.out 2>&1'


srun --cpu-bind=verbose hpc_container_exec cpe_25_09 bash -c 'module load OpenFOAM/2512-cray-mpich && source $FOAM_BASHRC && \
pisoFoam -parallel > out.log 2>&1'

How to use OpenFOAM on Dardel

To see which versions of OpenFOAM are installed on any of the machines at PDC log into the machine and type module avail openfoam after loading the PDC module (i.e. after running the command module load PDC)

Running on the Batch system

A sample job script for running openfoam simulations on Dardel can be found below

#!/bin/bash -l

#The name of the script is mytest
#SBATCH -J mytest

#SBATCH -A <allocation>

# 12 hour wall-clock time will be given to this job
#SBATCH -t 12:00:00

# Set the partition for your job. 
#SBATCH -p <partition>

# Number of nodes
#SBATCH --nodes=2

# Number of MPI processes per node (default 128)
#SBATCH --ntasks-per-node=128

# Load the openfoam module
module load PDC
module load openfoam/v2406

# Set the openfoam environment variables
. $FOAM_BASHRC

# Change OpenFoam user directory to the project directory
# Comment the three lines below if not running on the project directory

WM_PROJECT_DIRECTORY2=$(pwd)
export WM_PROJECT_USER_DIR=$WM_PROJECT_DIRECTORY2/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
export FOAM_RUN=WM_PROJECT_USER_DIR/run

# Start the OpenFOAM job with 256 MPI-tasks on 2 nodes

srun -n 256 -N 2 <openfoam binary> -case <path to case directory> -parallel > my_output_file 2>&1