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:
https://docs.docker.com/get-started/
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:
https://develop.openfoam.com/Development/openfoam/-/wikis/precompiled/docker
(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:
https://develop.openfoam.com/Development/openfoam/-/blob/master/doc/Build.md
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
Mattia says
Hello there. I’m just starting on CAE software. My FEM engineering course at Rome University requires us to install edu versions of preprocessing software and solvers such as Ansys Workbench, Mechanical, and Simcenter Femap by Nastran.
I currently have a Macbook Pro (Intel) with 8 GB of Ram and 512 GB SSD. I read that the solution to install VM Ware + Windows on the mac would just be too slow and wondered if maybe installing Linux on VM Ware could be a viable solution until I found your page about installing OpenFoam on Docker. I understand OpenFoam runs on Ubuntu, OpenSUSE, and Tumbleweed, which are Linux distributions.
1) Which distribution did you install OpenFoam on and did you find a noticeable sluggishness compared to a clean installation on a Linux box?
2) Do you have experience on running other Linux versions of CAD/FEM/CFD SW (SolidWorks, Ansys, Nastran, Abaqus, StarCCM+, Catia, CodeAster…) through Docker, and did you find them usable?
3) On a Mac would you say it’s a better choice to run this type of software on Docker using their Linux version compared to the Windows one?
Any additional details would be really welcome, thanks!
Mattia
Cyprien says
Hi Mattia,
I am using only Ubuntu for Linux, I haven’t compared with others. I think Ubuntu is a good choice for beginners in Linux. If you want more adventure, you can try Debian too ;-)
I have not compared the speed of Openfoam on Docker VS Virtual Machine VS normal installation.
My guess is that a normal installation will always be faster, then docker and then last VMWare (Pretty Slow).
If you try all of those and you want to write about it, don’t hesitate to send me your discoveries! That can help other engineers too.
Blue_serotta says
I can confirm that VMWare Fusion is very slow over an iMac (2013/Catalina) running an enterprise database server. It’s nice to keep your hand in SQL but not much else as you want to make sure not to stress the entire system, or vice versa and crash Fusion, obviating any logging.
Blue_serotta says
I am hoping to buy a (newly announced) Apple silicon Mac Mini or MacBook Pro (M2 Max) w/ 64 G ram/2Tb SSD, rather than a i7 Thinkpad with lots of NVMe
Yassik says
Hi I got problem setting environment ( for OpenFoam) on my MacBook M1pro. Can you tell how to do it? apparently there is a file …/etc/bachrc to be complied by source command. Compiling that gives me bunch of errors (while I have all requirements on my machine though!). Any help please? Thanks