C/C++教程

OpenFoam在Centos7.5下编译全过程(Openmpi)

本文主要是介绍OpenFoam在Centos7.5下编译全过程(Openmpi),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
  1. 安装必要的依赖包

$sudo yum groupinstall -y 'Development Tools'

$sudo yum install zlib-devel libXext-devel libGLU-devel libXt-devel libXrender-devel libXinerama-devel libpng-devel libXrandr-devel libXi-devel libXft-devel libjpeg-turbo-devel libXcursor-devel readline-devel ncurses-devel python python-devel cmake qt-devel qt-assistant mpfr-devel gmp gmp-devel

  1. 下载OpenFOAM安装包

$cd ~

$mkdir OpenFOAM

$cd OpenFOAM

$git clone https://github.com/OpenFOAM/OpenFOAM-5.x.git

$git clone https://github.com/OpenFOAM/ThirdParty-5.x.git

  1. 编译安装OpenFOAM第三方包

$cd ThirdParty-5.x

  1. 下载第三方包必要的源代码包

$mkdir download

$wget -P download https://www.cmake.org/files/v3.9/cmake-3.9.0.tar.gz

$wget -P download \

https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-4.10/CGAL-4.10.tar.xz

$wget -P download https://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.bz2

$wget -P download https://www.open-mpi.org/software/ompi/v2.1/downloads/openmpi-2.1.1.tar.bz2

$wget -P download http://www.paraview.org/files/v5.4/ParaView-v5.4.0.tar.gz

  1. 解压下载的源码包

$tar -xzf download/cmake-3.9.0.tar.gz

$tar -xJf download/CGAL-4.10.tar.xz

$tar -xjf download/boost_1_55_0.tar.bz2

$tar -xjf download/openmpi-2.1.1.tar.bz2

$tar -xzf download/ParaView-v5.4.0.tar.gz --transform='s/ParaView-v5.4.0/ParaView-5.4.0/'

  1. 更改默认的Boost和CGAL版本

$cd ..

$sed -i -e 's/\(boost_version=\)boost-system/\1boost_1_55_0/' OpenFOAM-5.x/etc/config.sh/CGAL

$sed -i -e 's/\(cgal_version=\)cgal-system/\1CGAL-4.10/' OpenFOAM-5.x/etc/config.sh/CGAL

  1. 配置临时环境变量

$source $HOME/OpenFOAM/OpenFOAM-5.x/etc/bashrc WM_LABEL_SIZE=64 WM_MPLIB=OPENMPI FOAMY_HEX_MESH=yes

  1. 构建CMake

CentOS 7.5附带CMake 2.8.,但ParaView 5.4.0需要最近的CMake 3.x系列中的一个版本,而CGAL也需要CMake。因此,我们需要自定义构建Cmake

$cd $WM_THIRD_PARTY_DIR

$./makeCmake > log.makeCmake 2>&1

$wmRefresh

  1. 编译ThirdParty包

$cd $WM_THIRD_PARTY_DIR

$./Allwmake > log.make 2>&1

$wmRefresh

  1. 编译ParaView

$cd $WM_THIRD_PARTY_DIR

$./makeParaView -mpi -python -qmake $(which qmake-qt4) > log.makePV 2>&1

$wmRefresh

  1. 编译OpenFOAM

$cd $WM_PROJECT_DIR

$./Allwmake -j > log.make 2>&1

$icoFoam -help

  1. 配置环境变量

$vim ~/.bashrc

#### OPENMPI #####

export PATH=$PATH:~/OpenFOAM/ThirdParty-5.x/platforms/linux64Gcc/openmpi-2.1.1/bin

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/OpenFOAM/ThirdParty-5.x/platforms/ linux64Gcc /openmpi-2.1.1/lib

#### PARAVIEW #####

export PATH=$PATH:~/OpenFOAM/ThirdParty-5.x/platforms/linux64Gcc/ParaView-5.4.0/bin

#### OpenFOAM #####

source ~/OpenFOAM/OpenFOAM-5.x/etc/bashrc

$source ~/.bashrc

这篇关于OpenFoam在Centos7.5下编译全过程(Openmpi)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!