-
-
Notifications
You must be signed in to change notification settings - Fork 33
ESI OpenFOAM(R) and Homebrew
Usually this OpenFOAM(R) version does not require patches. This guide can be considered as an extended version of the official build instructions.
This guide assumes you've got Homebrew package manager installed. If it is not the case, install it following instructions at http://brew.sh.
Text in the monospace
font is commands you need to enter at the shell prompt. In
the guide it is denoted as $
so if you copy-n-paste commands from the guide,
you don't need to copy that character.
<version>
suffix, which is used in the guide, depends on the actual version,
you are installing. Adapt the guide for your requirements.
Before starting the installation you need to make certain decisions:
- Third-part packages. The guide assumes, you need them all. However for
minimal installation you just need
open-mpi
. - Case-sensitive partition creation. The guide assumes, you would like to create sparse disk image. As an alternative, you can create APF volume.
- Size of the disk image. The guide sets it to 64 G, you can set it to a smaller value.
- How you are going to configure paths to system-wide installed third-party
libraries. There are two possible approaches: edit configuration files
in-tree (
etc/config.sh/scotch
, etc) or create configuration in home folder ($HOME/.OpenFOAM/config.sh/scotch
, etc). Later is shared between all OpenFOAM(R) installations. OpenFOAM(R) provides helper script for this purpose (bin/tools/foamConfigurePaths
), unfortunately it does not allow to configure all third-party libraries (for example,PETSc
configuration is missing) and is not compatible with macOS's sed. The guide provides commands for creation of configuration in the home folder. - What third-party functionality you need to be compiled. For example, FFTW
library is used in noise-generation utilities. So, if you are not quite
interested in turbulence, you can skip compilation of this utility. And
instead of
fftw-system
you putfftw-none
in your configuration files. - Do you need additional OpenFOAM(R) modules? If yes, you do not need to set
FOAM_MODULE_PREFIX
tofalse
.
Overview of the installation procedure is following:
$ brew install open-mpi libomp boost cgal metis scotch fftw adios2 hypre kahip petsc vtk
$ cd $HOME
$ hdiutil create -size 64g -type SPARSEBUNDLE -fs HFSX -volname OpenFOAM -fsargs -s OpenFOAM.sparsebundle
$ mkdir -p $HOME/OpenFOAM
$ hdiutil attach -mountpoint $HOME/OpenFOAM OpenFOAM.sparsebundle
$ cd $HOME/OpenFOAM
$ _v=<version>; curl -LO https://dl.openfoam.com/source/$_v/OpenFOAM-$_v.tgz
$ tar xzf OpenFOAM-<version>.tgz
$ cd OpenFOAM-<version>
$ mkdir -p $HOME/.OpenFOAM
$ echo 'export WM_COMPILER=Clang' > $HOME/.OpenFOAM/prefs.sh
$ echo 'export WM_COMPILE_OPTION=Opt' >> $HOME/.OpenFOAM/prefs.sh
$ echo 'export WM_MPLIB=SYSTEMOPENMPI' >> $HOME/.OpenFOAM/prefs.sh
$ echo 'export WM_NCOMPPROCS=$(sysctl -n hw.ncpu)' >> $HOME/.OpenFOAM/prefs.sh
$ echo 'export WM_LABEL_SIZE=32' >> $HOME/.OpenFOAM/prefs.sh
$ echo 'export WM_QUIET=1' >> $HOME/.OpenFOAM/prefs.sh
$ echo 'export FOAM_EXTRA_CXXFLAGS=-I/usr/local/opt/libomp/include' >> $HOME/.OpenFOAM/prefs.sh
$ echo 'export FOAM_EXTRA_LDFLAGS=-L/usr/local/opt/libomp/lib' >> $HOME/.OpenFOAM/prefs.sh
$ echo 'export WM_COMPILE_CONTROL="~openmp"' >> $HOME/.OpenFOAM/prefs.sh
$ echo 'export FOAM_MODULE_PREFIX=false' >> $HOME/.OpenFOAM/prefs.sh
$ mkdir -p $HOME/.OpenFOAM/config.sh
$ for f in CGAL FFTW adios2 hypre kahip metis petsc scotch vtk; do \
_s="etc/config.sh/$f"; \
_t="$HOME/.OpenFOAM/config.sh/$f"; \
[ -e $_s ] && { echo "$_s -> $_t"; cp $_s $_t; } \
done
$ for f in $HOME/.OpenFOAM/config.sh/*; do \
echo -n "Processing $f ... "; \
for l in boost CGAL FFTW adios2 hypre kahip metis petsc scotch vtk; do \
_v="$(echo $l | tr '[A-Z]' '[a-z]')_version"; \
_s="$(echo $l | tr '[A-Z]' '[a-z]')-system"; \
_p="$(echo $l | tr '[a-z]' '[A-Z]')_ARCH_PATH"; \
sed -i~ -e '/^[^#]/s@'"${_v}=.*"'@'"${_v}=${_s}"'@' -e '/^[^#]/s@'"${_p}=.*"'@'"${_p}=/usr/local"'@' $f; \
done; \
echo "DONE"; \
done
$ source etc/bashrc
$ [ "$(ulimit -n)" -lt "8192" ] && ulimit -n 8192
$ ./Allwmake > log.Allwmake 2>&1
OpenFOAM(R) uses different third-party libraries to avoid reinventing a wheel. The list of possible libraries are following:
-
OpenMPI
: for parallel communications. -
Boost
: for mesh renumbering and as a dependency forCGAL
. -
CGAL
: for geometric operations in foamyHexMesh. -
ADIOS 2
: for I/O operations. -
KaHIP
,METIS
,Scotch
: for mesh decomposition. -
PETSc
,HYPRE
: for additional linear system solvers. -
VTK
: for run-time visualization.
OpenFOAM(R) users case-sensitive file naming scheme, while MacOS is usually
installed on case-insensitive volumes. To avoid name clashes (ex. OpenFOAM's
Time.H
and system time.h
) user must create disk image or sub-volume with
case-sensitive file system.
$ cd $HOME
$ hdiutil create -size 64g -type SPARSEBUNDLE -fs HFSX -volname OpenFOAM -fsargs -s OpenFOAM.sparsebundle
$ mkdir -p $HOME/OpenFOAM
$ hdiutil attach -mountpoint $HOME/OpenFOAM OpenFOAM.sparsebundle
$ cd $HOME/OpenFOAM
Commands create disk image OpenFOAM.sparsebundle
in user home folder
($HOME
), create mount point for the disk, attaches the disk to the mount
point, and goes in the freshly mounted folder.
If you prefer to use APF sub-volume, refer to corresponding wiki page.
$ _v=<version>; curl -LO https://dl.openfoam.com/source/$_v/OpenFOAM-$_v.tgz
$ tar xzf OpenFOAM-<version>.tgz
ESI packages OpenFOAM(R) sources for download. Use can download sources using
preferred browser or use command line using curl
, which is available on MacOS
by default. -L
switch instructs curl to follow redirection (as the sources are hosted on
SourceForge, there are several redirections till the final download), -O
saves downloaded file in OpenFOAM-<version>.tgz
file (i.e. it uses remote
file name).
After the sources archive is downloaded it is extracted using tar
.
Here I modify content of files with echo
and sed
. If you prefer, you can edit corresponding files by hand.
$ mkdir -p $HOME/.OpenFOAM
$ echo 'export WM_COMPILER=Clang' > $HOME/.OpenFOAM/prefs.sh
$ echo 'export WM_COMPILE_OPTION=Opt' >> $HOME/.OpenFOAM/prefs.sh
$ echo 'export WM_MPLIB=SYSTEMOPENMPI' >> $HOME/.OpenFOAM/prefs.sh
$ echo 'export WM_NCOMPPROCS=$(sysctl -n hw.ncpu)' >> $HOME/.OpenFOAM/prefs.sh
$ echo 'export WM_LABEL_SIZE=32' >> $HOME/.OpenFOAM/prefs.sh
$ echo 'export WM_QUIET=1' >> $HOME/.OpenFOAM/prefs.sh
If you plan to use OpenMP, add corresponding extra flags:
$ echo 'export FOAM_EXTRA_CXXFLAGS=-I/usr/local/opt/libomp/include' >> $HOME/.OpenFOAM/prefs.sh
$ echo 'export FOAM_EXTRA_LDFLAGS=-L/usr/local/opt/libomp/lib' >> $HOME/.OpenFOAM/prefs.sh
If you do not need additional modules, add this line:
$ echo 'export FOAM_MODULE_PREFIX=false' >> $HOME/.OpenFOAM/prefs.sh
Set all libraries version and paths to system-wide installed ones:
$ mkdir -p $HOME/.OpenFOAM/config.sh
$ for f in CGAL FFTW adios2 hypre kahip metis petsc scotch vtk; do \
_s="etc/config.sh/$f"; \
_t="$HOME/.OpenFOAM/config.sh/$f"; \
[ -e $_s ] && { echo "$_s -> $_t"; cp $_s $_t; } \
done
$ for f in $HOME/.OpenFOAM/config.sh/*; do \
echo -n "Processing $f ... "; \
for l in boost CGAL FFTW adios2 hypre kahip metis petsc scotch vtk; do \
_v="$(echo $l | tr '[A-Z]' '[a-z]')_version"; \
_s="$(echo $l | tr '[A-Z]' '[a-z]')-system"; \
_p="$(echo $l | tr '[a-z]' '[A-Z]')_ARCH_PATH"; \
sed -i~ -e '/^[^#]/s@'"${_v}=.*"'@'"${_v}=${_s}"'@' -e '/^[^#]/s@'"${_p}=.*"'@'"${_p}=/usr/local"'@' $f; \
done; \
echo "DONE"; \
done
If you edit the files by hand, you set ..._vesion
variables to ...-system
and ..._ARCH_PATH
variables to /usr/local
(or library location on your system) in each file.
Environment setup:
$ source etc/bashrc
$ [ "$(ulimit -n)" -lt "8192" ] && ulimit -n 8192
$ ./Allwmake > log.Allwmake 2>&1
Depending on your hardware and choosen options this can take from several minutes to several hours.
After compilation you can proceed to testing and making OpenFOAM(R) usage more convenient.
This offering is not approved or endorsed by OpenCFD Limited, producer and distributor of the OpenFOAM software via www.openfoam.com, and owner of the OPENFOAM(R) and OpenCFD(R) trade marks.
OPENFOAM(R) is a registered trade mark of OpenCFD Limited, producer and distributor of the OpenFOAM software via www.openfoam.com.