OpenFOAM® Build Guide

OpenFOAM®  Build Guide

In the following sections, text in boxes should be entered into your shell window.

Ensure that the system requirements are satisfied as described here, and make sure to source the correct OpenFOAM environment e.g. for version OpenFOAM-v1612+

source ~/OpenFOAM/OpenFOAM-v1612+/etc/bashrc

Preliminaries

A new build guide for third party libraries can be found in $WM_PROJECT_DIR/ThirdParty-v1612+/BUILD.md

Several build issues related to specific compiler and VTK library versions can be found in $WM_PROJECT_DIR/BuildIssues.txt

ParaView

OpenFOAM is shipped with ParaView for post-processing OpenFOAM field results. This requires a separate compilation which can be omitted if using other post-processing software. To compile ParaView:

cd $WM_THIRD_PARTY_DIR
./makeParaView

CGAL

For most systems, CGAL is not normally installed or is likely to be an older version. We therefore recommend using CGAL from the ThirdParty source pack. This corresponds to the shipped settings in the etc/config.sh/CGAL file

cgal_version=CGAL-4.9

Boost

In most cases, the system boost libraries can be used for OpenFOAM and for building CGAL. This corresponds to the shipped settings in the etc/config.sh/CGAL file

boost_version=boost-system

If, however, the system boost libraries are either not installed, too old, or are missing some components e.g. threaded support, it is recommended to switch to using boost from the ThirdParty source pack.

boost_version=boost_1_62_0

Combining a ThirdParty boost with a system CGAL is neither supported by the OpenFOAM build process, nor is it recommended.

Compile OpenFOAM

The compilation process is self-contained and will compile and install all OpenFOAM code and dependencies.

  • Test the system readiness

    foamSystemCheck
  • Change to the main OpenFOAM directory ($WM_PROJECT_DIR). If this fails, the environment is not configured correctly

    foam
  • Compile OpenFOAM

    ./Allwmake
  • In case you need to stop the compilation, continue later by running Allwmake again

Compile OpenFOAM faster

For faster compilation, users can take advantage of multi-processor machines to build the code in parallel by setting the environment variable WM_NCOMPPROCS, e.g.

export WM_NCOMPPROCS=10
In addition, multiple machines can be used by setting:

export WM_SCHEDULER=wmakeScheduler
export WM_HOSTS="box1:4 box2:8"
export WM_NCOMPPROCS$($WM_SCHEDULER -count)
Where:
  • WM_SCHEDULER - flag to use the scheduler
  • WM_HOSTS - names of hosts and number of their CPUs to use
  • WM_NCOMPPROCS - number of parallel processes

Note that the wmakeScheduler requires the lockfile utility. This can be installed using, e.g. on Ubuntu:

sudo apt install procmail

Post-compilation steps

  • Open a new shell and source the OpenFOAM environment to see all changes (refer to top of page)
  • Validate the build by running

    foamInstallationTest
  • Create the user run directory:

    mkdir -p $FOAM_RUN
  • Test the installation with a simple tutorial:

    run
    cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily ./
    cd pitzDaily
    blockMesh
    simpleFoam
    paraFoam