OpenFOAM: Installation

From Define Wiki
Jump to navigation Jump to search

The installation steps for OpenFOAM depends on the choice of compilers and MPI being used. Most follow a common set of steps, but some setups such as those using Intel MPI require some additional steps.

Common Steps

Install the required libraries.

[root@xcatmn ~]# yum install '@development tools'

Create a directory to install OpenFOAM to.

[root@xcatmn ~]# mkdir -p /opt/OpenFOAM

Download the OpenFOAM and ThirdParty source tarballs into /tmp and extract them to the previously created installation directory.

[root@xcatmn ~]# cd /tmp
[root@xcatmn ~]# curl -LO https://sourceforge.net/projects/openfoam/files/v1912/OpenFOAM-v1912.tgz
[root@xcatmn ~]# curl -LO https://sourceforge.net/projects/openfoam/files/v1912/ThirdParty-v1912.tgz
[root@xcatmn ~]# tar -xf OpenFOAM-v1912.tgz -C /opt/OpenFOAM
[root@xcatmn ~]# tar -xf ThirdParty-v1912.tgz -C /opt/OpenFOAM

Now switch to the OpenFOAM source directory to prepare the build.

[root@xcatmn ~]# cd /opt/OpenFOAM/OpenFOAM-v1912
[root@xcatmn ~]# ls
Allwmake  applications  bin  COPYING  doc  etc  META-INFO  modules  README.md  src  tutorials  wmake

From this point on the steps to finish the install depend on compiler and MPI versions being used.

GCC and OpenMPI

GCC and OpenMPI is the simplest and most supported build. Essentially all the options to build are the defaults, so you just need to ensure that both the correct GCC and MPI versions are available in your PATH. It is recommended to use a newer version of GCC. In this example, GCC 8 and OpenMPI3 from the OpenHPC repos are being used.

Install the required versions of GCC and OpemMPI from the OpenHPC repos, as well as the lmod package.

[root@xcatmn OpenFOAM-v1912]# yum -y install gnu8-compilers-ohpc openmpi3-gnu8-ohpc lmod-ohpc
[root@xcatmn OpenFOAM-v1912]# module load gnu8
[root@xcatmn OpenFOAM-v1912]# module load openmpi3

To install OpenFOAM, source the environment file and run the build script. Note the '-j' flag is analogous to '-j' in GCC.

[root@xcatmn OpenFOAM-v1912]# pwd
/opt/OpenFOAM/OpenFOAM-v1912
[root@xcatmn OpenFOAM-v1912]# . etc/bashrc
[root@xcatmn OpenFOAM-v1912]# ./Allwmake -j

Note that this will use all available cores to compile which reduces build time but might cause noticeable slowness on systems for other users. If this is an issue either omit the -j flag or limit the number of cores by passing an integer argument

[root@xcatmn OpenFOAM-v1912]# ./Allwmake -j 2

Once the installation is complete you should see the binaries and libraries in a subdirectory of /opt/OpenFOAM/OpenFOAM-v1912/platforms, for example a build using GCC and double precision will install to

[root@xcatmn OpenFOAM-v1912]# ls /opt/OpenFOAM/OpenFOAM-v1912/platforms/linux64GccDPInt32Opt/
bin  lib

Intel ICC and Intel MPI

To be concluded...