OpenFOAM® Installation From Source

OpenFOAM®  Installation From Source

Preliminaries

  • 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 15.10, Ubuntu 14.04.3 LTS, CentOS and OpenSUSE Tumbleweed
  • Installation is possible on most other POSIX system with some minor additional settings

Build the code from source

  • Download OpenFOAM-v1706.tgz (md5sum: 630d30770f7b54d6809efbf94b7d7c8f)
  • Download ThirdParty-v1706.tgz (md5sum: 003d38fe3f97ccaa291bafbf94c768eb)
  • Unpack the tarballs to create the directories OpenFOAM-v1706 and ThirdParty-v1706

    tar -xzf OpenFOAM-v1706.tgz
    tar -xzf ThirdParty-v1706.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-v1706.tgz -C $HOME/OpenFOAM && tar -xzf ThirdParty-v1706.tgz -C $HOME/OpenFOAM
  • Source the OpenFOAM environment by executing, e.g. for bash shells:

    source ~/OpenFOAM/OpenFOAM-v1706/etc/bashrc
  • To build refer to the build guide

Frequently Asked Questions

  • 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) opencfd.co.uk.