Frequently Asked Questions

Running OpenFOAM
Last Updated 6 months ago


OpenFOAM is produced by OpenCFD Ltd, is freely available and open source, licensed under the GNU General Public Licence.


The OpenFOAM (Open Field Operation and Manipulation) CFD Toolbox can simulate anything from complex fluid flows involving chemical reactions, turbulence and heat transfer, to solid dynamics, electromagnetics and the pricing of financial options.

The core technology of OpenFOAM is a flexible set of efficient C++ modules. These are used to build a wealth of: solvers, to simulate specific problems in engineering mechanics; utilities, to perform pre- and post-processing tasks ranging from simple data manipulations to visualisation and mesh processing; libraries, to create toolboxes that are accessible to the solvers/utilities, such as libraries of physical models.

OpenFOAM is supplied with numerous pre-configured solvers, utilities and libraries and so can be used like any typical simulation package. However, it is open, not only in terms of source code, but also in its structure and hierarchical design, so that its solvers, utilities and libraries are fully extensible.

OpenFOAM uses finite volume numerics to solve systems of partial differential equations ascribed on any 3D unstructured mesh of polyhedral cells. The fluid flow solvers are developed within a robust, implicit, pressure-velocity, iterative solution framework, although alternative techniques are applied to other continuum mechanics solvers. Domain decomposition parallelism is fundamental to the design of OpenFOAM and integrated at a low level so that solvers can generally be developed without the need for any parallel-specific coding.


On Arctur-2 we have various versions of OpenFOAM and OpenFOAM-Extend available as modules.


To use, load the OpenFOAM or OpenFOAM-Extend module to add it to your environment. There are multiple versions installed, to see a list of available versions use:

module spider OpenFOAM

Choose the desired version and load it with the modules command, if you are unsure which one to choose, the default version will be loaded with this command:

module load OpenFOAM

OpenMPI and GCC will automatically be loaded, but you can always load a specific version later using the modules command.

Running parallel OpenFOAM jobs

Before you run your simulations, you have to make sure that your mesh will be efficiently divided across the computing resources. We have 28-core CPUs on every node, and you would ideally make use of all of them.

In your OpenFOAM simulation, there is usually a folder named 'system' and a filed named 'decomposeParDict' inside. Open decomposeParDict in your favourite editor. The entry 'numberOfSubdomains' specifies the number of subdomains into which the case will be decomposed, usually corresponding to the number of processors available for the case. If you want to use one node, that number shoud be 28, if you want to use more nodes, 28 should be multiplied by the amound of nodes you want to utilise.

In this example we are using 4 nodes, so:

numberOfSubdomains 112;

We also need to adjust n = (x y z) in hierarchicalCoeffs (could be a different name depending on the simulation like simpleCoeffs) accordingly, so that their multiplication is equal to numberOfSubdomains.

After this parameter is set, in the same directory, run
$ srun -N1 decomposePar -force

in order to automatically construct subdirectories. These will have been created, one for each processor, in the case directory. The directories are named processorN, where N = 0,1, ...
To run this, you need to submit a batch job.

Make a job submit file like this (works for 16 cores). We have configured modules and SLURM to take care of all the environment variables, so unless you want something specific, you don't need to worry about it.
An example of a batch script for OpenFOAM (you will need to adjust the path of your OpenFOAM simulation folder):


#SBATCH -n 112
#SBATCH --time=48:00:00 #SBATCH -A Arctur # your project name - contact Ops if unsure what this is
module load OpenFOAM
cd lesCase
mpirun -np 112 pisoFoam -parallel > log.piso 2>&1
Save it 'runScript' (or whatever you like).
Submit the job from the case directory (or give the path in the submit file) with

$ sbatch runScript

The above example works on a local multiprocessor machine. It is possible to run across a network. Look at section 3.4.2 in the User Guide for information about that.

OpenFOAM is often used as a framework when developing own codes for solving problems. Applications come in two main categories; solvers and utilities. It is often possible to find an already existing application that is similar to what you would like to do. Copy that and modify it for your purposes. When reading the OpenFOAM documentation on the issue, please note the following regarding where to place your binaries/libraries in order for it to work:

If you have further questions, please contact

Additional info

Please Wait!

Please wait... it will take a second!