How to install OpenFOAM into M1 MAC
This is a short note about how to operate OpenFOAM by using the Docker image on my M1 MAC (Monterey on Macbook Air M1–2020) environment.
Preparation
Docker has been supported Apple silicon chip already, then install Docker by the following link;
https://docs.docker.com/desktop/mac/apple-silicon/
Following instructions for installing OpenFOAM
Follow the install instruction for OpenFOAM with Docker by the following link;
https://develop.openfoam.com/Development/openfoam/-/wikis/precompiled/docker
Download the openfoam-docker run script to the proper directory, cf /usr/local/bin or else, and try it.
You could see “WARNING” which mentioned the Docker image is inconsistent with the host platform (/linux/arm64/v8), thus the Docker would try to execute it through “Rosetta 2” to handle as Intel-base platform. It works but is very slow.
openfoam$ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
openfoam$ cd pitzDaily
openfoam$ blockMesh
openfoam$ time simpleFoam
....
real 1m20.504s
user 1m18.608s
sys 0m0.455s
Download Dockerfiles
To build a proper Dockerfile which can work natively on Apple-silicon, download the container package files from the following Github repository;
https://develop.openfoam.com/packaging/containers
Then rebuild the ARM image by following instruction;
% cd containers-main/docker
% docker build -t opencfd/openfoam-run -f openfoam-run_leap.Dockerfile .
% openfoam-docker
There is no WARNING
openfoam$ cd pitzDaily
openfoam$ blockMesh
openfoam$ time simpleFoam
....
real 0m7.756s
user 0m5.963s
sys 0m0.357s
Almost x10 times faster !!
paraView
As mentioned in the Wiki FAQ section in following;
https://develop.openfoam.com/Development/openfoam/-/wikis/precompiled/docker
You SHOULD use the paraView directory on your M1 MAC, not through Docker.
Download ARM paraView package which has been supported by Apple-silicon already.
Install ParaView-5.10.0-MPI-OSX11.0-Python3.9-arm64.dmg
Then empty file on OpenFOAM working directory as follows;
openfoam$ cd pitzDaily
openfoam$ touch x.foam
Launch the paraView and Open x.foam file by File menu;
Enjoy…