- 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 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.
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 OpenCFD Ltd.