To allow smooth installation and use of multiple OpenFOAM versions on
the same system, we use the following structure:
The top-level meta package that provides links and requirements for the most recent openfoam release
Similar to mpi-selector, used to switch active openfoam versions
The maintenance version for 1906
The maintenance version for 1812
The version-specific packages (eg, openfoam1906, openfoam1812)
install into distinct directories so that it is possible to have
multiple versions available on your systems.
The top-level openfoam package registers which of the
version-specific packages corresponds to the current release.
Finally, the openfoam-selector package is used to register which
openfoam packages are installed on the system and allows the use to
select one of them.
To display which versions are installed:
Most people will find the openfoam-selector-menu more convenient to
WARNING: Changes made to the openfoam-selector defaultswill not be visible until you start a new shell!
NOTE Similar to the behaviour of the mpi-selector, the values
registered via the openfoam-selector will not be activated until the
next full login. This is to avoid a possible clash of environments
when a parallel job still being launched. Of course, you can still
simply source the corresponding bashrc file directly. For example,
$ source /opt/openfoam1906/etc/bashrc
Depending on how your packaging system has done things, an openfoam
session command may be available as an alternative to the
On the openSUSE installation, for example:
Note that the Debian packages may have been created with applications in
/usr/bin and configuration files under /usr/share/openfoam/etc.
In this case, you may need to manually define the location of the
OpenFOAM directory as follows:
The installation of openfoam with spack will generally require the
latest (development version) of spack. If this is available, you can
install openfoam in various configurations and dependencies, but
typically can simply install directly:
$ spack install openfoam
To help with RPM-based systems, the following content is provided for
reference purposes, and to help when scripting:
By default, OpenFOAM handles newer/older non-system compilers as
ThirdParty installations and uses the combination of WM_COMPILER
and WM_COMPILER_TYPE to select them. In some cases, however, it can
be much more convenient for the user to install prebuilt compiler
binaries as system compilers (eg, using deb or rpm packages).
This poses a slight problem since the OpenFOAM build rules normally
use the main compiler name (gcc, clang etc) without any additional
version information, but the various system compilers are frequently
installed with versioned names such as gcc-8, clang-9 etc.
Here is a simple way to solve this, using clang-9 on openSUSE for the
Or if this shall be restricted to system compilers only:
# Override compiler calls for llvm-9ifeq ($(WM_COMPILER_TYPE),system) cc = clang-9 CC = clang++-9 -std=c++11endif
The final step is to select this compiler definition with the following
# Preferences for system Clang90export WM_COMPILER=Clang90export WM_COMPILER_TYPE=system
If this change represents your standard default compiler definition,
then place the information into the etc/prefs.sh file (see the
etc/bashrc file for some details) and re-source your OpenFOAM
If you would like to selectively enable this compiler definition, a
common means is to place the same definition information into a user
configuration file (for example, ~/.OpenFOAM/clang90) and then
specify that configuration when sourcing your OpenFOAM environment.