Note on case-ErgunTestMPI
试图理解一下这个ErgunTestMPI case.
首先,执行 "Allrun.sh"
总的来说就是先判断一下有没有mesh,没有就用blockMesh创建mesh;然后看有没有运行过,运行过就用之前的文件,没有运行过就调用parDEMrun.sh;最后调用parCFDDEMrun.sh 。
#!/bin/bash
####第一行先声明使用的shell
#===================================================================#
# allrun script for testcase as part of test routine
# run ErgunTestMPI
# Christoph Goniva - Sept. 2010
#===================================================================#
#- define variables
casePath="$(dirname "$(readlink -f ${BASH_SOURCE[0]})")"
# check if mesh was built
if [ -f "$casePath/CFD/constant/polyMesh/points" ]; then
echo "mesh was built before - using old mesh"
else
echo "mesh needs to be built"
cd $casePath/CFD
blockMesh
fi
if [ -f "$casePath/DEM/post/restart/liggghts.restart" ]; then
echo "LIGGGHTS init was run before - using existing restart file"
else
#- run DEM in new terminal
$casePath/parDEMrun.sh
fi
###运行 "parDEMrun.sh"
####里面最重要的就是 "parDEMrun" 这个程序
# keep old couplingProperties 备份一下
cp $casePath/CFD/constant/couplingProperties $casePath/CFD/constant/couplingProperties_backup
####这堆都没啥用了
# change to M2M + type B
#changeDictionary -constant -dict changeDicts/changeDictionaryDict_1 -case $casePath/CFD
# change to MPI + type A
#changeDictionary -constant -dict changeDicts/changeDictionaryDict_2 -case $casePath/CFD
# change to MPI + engineIB
#changeDictionary -constant -dict changeDicts/changeDictionaryDict_3 -case $casePath/CFD
# change to MPI + subTS (bigger coupling interval)
#changeDictionary -constant -dict changeDicts/changeDictionaryDict_4 -case $casePath/CFD
# change to MPI + type Bfull
#changeDictionary -constant -dict changeDicts/changeDictionaryDict_5 -case $casePath/CFD
####这儿开始才是有用的
#- run parallel CFD-DEM in new terminal
#gnome-terminal --title='cfdemSolverPiso ErgunTestMPI CFD' -e "bash $casePath/parCFDDEMrun.sh"
. $casePath/parCFDDEMrun.sh
# restore old couplingProperties
mv $casePath/CFD/constant/couplingProperties_backup $casePath/CFD/constant/couplingProperties
然后是parCFDDEMrum.sh
#!/bin/bash
###第一行声明bash
#===================================================================#
# allrun script for testcase as part of test routine
# run settlingTest CFD part
# Christoph Goniva - Feb. 2011
#===================================================================#
#- source CFDEM env vars
. ~/.bashrc
#- include functions
source $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/functions.sh
#--------------------------------------------------------------------------------#
#- define variables 定义变量,没啥好说的
casePath="$(dirname "$(readlink -f ${BASH_SOURCE[0]})")"
logpath=$casePath
headerText="run_parallel_cfdemSolverPiso_ErgunTestMPI_CFDDEM"
logfileName="log_$headerText"
solverName="cfdemSolverPiso"
nrProcs="4"
machineFileName="none" # yourMachinefileName | none
debugMode="off" # on | off| strict | profile
testHarnessPath="$CFDEM_TEST_HARNESS_PATH"
runOctave="true"
postproc="true"
#--------------------------------------------------------------------------------#
#- call function to run a parallel CFD-DEM case 执行parCFDDEMrun,注意整句的语法
parCFDDEMrun $logpath $logfileName $casePath $headerText $solverName $nrProcs $machineFileName $debugMode
###判断是否输出图形,和后面判断是否做后处理一样,在定义变量中定义
if [ $runOctave == "true" ]
then
#------------------------------#
# octave
#- change path
cd octave
#- rmove old graph
rm cfdemSolverPiso_ErgunTestMPI.png
#- run octave 根据totalPressureDrop.m 文件做图,所以图不对就找这个文件
octave totalPressureDrop.m
#- show plot 显示
eog cfdemSolverPiso_ErgunTestMPI.png
#- copy log file to test harness
cp ../../$logfileName $testHarnessPath
cp cfdemSolverPiso_ErgunTestMPI.png $testHarnessPath
fi
###是否做后处理,目前不清楚调用那个python是什么意思,我在里面加了个reconstructPar
if [ $postproc == "true" ]
then
#- keep terminal open (if started in new terminal)
echo "simulation finished? ...press enter to proceed"
read
#- get VTK data from liggghts dump file
echo "start python"
cd $casePath/DEM/post
python -i $CFDEM_LPP_DIR/lpp.py dump*.liggghts_run
#- get VTK data from CFD sim
echo "start foamToVTK"
cd $casePath/CFD
reconstructPar
foamToVTK #- serial run of foamToVTK
#source $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/functions.sh #- include functions
#pseudoParallelRun "foamToVTK" $nrPostProcProcessors #- pseudo parallel run of foamToVTK
#- start paraview
paraview
####判断是否要清理
#- keep terminal open (if started in new terminal)
echo "...press enter to clean up case"
echo "press Ctr+C to keep data"
read
fi
#- clean up case
keepDEMrestart="false"
cleanCFDEMcase $casePath/CFD $keepDEMrestart
#####如果学过Fortran,把这个输入文件想象成Fortran就好理解多了,这种标点符号都舍不得用一个的输入文件,肯定不是C++
echo both
log ../DEM/log.liggghts
thermo_log ../DEM/post/thermo.txt
atom_style granular
###atom 是LIGGGHTS表示颗粒的方式,不同的style 决定不同的颗粒特性。sphere 和granular 都有颗粒直径,质量,角动量和速度 https://www.cfdem.com/media/DEM/docu/atom_style.html
atom_modify map array
###array 方式下,每个processor都储存所有颗粒的信息
communicate single vel yes
###通信,单向,速度
boundary m m m
newton off
units si
region reg block -0.015 0.015 -0.015 0.015 -0.001 0.0554 units box
create_box 1 reg
neighbor 0.001 bin
neigh_modify delay 0
###关于neighbor list建立及重新搜索的设置
# Material properties required for granular pair styles
fix m1 all property/global youngsModulus peratomtype 5.e6
fix m2 all property/global poissonsRatio peratomtype 0.45
fix m3 all property/global coefficientRestitution peratomtypepair 1 0.3
fix m4 all property/global coefficientFriction peratomtypepair 1 0.5
#####"fix ID group-ID style args" "fix id group property/global variablename style stylearg defaultvalue(s)..."
####总的来说fix就是用来定义一些东西,物质特性,壁面,颗粒,颗粒导入等,根据不同的 style,后面的东西不一样,也根据不同的Variablename 后面的东西也不一样。用fix_modify修改,用unfix删除
# pair style
pair_style gran model hertz tangential history # Hertzian without cohesion
pair_coeff * *
####设置计算pairwise作用的方式
###"pair_style style model_type model_name model_keyword model_value"
###"pair_style gran model hertz tangential history "
### style有 gran, bubble, gran_bubble; model_type似乎全是model
### 然后model_name 可以有 hertz, hertz/stiffness, hooke, hooke/stiffness
###这个命令的syntax有点乱七八糟的,比如下面这个expample,我脑子里面不知道他每个的关键字意思的时候,我怎么知道哪个关键字管哪个?这不是给初学增加难度吗!
###"pair_style gran model hertz tangential history rolling_friction cdt"
# timestep, gravity
timestep 0.00001
fix gravi all gravity 9.81 vector 0.0 0.0 -1.0
# walls
fix zwalls1 all wall/gran model hertz tangential history primitive type 1 zplane 0.0
fix zwalls2 all wall/gran model hertz tangential history primitive type 1 zplane 0.0553
fix cylwalls all wall/gran model hertz tangential history primitive type 1 zcylinder 0.01385 0. 0.
###设置壁面,上下两个壁面和圆柱面。wall/gran 用来定义约束颗粒系统模拟的有摩擦力的面,必须选择pair_style 使用的模型吻合的模型。还是那个槽点,既然都要选择一样的了,不选择又有什么关系?
# particle distributions and insertion
region bc cylinder z 0.0 0.0 0.012 0. 0.055 units box
### region 定义空间的几何区域,其他许多命令也需要用到regions,比如create_box( 定义模拟box), "region ID style args keyword arg" https://www.cfdem.com/media/DEM/docu/region.html
###cylinder (圆柱)z (方向) 0.0 0.0 (另外两个方向的坐标) 0.012 (半径)0.0 0.055 (起始位置)如果我定义的是y方向,那么区分剩下的两个坐标哪个是x哪个是z的规则是什么?BTW,这个定义方法似乎说明不能模拟复杂几何啊
fix pts1 all particletemplate/sphere 15485863 atom_type 1 density constant 3000 radius constant 0.0005
fix pdd1 all particledistribution/discrete 15485867 1 pts1 1.0
fix ins all insert/pack seed 32452843 distributiontemplate pdd1 vel constant 0. 0. -1. insert_every once overlapcheck yes all_in yes particles_in_region 10000 region bc
####"particletemplate/sphere" "particledistribution/discrete " "insert/pack " 三个命令基本是联合起来用。首先定义particletemplate, 然后particledistribution, 最后insert,
# apply nve integration to all particles that are inserted as single particles
fix integr all nve/sphere
###每次时间步长对有限颗粒的速度,角动量做NVE积分,使系统轨迹和物理实际符合(This creates a system trajectory consistent with the microcanonical ensemble.)
# screen output
compute rke all erotate/sphere
thermo_style custom step atoms ke c_rke vol
thermo 1000
thermo_modify lost ignore norm no
compute_modify thermo_temp dynamic yes
###compute 计算某个东西
####thermo 更新的时间步长
####thermo_modify 设置某个东西,这儿是lost 和 norm ,然后分别设置ignore (忽略)和 no(不正则化)
# insert the first particles so that dump is not empty
run 1
dump dmp all custom 5000 post/dump.liggghts_init id type x y z ix iy iz vx vy vz fx fy fz omegax omegay omegaz radius
###先运行1个时间步长
### dump 命令可以用几种风格之一的方式(图像除外,用dump image),在每N个时间步长输出颗粒的性质。也可以用dump_modify 来调整输出的时间间隔
run 10000 upto
write_restart post/restart/liggghts.restart
###写一个二进制文件来重启目前的模拟
首先,执行 "Allrun.sh"
总的来说就是先判断一下有没有mesh,没有就用blockMesh创建mesh;然后看有没有运行过,运行过就用之前的文件,没有运行过就调用parDEMrun.sh;最后调用parCFDDEMrun.sh 。
#!/bin/bash
####第一行先声明使用的shell
#===================================================================#
# allrun script for testcase as part of test routine
# run ErgunTestMPI
# Christoph Goniva - Sept. 2010
#===================================================================#
#- define variables
casePath="$(dirname "$(readlink -f ${BASH_SOURCE[0]})")"
# check if mesh was built
if [ -f "$casePath/CFD/constant/polyMesh/points" ]; then
echo "mesh was built before - using old mesh"
else
echo "mesh needs to be built"
cd $casePath/CFD
blockMesh
fi
if [ -f "$casePath/DEM/post/restart/liggghts.restart" ]; then
echo "LIGGGHTS init was run before - using existing restart file"
else
#- run DEM in new terminal
$casePath/parDEMrun.sh
fi
###运行 "parDEMrun.sh"
####里面最重要的就是 "parDEMrun" 这个程序
# keep old couplingProperties 备份一下
cp $casePath/CFD/constant/couplingProperties $casePath/CFD/constant/couplingProperties_backup
####这堆都没啥用了
# change to M2M + type B
#changeDictionary -constant -dict changeDicts/changeDictionaryDict_1 -case $casePath/CFD
# change to MPI + type A
#changeDictionary -constant -dict changeDicts/changeDictionaryDict_2 -case $casePath/CFD
# change to MPI + engineIB
#changeDictionary -constant -dict changeDicts/changeDictionaryDict_3 -case $casePath/CFD
# change to MPI + subTS (bigger coupling interval)
#changeDictionary -constant -dict changeDicts/changeDictionaryDict_4 -case $casePath/CFD
# change to MPI + type Bfull
#changeDictionary -constant -dict changeDicts/changeDictionaryDict_5 -case $casePath/CFD
####这儿开始才是有用的
#- run parallel CFD-DEM in new terminal
#gnome-terminal --title='cfdemSolverPiso ErgunTestMPI CFD' -e "bash $casePath/parCFDDEMrun.sh"
. $casePath/parCFDDEMrun.sh
# restore old couplingProperties
mv $casePath/CFD/constant/couplingProperties_backup $casePath/CFD/constant/couplingProperties
然后是parCFDDEMrum.sh
#!/bin/bash
###第一行声明bash
#===================================================================#
# allrun script for testcase as part of test routine
# run settlingTest CFD part
# Christoph Goniva - Feb. 2011
#===================================================================#
#- source CFDEM env vars
. ~/.bashrc
#- include functions
source $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/functions.sh
#--------------------------------------------------------------------------------#
#- define variables 定义变量,没啥好说的
casePath="$(dirname "$(readlink -f ${BASH_SOURCE[0]})")"
logpath=$casePath
headerText="run_parallel_cfdemSolverPiso_ErgunTestMPI_CFDDEM"
logfileName="log_$headerText"
solverName="cfdemSolverPiso"
nrProcs="4"
machineFileName="none" # yourMachinefileName | none
debugMode="off" # on | off| strict | profile
testHarnessPath="$CFDEM_TEST_HARNESS_PATH"
runOctave="true"
postproc="true"
#--------------------------------------------------------------------------------#
#- call function to run a parallel CFD-DEM case 执行parCFDDEMrun,注意整句的语法
parCFDDEMrun $logpath $logfileName $casePath $headerText $solverName $nrProcs $machineFileName $debugMode
###判断是否输出图形,和后面判断是否做后处理一样,在定义变量中定义
if [ $runOctave == "true" ]
then
#------------------------------#
# octave
#- change path
cd octave
#- rmove old graph
rm cfdemSolverPiso_ErgunTestMPI.png
#- run octave 根据totalPressureDrop.m 文件做图,所以图不对就找这个文件
octave totalPressureDrop.m
#- show plot 显示
eog cfdemSolverPiso_ErgunTestMPI.png
#- copy log file to test harness
cp ../../$logfileName $testHarnessPath
cp cfdemSolverPiso_ErgunTestMPI.png $testHarnessPath
fi
###是否做后处理,目前不清楚调用那个python是什么意思,我在里面加了个reconstructPar
if [ $postproc == "true" ]
then
#- keep terminal open (if started in new terminal)
echo "simulation finished? ...press enter to proceed"
read
#- get VTK data from liggghts dump file
echo "start python"
cd $casePath/DEM/post
python -i $CFDEM_LPP_DIR/lpp.py dump*.liggghts_run
#- get VTK data from CFD sim
echo "start foamToVTK"
cd $casePath/CFD
reconstructPar
foamToVTK #- serial run of foamToVTK
#source $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/functions.sh #- include functions
#pseudoParallelRun "foamToVTK" $nrPostProcProcessors #- pseudo parallel run of foamToVTK
#- start paraview
paraview
####判断是否要清理
#- keep terminal open (if started in new terminal)
echo "...press enter to clean up case"
echo "press Ctr+C to keep data"
read
fi
#- clean up case
keepDEMrestart="false"
cleanCFDEMcase $casePath/CFD $keepDEMrestart
file in.liggghts_init
#####如果学过Fortran,把这个输入文件想象成Fortran就好理解多了,这种标点符号都舍不得用一个的输入文件,肯定不是C++
echo both
log ../DEM/log.liggghts
thermo_log ../DEM/post/thermo.txt
atom_style granular
###atom 是LIGGGHTS表示颗粒的方式,不同的style 决定不同的颗粒特性。sphere 和granular 都有颗粒直径,质量,角动量和速度 https://www.cfdem.com/media/DEM/docu/atom_style.html
atom_modify map array
###array 方式下,每个processor都储存所有颗粒的信息
communicate single vel yes
###通信,单向,速度
boundary m m m
newton off
units si
region reg block -0.015 0.015 -0.015 0.015 -0.001 0.0554 units box
create_box 1 reg
neighbor 0.001 bin
neigh_modify delay 0
###关于neighbor list建立及重新搜索的设置
# Material properties required for granular pair styles
fix m1 all property/global youngsModulus peratomtype 5.e6
fix m2 all property/global poissonsRatio peratomtype 0.45
fix m3 all property/global coefficientRestitution peratomtypepair 1 0.3
fix m4 all property/global coefficientFriction peratomtypepair 1 0.5
#####"fix ID group-ID style args" "fix id group property/global variablename style stylearg defaultvalue(s)..."
####总的来说fix就是用来定义一些东西,物质特性,壁面,颗粒,颗粒导入等,根据不同的 style,后面的东西不一样,也根据不同的Variablename 后面的东西也不一样。用fix_modify修改,用unfix删除
# pair style
pair_style gran model hertz tangential history # Hertzian without cohesion
pair_coeff * *
####设置计算pairwise作用的方式
###"pair_style style model_type model_name model_keyword model_value"
###"pair_style gran model hertz tangential history "
### style有 gran, bubble, gran_bubble; model_type似乎全是model
### 然后model_name 可以有 hertz, hertz/stiffness, hooke, hooke/stiffness
###这个命令的syntax有点乱七八糟的,比如下面这个expample,我脑子里面不知道他每个的关键字意思的时候,我怎么知道哪个关键字管哪个?这不是给初学增加难度吗!
###"pair_style gran model hertz tangential history rolling_friction cdt"
# timestep, gravity
timestep 0.00001
fix gravi all gravity 9.81 vector 0.0 0.0 -1.0
# walls
fix zwalls1 all wall/gran model hertz tangential history primitive type 1 zplane 0.0
fix zwalls2 all wall/gran model hertz tangential history primitive type 1 zplane 0.0553
fix cylwalls all wall/gran model hertz tangential history primitive type 1 zcylinder 0.01385 0. 0.
###设置壁面,上下两个壁面和圆柱面。wall/gran 用来定义约束颗粒系统模拟的有摩擦力的面,必须选择pair_style 使用的模型吻合的模型。还是那个槽点,既然都要选择一样的了,不选择又有什么关系?
# particle distributions and insertion
region bc cylinder z 0.0 0.0 0.012 0. 0.055 units box
### region 定义空间的几何区域,其他许多命令也需要用到regions,比如create_box( 定义模拟box), "region ID style args keyword arg" https://www.cfdem.com/media/DEM/docu/region.html
###cylinder (圆柱)z (方向) 0.0 0.0 (另外两个方向的坐标) 0.012 (半径)0.0 0.055 (起始位置)如果我定义的是y方向,那么区分剩下的两个坐标哪个是x哪个是z的规则是什么?BTW,这个定义方法似乎说明不能模拟复杂几何啊
fix pts1 all particletemplate/sphere 15485863 atom_type 1 density constant 3000 radius constant 0.0005
fix pdd1 all particledistribution/discrete 15485867 1 pts1 1.0
fix ins all insert/pack seed 32452843 distributiontemplate pdd1 vel constant 0. 0. -1. insert_every once overlapcheck yes all_in yes particles_in_region 10000 region bc
####"particletemplate/sphere" "particledistribution/discrete " "insert/pack " 三个命令基本是联合起来用。首先定义particletemplate, 然后particledistribution, 最后insert,
# apply nve integration to all particles that are inserted as single particles
fix integr all nve/sphere
###每次时间步长对有限颗粒的速度,角动量做NVE积分,使系统轨迹和物理实际符合(This creates a system trajectory consistent with the microcanonical ensemble.)
# screen output
compute rke all erotate/sphere
thermo_style custom step atoms ke c_rke vol
thermo 1000
thermo_modify lost ignore norm no
compute_modify thermo_temp dynamic yes
###compute 计算某个东西
####thermo 更新的时间步长
####thermo_modify 设置某个东西,这儿是lost 和 norm ,然后分别设置ignore (忽略)和 no(不正则化)
# insert the first particles so that dump is not empty
run 1
dump dmp all custom 5000 post/dump.liggghts_init id type x y z ix iy iz vx vy vz fx fy fz omegax omegay omegaz radius
###先运行1个时间步长
### dump 命令可以用几种风格之一的方式(图像除外,用dump image),在每N个时间步长输出颗粒的性质。也可以用dump_modify 来调整输出的时间间隔
run 10000 upto
write_restart post/restart/liggghts.restart
###写一个二进制文件来重启目前的模拟
评论
发表评论