OpenFOAM 5.0 is a major new release of OpenFOAM, accompanied by ParaView 5.4.0, compiled with the official OpenFOAM reader module. It is packaged for Ubuntu 14.04, 16.04, 17.04, 17.10 and 18.04. For macOS, we provide instructions below on using Docker for Mac to provide a self-contained environment for OpenFOAM 5.0 that includes code, runtime, system tools and libraries. Requirements for Docker for Mac are:
- a 2010 or newer model, with Intel’s hardware support for memory management unit (MMU) virtualization;
- macOS 10.10.3 Yosemite or newer;
- at least 4GB of RAM;
- VirtualBox prior to version 4.3.30 must NOT be installed.
Step 1: Before Installing Docker
- The user requires superuser password authentication to execute the following commands with
sudo. If in doubt, talk to your system administrator.
- Ensure you have a network connection to download packages via
- The user can choose to enable graphical applications from the container. This is generally beneficial because it allows applications like gnuPlot to run (used for monitoring data, e.g. residuals with
- The speed of ParaView running from the Docker container is very slow. For much better performance, users can install ParaView directly on macOS. Note, however, that builds of ParaView direct from its producer, Kitware, do not contain the official reader module for OpenFOAM data, but instead use a native reader module that is not fully functional.
- OpenFOAM file names are case-sensitive. If you wish to output data to an OpenFOAM-compatible file system, which we recommend, check whether your file system is case-sensitive before proceeding.
Step 2: Installing Docker for Mac
Follow the Instructions for Installing Docker for Mac.
Step 3: Installing openfoam5-macos
OpenFOAM 4 is launched from a script named
openfoam5-macos. The script is available from the OpenFOAM Download Site and needs to be located somewhere on the user’s
PATH for convenient execution. The following commands will then install in the system-wide
/usr/local/bin directory and make the script executable:
sudo curl --create-dirs -o /usr/local/bin/openfoam5-macos http://dl.openfoam.org/docker/openfoam5-macos sudo chmod 755 /usr/local/bin/openfoam5-macos
Step 4: Enabling Graphical Applications (optional, recommended)
The Docker container runs Ubuntu Linux which uses the X Window System (“X11”, or “X”) to display graphical applications, such a ParaView, gnuPlot and gedit. Graphical applications can be displayed in the host macOS by connecting the application programs from the container to an X server on the host. macOS does not run an X server by default, so the user needs to install and run one; the most popular is Xquartz, which can be run as follows:
- Go to the Xquartz website, select the latest download and install.
- Start XQuartz.
- Check “Allow connections from network clients” and “Authenticate connections”.
- Shut down and Restart XQuartz.
Step 5: Case-sensitive filing system
If the user’s filing system is not case-sensitive, then they can create a case-sensitive volume using the
openfoam-macos-file-system script. Install the script in the system-wide
/usr/local/bin directory and make it executable by:
sudo curl -o /usr/local/bin/openfoam-macos-file-system http://dl.openfoam.org/docker/openfoam-macos-file-system sudo chmod 755 /usr/local/bin/openfoam-macos-file-system
In default-mode, the script will create a volume named
openfoam with size of 10GB, mounted at
$HOME/openfoam, which includes a
run directory corresponding to the
$FOAM_RUN environment variable in the Docker container. The defaults can be overridden using options listed by running with the help option by:
In particular, the user can set the size of the volume for their OpenFOAM data with “
-s <size>” where size is in GB. Commands exist to create, mount, unmount, delete and compact the volume:
openfoam-macos-file-system -s 20 create: creates a 20GB file system.
openfoam-macos-file-system mount: mounts the file system.
openfoam-macos-file-system unmount: unmounts the file system.
openfoam-macos-file-system automount: mounts the file system, automatically on machine boot.
openfoam-macos-file-system delete: deletes the file system permanently, losing all data.
Step 6: Launching openfoam5-macos
The Docker container mounts the user’s file system so that case files are stored permanently. The container mounts the directory from where
openfoam5-macos is launched by default, but the user can also specify the directory using the “
-d” option. Mounting the user’s
$HOME directory is disallowed. Where a case-sensitive volume has been created, the container mount directory would typically coincide with the mount directory (or sub-directory) of the volume. For example, for a case-sensitive volume mounted in the default location,
$HOME/openfoam, the Docker container is run without ParaView as follows:
cd $HOME/openfoam openfoam5-macos
To run the container with ParaView, use the “
-p” option, i.e.
The first time the container is launched, there is a short wait while the image downloads and unpacks. Note that mounted directory is represented in the container environment by the
WM_PROJECT_USER_DIR environment variable.
Step 7: Testing openfoam5-macos
run directory already exists (if not, run “
mkdir -p $FOAM_RUN”), copy across the backward facing step example, generate the mesh with blockMesh and run the steady flow, incompressible solver simpleFoam
cd $FOAM_RUN cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily . cd pitzDaily blockMesh simpleFoam
If ParaView is included in the container, then it can be run from the container by typing:
Refer to the OpenFOAM User Guide to get started.
Step 8: Exiting Docker
When finished using OpenFOAM in Docker exit the environment by typing:
If you encounter an issue with this installation, please report it to the OpenFOAM Issue Tracking system.
Thanks to Francesco Contino (from the Contributors to OpenFOAM) and Arnaud Borner for testing and reporting their experience with OpenFOAM on macOS.