Repository Release

Repository Release

Version 2.3.x, released 17/02/14, updated regularly

Overview

This page describes how to download and compile the very latest source code of OpenFOAM that includes fixes for all submitted bugs. Installing OpenFOAM by compiling source code requires some experience in administration on the Linux operating system, so is not recommended for all. The simpler approach is to install one of the pre-packaged installations.

Git Software

The sources can be obtained using the Git open source version control system that is commonly available on Linux distributions. Those with administrator permission can install the git software, e.g. by first switching to root user with sudo by typing in a terminal

sudo su -
On Ubuntu, git can be installed by executing the following command in a terminal prompt

apt-get install git-core
Similarly it can be installed on OpenSuSE by the following command.

zypper install git-core

Also it can be installed on RHEL by the following command.

yum install git

Downloading the Sources

The user should choose a directory location to download and unpack the files, which will become the installation directory of OpenFOAM. If the installation is for a single user only, or if the user does not have root access to the machine, we would recommend the installation directory is $HOME/OpenFOAM (i.e. a directory OpenFOAM in the user’s home directory). If the installer has root permissions and the installation is for more than one user, one of the ‘standard’ locations can be used, e.g. /usr/local/OpenFOAM, /opt/OpenFOAM, or just /opt. After the installation directory is chosen (and, if necessary, created) download and unpack OpenFOAM-2.3.x and ThirdParty-2.3.1 as follows.

OpenFOAM-2.3.x

The OpenFOAM-2.3.x repository is available at https://github.com/OpenFOAM/OpenFOAM-2.3.x. From the OpenFOAM installation root directory the repository can be obtained using

