关注九天学者
微信公众号(扫码关注)第一时间获取技术贴更新!
OpenFOAM官方推荐的首选系统是ubuntu,在ubuntu下安装OpenFOAM巨简单。可是MAC系统下,官方推荐是通过Docker虚拟ubuntu系统进行,但是这有几个弊端:虚拟机下运行效率低;访问不方便;数据共享很麻烦。找了很久终于找到了在Mac下安装的方法——源码安装。
教程
完全按照OpenFOAM(R) on OS X不找安装就没问题。
但是在安装scotch
和brew install parmetis
总是失败,突然想到我电脑上之前安装了dealii。dealii的安装目录下有自己的brew程序,而且已经将一些主要的库打包在了brew的安装目录下面。所以所有的这些安装都启用dealii的brew(而不是系统的brew)安装即可。
brew所在路径:/Applications/deal.II-8.5-brew.app/Contents/Resources/brew/bin/brew
注:之前安装完dealii发现系统自动将brew定向到dealii的brew,为了使dealii安装之前的程序有效,我将dealii的brew改名为brew2来阻止他的调用,因为dealii的brew安装的软件全都在装到了/Applications/deal.II-8.5-brew.app/Contents/Resources/brew
目录下面。现在为了安装OpenFOAM决定由改回来,以后也不会变,就让他装在dealii目录下面好了。
安装步骤
brew tap homebrew/science
brew install open-mpi --without-fortran
brew install scotch
brew install boost --without-single --with-mpi
brew install cgal
brew install metis
brew install parmetis
brew install https://raw.githubusercontent.com/mrklein/openfoam-os-x/master/formulae/parmgridgen.rb
cd $HOME
curl -L http://download.openfoam.org/source/<V-E-R> > OpenFOAM-<V.E.R>.tgz
hdiutil create -size 8.3g -type SPARSEBUNDLE -fs HFSX -volname OpenFOAM -fsargs -s OpenFOAM.sparsebundle
mkdir -p OpenFOAM
hdiutil attach -mountpoint $HOME/OpenFOAM OpenFOAM.sparsebundle
cd OpenFOAM
tar xzf $HOME/OpenFOAM-<V.E.R>.tgz
[ -d OpenFOAM-4.x-version-4.0 ] && mv OpenFOAM-4.x-version-4.0 OpenFOAM-4.0 # if you are installing version 4.0
cd OpenFOAM-<V.E.R>
curl -L https://raw.githubusercontent.com/mrklein/openfoam-os-x/master/OpenFOAM-<V.E.R>.patch > OpenFOAM-<V.E.R>.patch
git apply OpenFOAM-<V.E.R>.patch
mkdir -p $HOME/.OpenFOAM
echo 'WM_COMPILER=Clang' > $HOME/.OpenFOAM/prefs.sh
echo 'WM_COMPILE_OPTION=Opt' >> $HOME/.OpenFOAM/prefs.sh
echo 'WM_MPLIB=SYSTEMOPENMPI' >> $HOME/.OpenFOAM/prefs.sh
echo 'export WM_QUIET_RULES=Y' >> $HOME/.OpenFOAM/prefs.sh
echo 'export WM_NCOMPPROCS=$(sysctl -n hw.ncpu)' >> $HOME/.OpenFOAM/prefs.sh
source etc/bashrc
[ "$(ulimit -n)" -lt "4096" ] && ulimit -n 4096
./Allwmake > log.Allwmake 2>&1
关注九天学者
微信公众号(扫码关注)第一时间获取技术贴更新!