centos编译openfoam

先安装openmpi安装
yum install libxml2-devel libxslt-devel gsl -y
yum install openssl -y
yum install openssl-devel -y

mkdir /opt/openmpi

cd /opt/openmpi

wget https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.4.tar.gz

tar -xvf openmpi-4.0.4.tar.gz

cd openmpi-4.0.0

./configure --prefix=/opt/openmpi

make -j && make install

加入环境变量

export PATH=/opt/openmpi/bin:$PATH

export LD_LIBRARY_PATH=/opt/openmpi/lib:$LD_LIBRARY_PATH

接下来编译openfoam,编译最新openfoam8

mkdir /opt/openfoam

cd /opt/openfoam

wget -O - http://dl.openfoam.org/source/8 | tar xvz

wget -O - http://dl.openfoam.org/third-party/8 | tar xvz

mv OpenFOAM-8-version-8 OpenFOAM-8

mv ThirdParty-8-version-8 ThirdParty-8

cd /opt/openfoam/OpenFOAM-8

source /opt/openfoam/OpenFOAM-8/etc/bashrc

这步同步成功无报错就可以下一步
以下16是设置核数
export WM_NCOMPPROCS= ##指定使用服务器用来编译的核数
export WM_NCOMPPROCS=16
export WM_COLOURS=“black blue green cyan red magenta yellow”

./Allwmake -j

编译时间较长
如source同步出错,请按照下列操作临时升级gcc 此处为7.3版本

yum -y install centos-release-scl

yum -y install devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils

scl enable devtoolset-7 bash

需要注意的是scl命令启用只是临时的,退出shell或重启就会恢复原系统gcc版本。
如果要长期使用gcc 7.3的话:
echo “source /opt/rh/devtoolset-7/enable” >>/etc/profile
如编译时出错安装编译zlib库

cd /opt/ openfoam/

wget http://www.zlib.net/zlib-1.2.11.tar.gz

tar zxvf zlib-1.2.11.tar.gz

cd zlib-1.2.11

./configure

make test

make install

构建共享库

make clean

./configure --shared

make test
make install
cp zutil.h /usr/local/include
cp zutil.c /usr/local/include
将zlib库安装成后继续编译
编译完成后测试输出,出现以下的输出的,编译成功

blockMesh

of7


centos编译openfoam
https://c3.pw/post/d676d71e/
发布于
2022年9月19日
许可协议