EITHER
the git protocol (git://), which is very efficient:
  • git clone git://github.com/OpenFOAM/OpenFOAM-2.3.x.git

Note: the git protocol will not work if your computer is behind a firewall which blocks the relevant TCP port (9418).

OR
the https protocol (https://), which is fairly inefficient:
  • git clone https://github.com/OpenFOAM/OpenFOAM-2.3.x.git

Note: while the TCP port for https is rarely blocked by a firewall, download hangs have been experienced; upgrading to git version 1.7 seems to overcome this problem.

Either of the commands above will create an OpenFOAM-2.3.x directory that the user can subsequently be updated to the latest published copy using

  • cd OpenFOAM-2.3.x
  • git pull

ThirdParty

The source-pack containing additional software required to build and run OpenFOAM-2.3.x is available from SourceForge: Click to download ThirdParty-2.3.1.tgz now. In the OpenFOAM installation root directory unpack the ThirdParty-2.3.x.gtgz file and rename the unpacked directory ThirdParty-2.3.x:

  • tar xzf ThirdParty-2.3.1.tgz
  • mv ThirdParty-2.3.1 ThirdParty-2.3.x

System Requirements

OpenFOAM is developed and tested on Linux, but should work with other POSIX systems. OpenFOAM-2.3.x and ThirdParty-2.3.x have been tested on the following Linux distributions:

  • Ubuntu 14.04 (trusty), 14.10 (utopic)
  • OpenSuSE 13.1

In the following instructions, log in as the root user or switch to root user with sudo by typing in a terminal

sudo su -

Dependent packages required for Ubuntu can be installed by executing the following command in a terminal:

apt-get install build-essential flex bison cmake zlib1g-dev qt4-dev-tools libqt4-dev gnuplot libreadline-dev libncurses-dev libxt-dev

System versions of the OpenMPI, Scotch and GCAL libraries can also be installed for Ubuntu, rather than having to compile them from sources:

apt-get install libscotch-dev libopenmpi-dev libcgal-dev

Dependent packages required for OpenSuSE can be installed by executing the following commands in a terminal:

zypper install -t pattern devel_C_C++
zypper install cmake libqt4-devel boost-devel gnuplot

Dependent packages required for RHEL 6.5 need updating to newer versions, e.g. Gcc needs upgrading from v4.4 to v4.7+. These upgrades may be available under a RHEL support subscription. If not, then upgrades can be obtained from unofficial repositories using the following instructions:

  1. Programming tools can be installed by executing the following commands in a terminal:

    yum groupinstall 'Development Tools'
    yum install openmpi openmpi-devel
    yum-config-manager --nogpgcheck --add-repo http://dl.atrpms.net/el6-x86_64/atrpms/stable
    yum install --nogpgcheck qtwebkit qtwebkit-devel
    yum install --nogpgcheck CGAL CGAL-devel

    The Boost C++ library is installed automatically for GCAL under the name libboost_thread-mt.so, but it requires the library to be named libboost_thread.so. To work around this inconsistency, a soft link should be created as follows:

    ln -s /usr/lib64/libboost_thread-mt.so /usr/lib64/libboost_thread.so
  2. In order to activate OpenMPI, add the path entries below, for example by including the following within the users .bashrc file:

    export PATH=/usr/lib64/openmpi/bin/:$PATH
    export LD_LIBRARY_PATH=/usr/lib64/openmpi/lib/:$LD_LIBRARY_PATH
    The user can check that MPI is available on their system by typing the following:

    mpirun --version
  3. The GCC compiler may need to be upgraded to version 4.7 or higher, a requirement for OpenFOAM. The compiler can be upgraded by adding the following repositories and installing as follows:

    yum-config-manager --nogpgcheck --add-repo http://springdale.princeton.edu/data/puias/6.5/x86_64/os
    yum-config-manager --nogpgcheck --add-repo http://springdale.princeton.edu/data/puias/DevToolset/6.5/x86_64
    yum install --nogpgcheck devtoolset-1.1-runtime devtoolset-1.1-gcc.x86_64 devtoolset-1.1-gcc-c++.x86_64
        
    This creates an isolated installation of GCC which can be used by sourcing the relevant script by typing the following in a local terminal:

    source /opt/rh/devtoolset-1.1/enable
    The user can check that the correct version of GCC is available on their system by typing the following:

    gcc --version

OpenFOAM-2.3.x also builds on many other and older Linux distributions but the ParaView-4.1.0 version supplied in ThirdParty requires cmake-2.8.8 or higher and Qt-4.7.2 or higher which can be obtained from various repositories for many Linux distributions. To check your system setup, you can execute the foamSystemCheck script, described in “Checking the System” (below).

Setting Environment Variables

The environment variable settings are contained in files in an OpenFOAM-2.3.x/etc directory in the OpenFOAM release. e.g. for the case where the installation is in $HOME/OpenFOAM, in:

  • $HOME/OpenFOAM/OpenFOAM-2.3.x/etc

EITHER
if running bash or ksh (if in doubt type echo $SHELL), source the etc/bashrc file by adding the following line to the end of your $HOME/.bashrc file:

source $HOME/OpenFOAM/OpenFOAM-2.3.x/etc/bashrc
then type “source $HOME/.bashrc” in the current terminal window
OR
if running tcsh or csh, source the etc/cshrc file by adding the following line to the end of your $HOME/.cshrc file:

source $HOME/OpenFOAM/OpenFOAM-2.3.x/etc/cshrc

then type “source $HOME/.cshrc” in the current terminal window

Setting environment variables for alternative locations

OpenFOAM may also be installed in alternative locations. However, the installation directory should be network available (e.g. NFS) if parallel calculations are planned.

The environment variable FOAM_INST_DIR can be used to find and source the appropriate resource file. Here is a bash/ksh/sh example:

export FOAM_INST_DIR=/data/app/OpenFOAM
foamDotFile=$FOAM_INST_DIR/OpenFOAM-2.3.x/etc/bashrc
[ -f $foamDotFile ] && . $foamDotFile
and a csh/tcsh example:

setenv FOAM_INST_DIR /data/app/OpenFOAM
foamDotFile=$FOAM_INST_DIR/OpenFOAM-2.3.x/etc/cshrc
if ( -f $foamDotFile ) source $foamDotFile
The value set in $FOAM_INST_DIR will be used to locate the remaining parts of the OpenFOAM installation.

Checking the System

To check your system is ready to build the sources, execute the foamSystemCheck script (in the OpenFOAM-2.3.x/bin directory). If any critical software is missing, or needs updating to a newer version, please contact the system administrator to install the required software before proceeding to the build.

In particular your system will need to include a recent version of a C++ compiler. Compilation has been tested with the following compilers and versions:

  • GCC: 4.5.0 and above
  • LLVM Clang: 3.4
  • Intel ICC: 14.0.1

The default compiler for OpenFOAM is GCC. OpenFOAM v2.2 series will only compile with versions of GCC above 4.5.0. Administrators and users can check the version of GCC running on their system by typing

gcc --version
If the installed version is not recent, the source pack for newer versions are available from http://gcc.gnu.org/.

Building the Sources

Go to the top-level source directory $WM_PROJECT_DIR and execute the top-level build script ./Allwmake. In principle this will build everything, but if problems occur with the build order it may be necessary to update the environment variables and re-execute ./Allwmake.

wmake

OpenFOAM uses wmake to perform compilation (building, linking) of its C++ source code into executable code. wmake is called from the Allwmake scripts during the initial build of the complete OpenFOAM project but can be executed directly to update the compilation of any of the OpenFOAM components:

  • all invocations can have an optional directory:

    wmake $FOAM_UTILITIES/mesh/manipulation/checkMesh
    wmake libso $FOAM_SRC/finiteVolume
  • recursively build all applications in current or specified directory:

    wmake all
    wmake all <dir>
  • build any single object or executable:

    wmake Make/linux64Gcc4DPOpt/<object>.o
    wmake <executable>
  • build any single shared library:

    wmake libso
    wmake libso <lib dir>

wmakeScheduler for faster compilation

wmake comes with a parallel compilation scheduler, wmakeScheduler, which spawns compilation jobs on free machines. These machines need password-less network access, e.g. using SSH, and a network mounted installation, e.g. using NFS.

wmakeScheduler is set up with environment variables:

  • WM_SCHEDULER : the name of the scheduler to use
  • WM_HOSTS : the list of cores to use
  • WM_NCOMPROCS : the number of parallel builds (usually the size of WM_HOSTS)
  • WM_COLOURS : Optional list of colours for the compilation output from the cores.

For example to build on 1 processor of machine aaa and 4 processors of bbb:

export WM_SCHEDULER=wmakeScheduler
export WM_HOSTS="aaa:1 bbb:4"
export WM_NCOMPPROCS=$($WM_SCHEDULER -count)
export WM_COLOURS="black blue green cyan red magenta yellow"
wmakeScheduler uses ssh to spawn jobs on the listed machines so needs passwordless access and a network mounted installation

Compiling Paraview and the Paraview Reader Module

Paraview is the third-party software that we provide for graphical post-processing in OpenFOAM. Its compilation is automated using a script called makeParaView in the ThirdParty-2.3.x directory.

Before installing Paraview, check the version of cmake that is installed on the system. This can be done by typing

cmake --version
If the system cmake is older than version 2.8.8, the version supplied in the Third Party pack can be compiled by executing the following:

cd $WM_THIRD_PARTY_DIR
./makeCmake

To install Paraview, execute the following (except for RHEL)

cd $WM_THIRD_PARTY_DIR
./makeParaView4

For RHEL, the system QT version is 4.6.2, which allows us to compile Paraview v3.12.0 only (rather than v4.1.0). The user is therefore required to change the default Paraview version setting in $WM_PROJECT_DIR/etc/config/paraview.sh (or paraview.csh for CSH users), which should subsequently be sourced:

export Paraview_VERSION=3.12.0
For RHEL, the user should then execute the following:

cd $WM_THIRD_PARTY_DIR
./makeParaView -qmake $(which qmake-qt4)

for all systems, the PV4blockMeshReader and the PV4FoamReader ParaView plugins are compiled as usual for OpenFOAM utilities. For RHEL, substitute “PV4Readers” with “PV3Readers” in the following command.

cd $FOAM_UTILITIES/postProcessing/graphics/PV4Readers
wmSET
./Allwclean
./Allwmake

Testing the Installation

To check your installation setup, execute the foamInstallationTest script (in the OpenFOAM-2.3.x/bin directory). If no problems are reported, proceed to getting started with OpenFOAM; otherwise, go back and check you have installed the software correctly and/or contact your system administrator.

Getting Started

Create a project directory within the $HOME/OpenFOAM directory named <USER>-2.3.x (e.g. chris-2.3.x for user chris and OpenFOAM version 2.3.x) and create a directory named run within it, e.g. by typing:

mkdir -p $FOAM_RUN
Copy the tutorial examples directory in the OpenFOAM distribution to the run directory. If the OpenFOAM environment variables are set correctly, then the following command will be correct:

cp -r $FOAM_TUTORIALS $FOAM_RUN
Run the first example case of incompressible laminar flow in a cavity:

cd $FOAM_RUN/tutorials/incompressible/icoFoam/cavity
blockMesh
icoFoam
paraFoam
Refer to the OpenFOAM User Guide to get started.

Reporting Bugs in OpenFOAM

We appreciate that bugs in OpenFOAM are reported so we can fix them. Please refer to the OpenFOAM bugs pages to report bugs.