- Linux, Unix-like systems
- Packaging systems
- Darwin (Mac-OS)
- Windows (cross-compiled)
|spack||package openfoam||Actively maintained by OpenCFD||notes|
|EasyBuild||package OpenFOAM||Maintained independently, with input from OpenCFD|
|debian, RPM||See precompiled||Actively maintained by OpenCFD|
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
The installation of OpenFOAM with easybuild will generally require the latest (development version) of easybuild.
The support for Darwin is complete, but less well tested than Linux.
- The Darwin build (and operation) requires a case-sensitive file system, which is often created as a disk image and mounted (for older systems).
- Compilation uses the system clang compiler.
- ThirdParty CGAL will normally need to be compiled without mpfr/gmp.
This should be done manually prior to building OpenFOAM or other
ThirdParty. For example,
cd $WM_THIRD_PARTY_DIR ./makeCGAL gmp-none mpfr-none
wmake/rules/darwin64Clang/CGALfile has been adjusted to eliminate references to gmp/mpfr libraries.
Windows 64bit binaries can be generated on 64bit Linux by cross-compilation.
Sometimes it is useful to switch between entire sets of configuration
preferences without re-editing the files each time. This is the
purpose of the
FOAM_CONFIG_ETC variable. It specifies an absolute
path, or a path relative to the project directory where various
configuration files can be found. These are selected in preference to
the normal shipped configuration files.
This allows swapping in a set of different preferences without modifying the regular settings. See cross-compilation for an example of its use.
Processor-specific builds are typically handled by creating a new compilation option. For example, to create Broadwell-specific options:
$ cd wmake/rules/linux64Gcc $ cp c++Opt c++OptBdw
edit this file and then use WM_COMPILE_OPTION=OptBdw in the
before re-sourcing the OpenFOAM environment.
Since OpenFOAM is purely C++ code, there is no need to apply special
processor-specific optimizations for C code (the regular
optimization is fine) since these components only appear as part of the
wmake build toolchain itself.
Different compiler versions
By default, OpenFOAM handles newer/older non-system compilers as
ThirdParty installations and uses the combination of
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 (e.g., using deb or rpm packages).
This poses a slight problem since the OpenFOAM build rules normally
use the main compiler name (
clang etc) without any additional
version information, but the various system compilers are frequently
installed with versioned names such as
Here is a simple way to solve this, using clang-10 on openSUSE for the example:
Install the desired system compiler. In this case clang-10 from tools:compiler which installs
Next override the OpenFOAM compiler calls, but without blindly rewriting everything.
We create a new directory for our special rules:
Inside this directory, we add an general rules file (
wmake/rules/linux64Clang100/general) with the following contents:
# Override compiler calls for llvm-10 cc = clang-10 CC = clang++-10 -std=c++11
Or if this shall be restricted to system compilers only:
# Override system compiler calls for llvm-10 ifeq (system,$(WM_COMPILER_TYPE)) cc = clang-10 CC = clang++-10 -std=c++11 endif
The final step is to select this compiler definition with the following combination:
# Preferences for system Clang100 export WM_COMPILER=Clang100 export WM_COMPILER_TYPE=system
If this change represents your standard default compiler definition, then place the information into the
etc/prefs.shfile (see the
etc/bashrcfile for some details) and re-source your OpenFOAM environment.
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/clang100) and then specify that configuration when sourcing your OpenFOAM environment. For example,
source /path/to/OpenFOAM-version/etc/bashrc clang100
bashrcwill locate and use the configuration file, after which the compiler will be properly selected. To verify that this is indeed the case:
should display the selected compiler. You may also wish to verify its path:
For older versions,
which $(wmake -show-cxx)instead.
Copyright (C) 2020-2021 OpenCFD Ltd.