Installing solids4foam from Source


Source a supported version of OpenFOAM, then download, build and test solids4foam-v2.0:

git clone --branch v2.0
cd solids4foam && ./Allwmake -j && cd tutorials && ./Alltest

The -j flag instructs Allwmake to use all available cores. For the latest nightly build, specify the development branch instead of v2.0. For a detailed installation guide, see below.

Detailed Installation Guide

Supported Versions of OpenFOAM/foam

solids4foam requires a working version of OpenFOAM or foam-extend. Currently, the following OpenFOAM versions are supported:

solids4foam version OpenFOAM/foam version
solids4foam-v1.* foam-extend-4.0
solids4foam-v2.* foam-extend-4.1

Optional fixes for the OpenFOAM installation

The solids4foam Allwmake script will ask you to fix files in the main OpenFOAM/foam installation. If you do not want to (or cannot) make these changes, please set the environmental variable S4F_NO_FILE_FIXES=1 before running the Allwmake script when building solids4foam, e.g.

> export S4F_NO_FILE_FIXES=1 && ./Allwmake -j

To make these fixes, follow the instructions from the Allwmake script when building solids4foam.

See the page on Optional Fixes for further details on these optional changes.



These dependencies are optional. You can skip them if you want to get up and running quickly.

Beyond a working version of OpenFOAM or foam-extend, solids4foam does not have any mandatory dependencies; however, several optional dependencies are required to use the complete set of functionalities:

Dependency Functionality Provided
Eigen Block-coupled cell-centred and vertex-centred solid models linear solvers
PETSc Block-coupled vertex-centred solid models linear solvers
gfortran Abaqus UMAT mechanical law interface
cfmesh Some tutorials use cfmesh for creating the meshes
gnuplot Some tutorials use Gnuplot to generate graphs after running the solver


Before building solids4foam, the EIGEN_DIR environment variable can be set to the local Eigen installation location. If EIGEN_DIR is not set, then solids4foam will download a local copy of Eigen.

If you would like solids4foam not to use Eigen (e.g. due to version conflicts when using preCICE), set the S4F_NO_USE_EIGEN environment variable, e.g. add the following to your bashrc

> export S4F_NO_USE_EIGEN=1


The binaries for PETSc can be installed on Ubuntu with

> sudo apt install petsc-dev

Or, on macOS with

> brew install petsc

Alternatively, and more generally, PETSc can be installed following the instructions at

Once PETSC has been installed, the PETSC_DIR environment variable should be set to the installation location; this allows solids4foam to use it. If the PETSC_DIR environment variable is not set, then solids4foam will not use PETSc and functionalities that require PETSc will be disabled. For example, on Ubuntu you can do this with:

export PETSC_DIR=/lib/petsc

Or, if using homebrew, on macOS (you may need to update the version number)

export PETSC_DIR=/opt/homebrew/Cellar/petsc/3.17.2

Add the export PETSC_DIR statement to your ~/.bashrc file to set this variable for new terminal sessions automatically.


gfortran can be installed on Ubuntu with:

> sudo apt-get install gfortran

Or, on macOS with

> brew install gcc

If the GCC compilers were used to compile OpenFOAM or foam-extend, then a compatible version of gfortran should be installed. For example, gfortran-7 should be used with gcc-7.

solids4foam will use gfortran if the gfortran executable is found in the $PATH; if not, solids4foam will disable functionalities that require gfortran.


A small number of tutorials require the cartesianMesh utility from cfmesh. If the cartesianMesh executable is not found within the $PATH then the Allrun script within these tutorials will exit.

  • foam-extend: cfmesh is included in foam-extend.
  • (OpenCFD/ESI version): compatible versions of cfmesh can be installed from
  • (Foundation version): the free version of cfmesh is currently not compatible with


gnuplot can be installed on Ubuntu with:

> sudo apt-get install gnuplot

Or, on macOS with

> brew install gnuplot

Downloading the solids4foam Source Code

The solids4foam directory can be downloaded to any reasonable location on your computer; we suggest placing it in $FOAM_RUN/...

Archive file

solids4foam-v2.0 can be downloaded as an archive file:

Git repository: v2.0

solids4foam-v2.0 can be downloaded using

> git clone --branch v2.0

Git repository: latest development branch

The latest nightly build development branch can be downloaded with

> git clone --branch development

Building solids4foam

Before building solids4foam, a compatible version of OpenFOAM or foam-extend should be sourced: see the table above. To build solids4foam, enter the solids4foam directory and execute the included Allwmake script, e.g.

> cd solids4foam
> ./Allwmake -j 2>&1 | tee log.Allwmake

Depending on your hardware, you can expect this build to last about 5 minutes.

If solids4foam is built successfully, you will be presented with the following message:

There were no build errors: enjoy solids4foam!
To test the installation, run:
    > cd tutorials && ./Alltest

If the build encounters errors, you will receive the following message:

There were build errors in the following logs:

Please examine these logs for additional details

You can examine the source of the errors in the log.Allwmake file within the solids4foam parent directory. Additionally, please search for similar errors. If you cannot find a resolution, please create a new thread at Alternatively, if you believe you have encountered a bug, please create a new issue at

Testing the Installation

As instructed, after a successful build, you can test the tutorials using the following commands, executed from the solids4foam parent directory.

> cd tutorials && ./Alltest

You can expect these tests to last a few minutes.

If the tests pass, you will receive the message:

All tests passed: enjoy solids4foam.

This means your solids4foam installation is working as expected.

If any of the tests fail, you will receive the message:

The solids4Foam solver failed in the following cases:

or if the errors do not come from the solids4foam calls but elsewhere

The following commands failed:

What Next?

Please see the tutorial guide.