Close

1st May 2016

OpenFOAM Repo: 5. Compiling OpenFOAM

With the Third Party software installed and environment updated, compile OpenFOAM by going into the OpenFOAM-dev directory.  It contains a script named Allwmake which can execute the compilation in serial, by default, or parallel with the -j option.  It can also compile multiple libraries and executables simultaneously with the -q option.  OpenFOAM can be compiled quickly using the -j and -q options, although these options make it more difficult to locate the origin of any compilation error.  With the -j option the number of cores for parallel compilation can be specified otherwise all detected cores/hyperthreads will be used.

Fast compilation

To compile OpenFOAM as quickly as possible, run

./Allwmake -q -j <n>

where <n> optionally specifies the number of cores, e.g. 16.  With 64 cores and fast disk, the entire code (1.5M lines) can compile in ~4 minutes (beat that cmake).

Sequential compilation

To compile each component of OpenFOAM sequentially in serial, run

./Allwmake

Sequential compilation in serial takes ~2 hours but it is easier to locate any compilation errors.

Updating the System

The source repositories, in particular OpenFOAM-dev, are updated regularly.  Updates can be “pulled” to your source directory by executing in the OpenFOAM-dev directory

git pull

The updates can then be compiled into OpenFOAM with the -update option (with or without the parallel -j option):

./Allwmake -update

If the update build does not compile correctly, e.g. after some very major changes, then the platform should be cleaned before recompiling with

wcleanPlatform
./Allwmake

← Back: 4. Installing Third Party Software | Up: Main Page