OpenFoam (.com)#

OpenFoam is an open source Computation Fluid Dynamics Package.

OpenFoam homepage: openfoam.com/

Official OpenFoam Tutorials: openfoam.com/documentation/tutorial-guide

See also

For examples and tips on submitting jobs, see our SLURM documentation and Best Practices for Jobs

For compute resources, see HPC Queues

Using OpenFoam on M3#

Files used in the example are available:

  • on github

  • on M3 at /hpc/m3/examples/openfoam/

Example submission script#

The following job script can be submitted using sbatch openfoam_example.sbatch.

It requires a decomposeParDict to run, (see e.g. running in paralell). An example file is included in the files mentioned above

This example should run in approximately 10 seconds and use about 600 MB of memory when using 4 tasks. Therefore, we request 1 GB of memory and 3 minutes of run time to give ourselves some room for error.

Note, we know this from running the job. It is always a good idea to review the resources your jobs use and adjust future jobs to more accurately request resources.

 1#!/bin/bash
 2#SBATCH --nodes=1
 3#SBATCH --ntasks-per-node=4
 4#SBATCH --mem=10G
 5#SBATCH --job-name=OpenFOAM
 6#SBATCH --output=output_OpenFOAM_%j.out
 7#SBATCH --time=00:05:00
 8#SBATCH -p dev
 9
10# load openfoam
11module purge
12module load gcc/11.2.0
13module load openfoam/2312-5z7e7ot
14module load openmpi/4.1.6-vfi4iwj
15
16# make a test directory in scratch with the Job id
17# NOTE: $SCRATCH has a 60 day purge policy
18mkdir -p ${SCRATCH}/openfoam/test_run_${SLURM_JOB_ID}/
19cd ${SCRATCH}/openfoam/test_run_${SLURM_JOB_ID}/
20
21# copy example from official tutorial
22cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
23chmod 700 -R pitzDaily && cd pitzDaily
24
25# copy our decomposeParDict into the $SCRATCH job folder
26cp ${SLURM_SUBMIT_DIR}/decomposeParDict system/decomposeParDict
27
28# run the example
29srun blockMesh
30srun decomposePar
31srun simpleFoam -parallel