Compile OpenFOAM from source on M1 Mac

I just spent 3 hours building ESI OpenFOAM-v2112 from source code locally(no need docker) on my m1 MacBook air. This blog is to record the process.

Although here is a very convenient already-built source for mac: gerlero/openfoam2112-app. I still chose to build it from the source on my own mac.

Preliminaries

Command line tools:

xcode-select --install

Homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Procedures

  1. Create a case-sensitive volume on mac. OpenFOAM requires a case-sensitive volume to build and run, yet mac does not support it by default.

    Open disk utility.app and follow these settings:

  2. Go to /Volumes/OpenFOAMs/, download and extract the source code and the patches for mac (thanks to BrushXue) to the same directory.

  3. Install dependencies with homebrew:

    brew install cmake open-mpi libomp adios2 boost fftw kahip metis
  4. Install modifiled scotch and CGAL@4 (Thanks to gerlero for creating this tap)

    brew tap gerlero/openfoam
    brew install scotch-no-pthread cgal@4
  5. And you probably need to add the following:

    export CPATH=/opt/homebrew/include
    export LIBRARY_PATH=/opt/homebrew/lib
  6. Source OpenFOAM's environment bashrc:

    source etc/bashrc
  7. Check the system and build (about 1 hour on MacBook Air)

    foamSystemCheck
    ./Allwmake -j -s -l
  8. Install paraview from Homebrew

    brew install --cask paraview
  9. Add alias to $home/.zshrc

    alias of="source /Volumes/OpenFOAMs/OpenFOAM-v2112/etc/bashrc"

Compile OpenFOAM from source on M1 Mac
https://daydreamatnight.github.io/2022/06/09/Build-OpenFOAM-from-source-on-M1-Mac/
Author
Ryan LI
Posted on
June 9, 2022
Licensed under