Running oomph-lib anywhere (in docker)

Oomph-lib is an open-source C++ finite-element library, a great versatile tool for 2 and 3-dimensional fluid and solid mechanical modelling. However, it is currently developed on Linux systems. While it is possible to run it on OSX, the setup isn’t trivial. Docker is a container solution, where programs are run in containers, which are isolated from the operating system but share its resources. In contrast to a virtual machine, a container only uses RAM and CPU when needed and releases it again when it has finished running the task at hand.  From the docker website:

Developers use Docker to eliminate “works on my machine” problems when collaborating on code with co-workers.

Let’s setup oomph-lib on docker! Images are specified enviroments in which programmes can be run. For example, our images will need to contain both gcc as well as svn. Containers are running instances of an image that allow code execution. However, containers are isolated environments that have no persistent storage. As we will want to save our code changes, we will need to work with docker mounts or volumes, a mechanism for persistent storage.

Before continuing, you need to install Docker

1. Build Ubuntu image with the necessary libraries to run oomph lib

The Dockerfile defines what libraries are installed in a container. Place this in a file called Dockerfile in an empty folder with the name oomphbase.

FROM ubuntu
RUN apt-get update && \
 apt-get install -y --no-install-recommends \
 autoconf \
 automake \
 dpkg-dev \
 g++ \
 gcc \
 libbz2-dev \
 libtool \
 make \
 gfortran \
 git \
 python \
 python-dev \ 
 python-pip \
 python-virtualenv \

CMD [ "sh", "-c", "bash"]

Build this image with the following command (when in the same directory)

docker build -t oomphbase

2. Start a container based on this image with a mount point to store the library

I have setup an empty folder at /Users/edgar/oomph-lib, amend as appropriate for your system.

docker run -d -it --name oomph --mount =bind,source=/Users/edgar/oomph-lib,target=/oomph-lib oomphbase:latest

3. Check that it is mounted correctly

docker inspect oomph

In the output you should find details on the mounting

  [ { "Type": "bind", 
      "Source": "/Users/edgar/oomph-lib", 
      "Destination": "/oomph-lib", 
      "Mode": "", 
      "RW": true, 
      "Propagation": "rprivate" } 

4. Get a Bash terminal

Attach a bash terminal to the docker container (you can attach as many terminals as you like with this command)

docker exec -i -t oomph /bin/bash

You should now be in the terminal of the Docker container.

5. Download and build oomph-lib

Run the following commands. This will take a while. Refer to the omph-lib page for any problems.

cd oomph-lib; svn checkout svn:// .

After download, run either the interactive or non-interactive script to build the library


At this point, you should have a ready installed oomph-lib library on your machine!

6. Optional: Run self-tests

It will take quite some time to run the self-tests

make check -k

Expected output

All 854 compiled test[s] passed successfully.

See /oomph-lib/self_test/analyse_self_tests/validation.log for details.

mpi_run_command_length: 0 Don't have mpi compiler... 



Left as an exercise to the reader

You can expose the X11 socket so that you can use graphical software, such as emacs or Paraview, in a Docker container. As the files are in a mount point of your system, it is also possible to modify them with an editor from your OS, just watch out for file ending problems.

For emacs, there is a guide how to do it here.

2 thoughts on “Running oomph-lib anywhere (in docker)

  1. Hello Edgar! Thank you so much for this incredible article, I’ve been struggling to install oomph-lib on my Mac Monterey but to no avail.
    I’ve followed your instructions above (edited the Dockerfile slightly) but when running make check -k two major errors appear:
    1) There seems to be some FPU issue with the triangle_meshes
    In file included from
    triangle_mesh.template.h: In constructor ‘oomph::TriangleMesh::TriangleMesh(const string&, const double&, oomph::TimeStepper*, const bool&)’:
    triangle_mesh.template.h:819:43: error: ‘_FPU_EXTENDED’ was not declared in this scope
    819 | fpu_control_t cw = (_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE;
    | ^~~~~~~~~~~~~
    triangle_mesh.template.h:819:60: error: ‘_FPU_DOUBLE’ was not declared in this scope
    819 | fpu_control_t cw = (_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE;
    | ^~~~~~~~~~~
    triangle_mesh.template.h: In member function ‘void oomph::TriangleMesh::generic_constructor(oomph::Vector&, oomph::Vector&, oomph::Vector&, const double&, oomph::Vector<oomph::Vector >&, std::map<unsigned int, oomph::Vector >&, std::map&, oomph::TimeStepper*, const bool&, const bool&, const bool&)’:
    triangle_mesh.template.h:1317:43: error: ‘_FPU_EXTENDED’ was not declared in this scope
    1317 | fpu_control_t cw = (_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE;
    | ^~~~~~~~~~~~~
    triangle_mesh.template.h:1317:60: error: ‘_FPU_DOUBLE’ was not declared in this scope
    1317 | fpu_control_t cw = (_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE;
    | ^~~~~~~~~~~
    triangle_mesh.template.h: In constructor ‘oomph::RefineableTriangleMesh::RefineableTriangleMesh(const oomph::Vector&, oomph::TriangulateIO&, oomph::TimeStepper*, const bool&, const bool&, oomph::OomphCommunicator*)’:
    triangle_mesh.template.h:2371:43: error: ‘_FPU_EXTENDED’ was not declared in this scope
    2371 | fpu_control_t cw = (_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE;
    | ^~~~~~~~~~~~~
    triangle_mesh.template.h:2371:60: error: ‘_FPU_DOUBLE’ was not declared in this scope
    2371 | fpu_control_t cw = (_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE;
    | ^~~~~~~~~~~

    2) None of the demo files can find “generic.h”, returning fatal error: generic.h: No such file or directory
    which resulted in all tests failing.

    Could you please help me out with this? I’m really excited to use oomph-lib. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *