Installing OpenFOAM


The installation of OpenFOAM is documented on the OpenFOAM website. We briefly summarize the steps required to build OpenFOAM-dev on openSUSE 13.2 here, however the steps are similar on other distributions.

  1. Install the C/C++ development pattern in openSUSE
    • zypper install -t pattern devel_C_C++
  2. Install the following packages:
    • zypper install cmake gnuplot openmpi openmpi-devel git-core
  3. Install Qt 4 depedencies to be able to build Paraview:
    • zypper install libqt4-devel libQtWebKit-devel libQtAssistantClient4
  4. Check that openmpi 1.7.2 is selected as default with:
    • mpi-selector --list
    • The output should read: “openmpi-1.7.2″. If not, use mpi-selector to configure the default version of openmpi (this can be done for the individual user or system-wide, acquiring administrative rights)
  5. Create the OpenFOAM directory in your home directory:
    • mkdir ~/OpenFOAM
  6. Enter the OpenFOAM directory:
    • cd ~/OpenFOAM
  7. Download the source code from the git repository:
    • git clone https://github.com/OpenFOAM/OpenFOAM-dev.git
  8. Download the ThirdParty package (command on a single line)
    • wget -c downloads.sourceforge.net/foam/ThirdParty-2.4.0.tgz?use_mirror=mesh -O ThirdParty-2.4.0.gtgz
  9. Extract the ThirdParty package and rename it as follows:
    • tar xzf ThirdParty-2.4.0.gtgz
    • mv ThirdParty-2.4.0 ThirdParty-dev
  10. Execute
    • cp ~/OpenFOAM-dev/OpenFOAM-dev/etc/config/example/prefs.sh  ~/OpenFOAM/OpenFOAM-dev/etc/
    • Open this file with a text editor and make sure it contains the line
      • export WM_MPLIB=SYSTEMOPENMPI
  11. In order to use the ThirdParty package provided with OpenFOAM 2.4.0, you have to edit the following files to change the version number of some libraries to the one of the libraries contained in the ThirdParty package:
    • Edit
      • ~/OpenFOAM-dev/OpenFOAM-dev/etc/config/CGAL.sh
    • and make sure it contains the line
      • cgal_version=CGAL-4.6
    • Edit
      • ~/OpenFOAM-dev/OpenFOAM-dev/etc/config/paraview.sh
    • and make sure it contains the line
      • export ParaView_VERSION=4.3.1
    • Edit
      • ~/OpenFOAM-dev/OpenFOAM-dev/etc/config/scotch.sh
    • and make sure it contains the line
      • export SCOTCH_VERSION=scotch_6.0.3
    • This can be avoided downloading the versions of these libraries specified in the ThirdParty-dev repository.
  12. Add the following line to your ~/.bashrc file:
    • [Optional for multi-core compilation, replace 4 with the number of cores you want to use]:
      • export WM_NCOMPPROCS=4
    • source $HOME/OpenFOAM/OpenFOAM-dev/etc/bashrc
  13. Open a new terminal and execute this sequence of commands to compile the whole OpenFOAM suite
    • source ~/.bashrc
    • cd ~/OpenFOAM/OpenFOAM-dev
    • ./Allwmake
  14. To build paraview and its reader:
    • cd ~/OpenFOAM/ThirdParty-dev
    • ./makeParaView
    • cd $FOAM_UTILITIES/postProcessing/graphics/PV3Readers/
    • ./Allwclean
    • ./Allwmake
  15. At this point OpenFOAM-dev should be fully functional on your openSUSE 12.3. The installation can be updated, as usual, with:
    • cd ~/OpenFOAM/OpenFOAM-dev
    • git pull
    • wcleanLnIncludeAll
    • ./Allwmake