Running OpenFOAM CFD on Apple Silicon

Many years ago, when I first started learning the basics of OpenFOAM, the software pretty much only ran on Linux. I ended up having to build a dedicated Ubuntu machine just to get it to function. Despite the amount of work, the setup was reliable enough, and because I only used the software sporadically, I've been using it that way ever since.
This year I need to create significantly more computational fluid dynamics (CFD) simulations. To speed up my workflow I've been looking into running the software on Windows and macOS. I was especially keen to check out performance on Apple's M1 chip.
Taking it easy
It turns out installation on Windows is now an absolute breeze thanks to integration with Windows Subsystem for Linux (WSL).
The Windows documentation is mostly straightforward to follow, although instructions have yet to be updated to cover OpenFOAM v10 which was released back in summer of last year. References to openfoam9
need to be amended to read openfoam10
. There is also the option to choose the openfoam-dev
path to use the current development version instead.
Beyond that, everything works as described and after a few minutes I was up and running.
Command performance
The process for macOS is slightly trickier, as it relies on Docker containers. This macOS documentation is easy enough to follow, but the OpenFOAM foundation have only provided a Dockerfile for amd64 architecture, meaning their environment executes under slower Rosetta emulation.
Thankfully Gabriel Gerlero has stepped up to provide a precompiled OpenFOAM environment for ARM-based processors. After switching over to this alternate Dockerfile, the installation completed smoothly and crucially OpenFOAM is very quick on M1. Apple Silicon continues to impress nearly two years after its release.
Running simpleFoam
against the standard aerofoil validation sample took around 6 seconds to complete. This is of course dependant on the angle of attack, grid cell size and NACA profile selected. Previously this was taking nearly a minute on the older Linux machine.

Note that the hardware is not in any way comparable, but I am hugely pleased with the result. Surprisingly, Docker doesn't appear to add too much overhead here either.
I do wish that the OpenFOAM Foundation would make the effort to create an official ARM environment script. Associated apps such as ParaView, Gnuplot and Gedit are also optimised for Apple Silicon, so there is no reason to load any of this through Rosetta emulation.
Being able to perform CFD simulations on a faster, quieter machine is a total game changer for me.
It is arguably much easier to get up and running with Windows' brilliantly useful WSL integration, but it is hard not to be impressed by the performance of OpenFOAM on a portable MacBook Pro.