分享CFDEM+OpenFOAM+LIGGGHTS初次编译安装过程
-
详细记录CFDEM+OpenFOAM+LIGGGHTS初次编译安装过程
时间:
2021/5/31
计算机平台:
普通AMD/Intel x64台式机
软件:
-
VMware虚拟机版本:16 Pro
-
Ubuntu版本:20.04(focal)
-
OpenFoam:5.x
-
ParaView:5.4.0
-
LIGGGHTS: 3.8.0
-
QT:qt4
1. 更换下载源
sudo gedit /etc/apt/sources.list
打开文本,并用下面内容替换(对应ubuntu20.04–focal,若为其他版本ubuntu,修改focal为其它名称,如18.04→bionic,16.04→xenial,14.04→trusty)
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
2. 安装编译所需其它文件
sudo apt update sudo apt-get install -y build-essential flex bison git cmake zlib1g-dev libboost-system-dev libboost-thread-dev libopenmpi-dev openmpi-bin gnuplot libreadline-dev libncurses-dev libxt-dev libscotch-dev libptscotch-dev libvtk6-dev python-numpy ffmpeg octave curl
确保安装无异常。若出现
could not get lock /var/...
类似的错误,重新启动客户端一次,并重复该步骤,直到运行到如下图状态——0 upgraded, 0 newly installed, 0 to remove
。sudo
可让用户以其他的身份来执行指定的指令,apt-get
后的命令参数有install 安装、 update 更新、 remove 移除 、check 检查、clean清除缓存。-y
表示跳过确认步骤,直接安装。&&
命令表示顺序执行由它连接的命令,但是只有它之前的命令成功执行完成了之后才可以继续执行它后面的命令。3. 下载CFDEM、LIGGGHTS和OpenFOAM-5.x源文件,并建立对应文件夹
cd $HOME && mkdir -p OpenFOAM && cd OpenFOAM && git clone git://github.com/OpenFOAM/OpenFOAM-5.x.git && git clone git://github.com/OpenFOAM/ThirdParty-5.x.git && cd $HOME && mkdir -p CFDEM && cd CFDEM && git clone git://github.com/CFDEMproject/CFDEMcoupling-PUBLIC.git && cd $HOME && mkdir -p LIGGGHTS && cd LIGGGHTS && git clone git://github.com/CFDEMproject/LIGGGHTS-PUBLIC.git && git clone git://github.com/CFDEMproject/LPP.git lpp
4. 下载完整编译版qt4和qtcreator
sudo add-apt-repository ppa:rock-core/qt4 && sudo apt update && sudo apt-get install qt4* && sudo apt-get install qtcreator
5. 配置OpenFOAM环境变量及路径
-
直接在Terminal输入
sed -i '$a export WM_NCOMPPROCS=12' $HOME/.bashrc sed -i '$a source $HOME/OpenFOAM/OpenFOAM-5.x/etc/bashrc' $HOME/.bashrc source ~/.bashrc
sed
是一个以行为单位文件处理工具,可以将数据行进行替换、删除、新增、选取等特定工作。sed -i '$a bye' ab
→ 在文件ab中最后一行直接输入"bye"sed '1,2c Hi' ab
→ 第一行到第二行代替为Hi(
-i
:直接修改读取的档案内容,而不是由荧幕输出)-
或者:
-
在Terminal输入
gedit ~/.bashrc
-
打开.bashrc文件,在.bashrc文件最后添加下列代码
export WM_NCOMPPROCS=12 source $HOME/OpenFOAM/OpenFOAM-5.x/etc/bashrc
-
之后再在Terminal中输入
source ~/.bashrc
-
6. 编译OpenFOAM
cd $HOME/OpenFOAM/OpenFOAM-5.x &&./Allwmake -j
-j 表示可以启用并行编译指令
7. 编译paraFoam(paraView)
cd $HOME/OpenFOAM/ThirdParty-5.x && export QT_SELECT=qt4 sudo apt install libqt5x11extras5-dev libxt-dev qt5-default qttools5-dev curl && ./makeParaView
会出现安装paraView5.4.0的bug,如下图
解决方法:
——在文件夹:
OpenFOAM/ThirdParty-5.x/ParaView-5.4.0/Plugins/StreamLinesRepresentation
下手动创建doc
文件夹,并重新运行./makeParaView
。 之后,
wmRefresh && cd $FOAM_UTILITIES/postProcessing/graphics/PVReaders && ./Allwclean && ./Allwmake
7. 配置CFDEM环境变量和路径
cd $HOME/CFDEM mv CFDEMcoupling-PUBLIC CFDEMcoupling-PUBLIC-$WM_PROJECT_VERSION gedit ~/.bashrc
在.bashrc文件最后添加下列代码
#================================================# #- source cfdem env vars export CFDEM_VERSION=PUBLIC export CFDEM_PROJECT_DIR=$HOME/CFDEM/CFDEMcoupling-$CFDEM_VERSION-$WM_PROJECT_VERSI ON export CFDEM_PROJECT_USER_DIR=$HOME/CFDEM/$LOGNAME-$CFDEM_VERSION-$WM_PROJECT_VERSI ON export CFDEM_bashrc=$CFDEM_PROJECT_DIR/src/lagrangian/cfdemParticle/etc/bashrc export CFDEM_LIGGGHTS_SRC_DIR=$HOME/LIGGGHTS/LIGGGHTS-PUBLIC/src export CFDEM_LIGGGHTS_MAKEFILE_NAME=auto export CFDEM_LPP_DIR=$HOME/LIGGGHTS/lpp/src . $CFDEM_bashrc #================================================#
之后,
source ~/.bashrc
8.编译CFDEM(同时编译了LIGGGHTS)
cfdemCompCFDEMall
安装完成。
9.建立软连接
建立LIGGGHTS的软连接(相当于快捷方式,输入
liggghts
即可单独启动LIGGGHTS运算程序lmp_auto
)sudo ln -s $HOME/LIGGGHTS/LIGGGHTS-PUBLIC/src/lmp_auto /usr/bin/liggghts
10.案例运行
将OpenFOAM、LIGGGHTS、CFDEM中的tutorials文件夹拷贝到自定义的文件夹中
mkdir -p $HOME/JOBS/OF_JOB/tutorials && mkdir -p $HOME/JOBS/LG_JOB/tutorials && mkdir -p $HOME/JOBS/CFDEM_JOB/tutorials && cp -r $FOAM_TUTORIALS $HOME/JOBS/OF_JOB && cp -r $HOME/LIGGGHTS/LIGGGHTS-PUBLIC/examples/LIGGGHTS/Tutorials_public $HOME/JOBS/LG_JOB/tutorials && cp -r $HOME/LIGGGHTS/LIGGGHTS-PUBLIC/examples/LIGGGHTS/SPH $HOME/JOBS/LG_JOB/tutorials &&cp -r $HOME/CFDEM/CFDEMcoupling-PUBLIC-5.x/tutorials $HOME/JOBS/CFDEM_JOB
-
单独运行OpenFOAM
cd $HOME/JOBS/OF_JOB/tutorials/incompressible/icoFoam/cavity/cavity blockMeshicoFoamparaFoam
-
单独运行LIGGGHTS
cd ~/JOBS/LG_JOB/tutorials/Tutorials_public/chute_wearliggghts -in in.chute_wearparaview
-
运行CFDEM
cd ~/JOBS/CFDEM_JOB/tutorials/cfdemPostproc/fillCylinder./Allrun.sh
运行错误,修改案例的Allrun.sh文件81行为
$HOME/OpenFOAM/ThirdParty-5.x/build/linux64Gcc/ParaView-5.4.0/bin/paraview
重新运行
./Allrun.sh
,获得结果
-
-
-
-
您好,安装编译所需文件时报错:Package libvtk6-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another sourceE: Package 'libvtk6-dev' has no installation candidate
E: Unable to locate package python-numpy
怎么解决呢 -
-
@lixin19981013 您好,我按照您的回复将“libvtk6-dev”修改成“libvtk9-dev”,但仍出现以下报错:
E: 无法定位软件包 python-numpy
请问是什么原因呢