Today, I will teach you what is docker and how to install OpenFoam on a Mac M1 Pro using it.
If you don’t have a Mac, it will work the same on Windows and Linux, I just thought it would be cool to show you that you can also do CFD simulation with OpenFoam on a Mac ;-)
Here’s the video:
Now you might be wondering why you need docker at all and why it is so useful…
Why is Docker so useful?
If you start working with Automation, Python and scripting, you will quickly find that you can do a LOT of things!
There are basically python modules to do whatever your mind can conceive (and more)
The problem is that once you have built something really cool, it might become this huge Juggernaut of code which depends on several « custom » modules or you may even have to interact with executables written in other languages or compiled code…
So the problem is that it may work for you, but it would be crazy hard to install all what is needed for your system to work on another system.
Typically, if you want to hire someone to work together with you, how do you make it easy for your collaborator to install your system? Or for end users to install it on their machine?
That’s also what’s causing a lot of problem when you work with Open Source… Installing Code_Aster may work for the developer in his specific setup environment with all the pre-requisites installed…
But if you have a different setup or system, it will be crazy hard to compile and install.
Here comes « Docker! »
With Docker you can basically install everything with one simple command!
(You just need to have docker installed)
For example, with docker in one command line, you can install Code_Aster solver on your computer
You just need to install docker
and to pull the right «docker container »
What is Docker?
Docker is a bit like a virtual machine, but not exactly
Docker is faster and more lightweight to use than a virtual machine
Thus if you just want to fulfil one task (use a specific program that runs only a certain specific environment) docker is a great tool
Docker is using containers that are installed on top of your current OS system through the docker software
It doesn’t require to install a full new OS System in a virtual machine, it just takes the components of the system that are required to run the program you want to run.
Simple Docker Example
(Watch the video at the beginning of the article for all the details)
The easiest way to start understanding how to use docker is to look at the start tutorials and to really read in details the « Get started Pages »
Here’s the link:
It’s not always very clear though if you have low experience in development, so you might have to watch a few videos on Youtube to understand in a bit more details how it works.
I found this video pretty helpful:
Now how to install OpenFoam with Docker…
Installing OpenFoam with Docker on MacOS
You will find the OpenFoam installation procedure with Docker on this page:
(Again, watch the video at the beginning of the article for the details)
Now to run OpenFoam, you need to find the test cases that go together with this version.
If you try to run the open foam 9 test cases, it will not work…
Test cases for OpenFoam version 2112 are available here:
To post process the results, you will need to install Paraview and use the command foamToVTK to convert the results into VTK format
(Paraview is not installed within the contained so the command paraFoam will not work)
It should work and get you results like that:
If you have never used Paraview, you can check my free course on this Blog :)
Thanks for watching my videos and reading my articles as always!
If you have any question of comment, please post it here, I read all of them
Cyprien “First Docker Tutorial Wouhou!!” Rusu