OpenFOAM® Installation From Source


  • Make sure that your system complies with the system requirements
  • The Source contains all the source code needed for compilation on a Linux system
  • Installation was tested on Ubuntu 16.04 LTS, CentOS 7.4 and OpenSUSE Tumbleweed
  • Installation is possible on most other POSIX system with some minor additional settings

Build the code from source

  • Download OpenFOAM-v2012.tgz (md5sum: 4b83938a8c939a84b7e985e4f5ab7543)
  • Download ThirdParty-v2012.tgz (md5sum: 89171ed9a03505cd42f3b17ac40fa8b1)
  • Unpack the tarballs to create the directories OpenFOAM-v2012 and ThirdParty-v2012
    tar -xzf OpenFOAM-v2012.tgz
    tar -xzf ThirdParty-v2012.tgz
  • OpenFOAM can be installed either to:
    • the user home directory, e.g. $HOME/OpenFOAM, or
    • to a system wide directory, e.g. /opt/OpenFOAM.
  • The default is the home directory, for a different location adapt the foamInstall in the set up file etc/bashrc.
  • If unsure, the following line will extract files to the $HOME/OpenFOAM directory:
    mkdir $HOME/OpenFOAM && tar -xzf OpenFOAM-v2012.tgz -C $HOME/OpenFOAM && tar -xzf ThirdParty-v2012.tgz -C $HOME/OpenFOAM
  • Source the OpenFOAM environment by executing, e.g. for bash shells:
    source ~/OpenFOAM/OpenFOAM-v2012/etc/bashrc
  • To build refer to the build guide

Frequently Asked Questions on Docker

  • Is there any performance degradation when running via Docker?
    No performance penalties are expected. On Linux, OpenFOAM inside Docker should run as fast as natively compiled code. On Windows and Mac OS X there may be a slight performance penalty associated with I/O.
  • How do I check if the OpenFOAM image has been downloaded correctly?
    Type the command
    docker images
    to show the images available in Docker environment, e.g.
    REPOSITORY                         TAG       IMAGE ID        CREATED        VIRTUAL SIZE
    openfoamplus/of_v1706_centos73     latest    88d542266184    4 hours ago    1.574 GB
    If you receive an error message about not being able to contact the Docker daemon check that
    • the Docker daemon is started at boot time
    • the user account is in the group ‘docker’
  • Where are my files?
    The user files inside Docker are visible (i.e. mounted) in your home area and can be operated on just like any other file.
  • Why doesn’t paraFoam display?
    • Make sure that your machine’s software is fully up-to-date. See if you can start a simple X-windows, non-graphics program, e.g.: xterm If this does not come up there may be a problem with the xhost access to the host screen. This is one of the steps inside the startOpenFOAM script.
    • An alternative remedy is to install the native ParaView version for your system, and use the built-in OpenFOAM reader and/or OpenFOAM data conversion tools.
  • How do I run parallel?
    Same as any other OpenFOAM installation, e.g.: mpirun -np 2 icoFoam -parallel
  • How do I run parallel on multiple computers?
    This is not trivial inside the Docker environment. Also you might want to include optimised communication libraries (MPI) so it probably makes more sense to perform a native compilation.
  • How do I compile code?
    The Docker environment contains a full OpenFOAM development environment so all Allwmake, wmake, wclean etc. commands work (it is running the actual environment OpenFOAM was compiled in!)
  • What does installOpenFOAM do?
    It downloads the OpenFOAM image from the Docker Hub and creates a specialised container. This container
    • mounts the home directory of the user with read/write access
    • optionally channels the graphics
    • sets up the OpenFOAM environment.
    The image itself was created from CentOS 7.3. If you wish to install any additional tool in your docker container, start it as usual via the startOpenFOAM script, login as root with the password ofuser2017 and use e.g. yum.
  • I still have questions...
    The Docker route to OpenFOAM is new and still being refined. It you have comments/tips please mail them to: docker (at)