Patch to compile OpenFOAM-v2206 on M1 Mac.
- Create to a case-sensitive volume like this
I usually create a soft link so I don't need to change etc/bashrc
ln -s /Volumes/OpenFOAM ~/OpenFOAM
cd ~/OpenFOAM
- Install these components from homebrew
brew install cmake open-mpi libomp adios2 boost fftw kahip metis
- Install modifiled
scotch
andCGAL@4
(Thanks to @gerlero for creating this tap)
brew tap gerlero/openfoam
brew install scotch-no-pthread cgal@4
- Clone the OpenFOAM source code into this volume
git clone https://develop.openfoam.com/Development/openfoam.git OpenFOAM-v2206
cd OpenFOAM-v2206
git checkout OpenFOAM-v2206
git submodule init
git submodule update
- Apply mrklein's patch for OpenFOAM-v2206
curl -OL https://github.com/mrklein/openfoam-os-x/raw/master/OpenFOAM-v2206.patch
git apply OpenFOAM-v2206.patch
- Apply my patch for M1.
curl -OL https://github.com/BrushXue/OpenFOAM-AppleM1/raw/main/M1.patch
git apply M1.patch
- Add OpenFOAM to
.zshrc
or.bashrc
echo 'source ~/OpenFOAM/OpenFOAM-v2206/etc/bashrc' >> ~./zshrc
And you probably need to add the following for M1:
export CPATH=/opt/homebrew/include
export LIBRARY_PATH=/opt/homebrew/lib
- Compile the code with bear (remove
-with-bear
if you don't need it).
./Allwmake -j -s -l -with-bear
It takes 40~45 minutes on M1.
- Install
paraview
from Homebrew
brew install --cask paraview
sigFpe is disabled for now until new solution comes.
It is suggested to run parallel command in scripts by using
. $WM_PROJECT_DIR/bin/tools/RunFunctions
runParallel ***Foam
to avoid macOS restrictions.
- Download swak4Foam
hg clone http://hg.code.sf.net/p/openfoam-extend/swak4Foam swak4Foam
cd swak4Foam
hg update develop
- Apply my patch for macOS.
curl -OL https://github.com/BrushXue/OpenFOAM-AppleM1/raw/main/swak4Foam.patch
git apply swak4Foam.patch
- Install these components from homebrew:
brew install bison pkgconfig
- Add bison to the path:
export PATH="$(brew --prefix)/opt/bison/bin:$PATH"
- Compile the code.
./AllwmakeAll
It takes approximately 6 minutes on M1.
python 2.7 is removed in macOS 12.3+. Therefore swakPythonIntegration
and funkyPythonPostproc
are disabled.
The benchmark is modified from https://www.cfd-online.com/Forums/hardware/198378-openfoam-benchmarks-various-hardware.html