In an earlier article we introduced the general main steps for investigating fluid motion using the computational fluid dynamics methodology. Within this article we dive deeper into how to conduct the simulation step, using OpenFOAM running on Docker.
Intro to OpenFOAM
OpenFOAM is an open-source package that includes numerical solvers that can be performed on the Navier-Stokes equations to get an approximate solution. OF also has geometry and meshing capability, which is beyond the scope of this article.
Intro to Docker
By using Docker, the aspiring researcher gains an isolated environment that can be reproduced (exactly), which is good for science and good for your mind -- instead of having to understand cross-platform issues you can focus on understanding the fluid dynamics of your investigation.
OpenFOAM: within Docker
A long-term user of OpenFOAM has generously made available a Docker script that easily creates a Docker image , which OpenFOAM can be executed upon, once this image is run within a Docker container (see above link for more instructions about how to make a Docker image):
sudo docker container run -ti --rm -v $HOME/cfd/openfoam/openfoam-data:/data -w /data openfoam:latest
OpenFOAM: simulating a case
After this container is launched, the user can then run a simplified, short 'case'. This case represents the abstracted flow scenario that will be simulated. For example, if we copy an OpenFOAM tutorial then examine it's file structure, using the following commands within the running container:
cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
You then see the breakdown of the case into more granular components (e.g. directories & files). Before a simulation can be done, first generate the meshed geometry by executing a meshing application within OpenFOAM's collection :
Then select a particular solution method (i.e. solver) to use on the case. In this instance the SIMPLE algorithm application is selected and simulation started by executing:
Once you achieve convergence (within approximately 300 iterations) you can then analyse your simulation results using post-processing software such as ParaView , which can be installed on your normal (host) operating system for ease-of-use.
In this article you were introduced to conducting your first computational fluid dynamics simulation using OpenFOAM, which was run on Docker. More technical information was deliberately omitted to keep this article very accessible. If you are interested in continuing to explore CFD using OpenFOAM there are more comprehensive tutorials available on OpenFOAM's website .
 OpenFOAM Dockerfiles:
 OpenFOAM User Guide:
 OpenFOAM Tutorial Guide: