Skip to content

OpenFOAM(R) v1912 and Homebrew

Alexey Matveichev edited this page Feb 9, 2024 · 1 revision

Differences from original release

  1. Switched C++ standard compilation flag to std=c++14 to comile CGAL-dependent parts of the code (Homebrew's CGAL is at version 5.x and requires C++14);
  2. As a result of 1 it was necessary to fix location of [deprecated] attribute;
  3. Imported HashTable modifications to avoid ugly conditional compilation in HashSet and bitSet;
  4. Modified OpenMP wmake rules.

Dependencies

The only required dependency to compile the software is a C++ compiler. Patches here is for Apples clang. One can try to build OpenFOAM(R) with Intel or PGI compilers, yet, the process is untested.

The following optional software could be installed to enable additional features:

  • Open MPI (parallel execution)
  • boost (mesh renumbering and dependency for CGAL)
  • CGAL (mainly foamyMesh)
  • Scotch, METIS, KaHIP (corresponding decomposition methods)
  • FFTW
  • ADIOS2 (ADIOS I/O)

To do the installation with Homebrew one can use the following command:

$ brew install adios2 boost cgal fftw kahip metis open-mpi

since Scotch is not in homebrew/core, it can be installed from formula in the repository with a command:

$ brew install https://raw.githubusercontent.com/mrklein/openfoam-os-x/master/formulae/scotch.rb

Certain run-time post-processing depends on VTK, unfortunately due to names clash between case-sensitive and case-insensitive file systems, this functionality is disabled.

Create disk image with case-sensitive file system

OpenFOAM(R) uses case-sensitive source files naming scheme, so it is necessary to have case-sensitive file system to compile it. If your home folder is on case-sesitive FS, you can skip this step. If you are not sure, create disk image.

The image is created with the following command:

$ hdiutil create -size 64g -type SPARSEBUNDLE -fs HFSX -volname OpenFOAM -fsargs -s OpenFOAM.sparsebundle

You can adjust image size and name according to your needs and preferences. Since it is sparse bundle, initial image size is smaller.

Mount disk image

Further steps are easier if the image is mounted into $HOME/OpenFOAM, since it is default location (if you prefer another location, adjust settings accordingly).

Disk is mounted with the following command:

$ mkdir -p $HOME/OpenFOAM
$ hdiutil attach -mountpoint $HOME/OpenFOAM OpenFOAM.sparsebundle

Get sources

Get patch

Apply patch

Setup environment

Compile software

Test