算例路径: OpenFOAM-8\tutorials\multiphase\interFoam\laminar\wave
算例描述: 使用 interFoam 求解器的造波功能
学习目标: extrudeMesh 网格操作;了解 setWaves 功能;理解 interFoam 求解器造波。
学习体会:
若希望通过 interFoam 求解器模拟波浪运动,最好使用 com 版本的 OpenFOAM,它提供了充足的波浪类型和 tutorial 示例;org 版本(OpenFOAM-8)的波浪模拟功能尚比较局限。
算例快照:
文件结构:
.
├── 0
│ ├── U.orig
│ ├── alpha.water.orig
│ └── p_rgh
├── Allrun
├── constant
│ ├── fvOptions
│ ├── fvOptions.verticalDamping
│ ├── g
│ ├── momentumTransport
│ ├── transportProperties
│ └── waveProperties
└── system
├── blockMeshDict
├── controlDict
├── decomposeParDict
├── extrudeMeshDict
├── fvSchemes
├── fvSolution
├── refineMeshDictX
├── refineMeshDictY
├── setWavesDict
├── topoSetDict1
├── topoSetDict2
├── topoSetDict3
├── topoSetDict4
├── topoSetDict5
└── topoSetDict6
算例文件解析:
【Allrun】
#!/bin/sh
cd ${0%/*} || exit 1 # 转到当前目录,若发生异常则退出命令
. $WM_PROJECT_DIR/bin/tools/RunFunctions # “.” 即 “source”,将设置在文件中的配置信息马上生效,而不需要经过重启
# 以OpenFOAM-v8为例,包含isTest()、getNumberOfProcessors()、getApplication()、runApplication()、runParallel()、compileApplication()和cloneMesh()的配置信息
runApplication blockMesh
runApplication extrudeMesh
for i in 1 2
do
runApplication -s $i topoSet -dict system/topoSetDict$i
runApplication -s $i refineMesh -dict system/refineMeshDictX -overwrite
done
for i in 3 4 5 6
do
runApplication -s $i topoSet -dict system/topoSetDict$i
runApplication -s $i refineMesh -dict system/refineMeshDictY -overwrite
done
runApplication setWaves
# Applies wave models to the entire domain for case initialisation using level sets for second-order accuracy.
runApplication decomposePar
runParallel $(getApplication)
runApplication reconstructPar
【system\extrudeMeshDict】
更多参数含义可查看 etc\caseDicts\annotated\extrudeMeshDict
constructFrom mesh; //可选参数有 patch、mesh 和 surface。
sourceCase "."; // 当前算例路径
sourcePatches (right); // 以 right 为网格拓展源
flipNormals false;
nLayers 25; // 拓展的网格层数为25
expansionRatio 1.09; // 网格膨胀率为1.09
extrudeModel linearNormal; // 线性法向
linearNormalCoeffs
{
thickness 1500; // 扩展网格厚度
}
mergeFaces false; // 前后面是否合并,仅对360度的楔形扩展有意义
【system\topoSetDict1】
topoSetDict2-6 类似
actions
(
{
name box; //自定义域名称
type cellSet; //单元集
action new; //生成一个新cellSet
source boxToCell; //通过boxToCell的方式选定单元
sourceInfo
{
box (-1e6 -40 -1e6) (1300 40 1e6);
}
}
);
【system\refineMeshDictX or refineMeshDictY】
set box; // topoSet中定义的域名称
coordinateSystem global;
globalCoeffs
{
tan1 (1 0 0); // X方向
tan2 (0 1 0); // Y方向
}
directions //选定总体加密或者局部加密的方向
(
tan1 // tan1 方向加密一次
// tan2 // tan2 方向加密一次
// normal // normal 方向加密一次
);
useHexTopology true; //是否只用六面体加密
geometricCut false; //是否进行几何切割
writeMesh false; //是否写入网格
【constant\waveProperties】
origin (0 0 0);
direction (1 0 0);
waves
(
Airy // 以OpenFOAM-v8为例,可选波浪类型有4种:Airy Stokes2 Stokes5 solitary
{
length 300; // 波长
amplitude 2.5; // 振幅 H/2
phase 0; // 初始相位
angle 0; // 入射角度
}
);
UMean (2 0 0); // 流速
scale table ((1200 1) (1800 0));
crossScale constant 1;
【constant\fvOptions】
// 这个fvOption对矢量场的所有分量施加一个隐式阻尼力,以将场松弛到指定的均匀值。
// 目的是在接近出口的区域中抑制界面的运动,以消除反射。
// 参数含义及计算方法详见:
// src\fvOptions\sources\derived\damping\damping\damping.H
// src\fvOptions\sources\derived\damping\isotropicDamping\isotropicDamping.H
option1
{
type isotropicDamping;
selectionMode all; //
origin (1200 0 0); // 定义应用范围
direction (1 0 0);
scale
{
type halfCosineRamp; // 阻尼方法
start 0;
duration 600;
}
value (2 0 0); // Value towards which the field it relaxed
lambda 0.5; // 阻尼系数,计算方法见 isotropicDamping.H
timeStart 0;
duration 1e6;
}
【constant\fvOptions.verticalDamping】
// 这个fvOption在重力方向上对矢量场的分量施加显式阻尼力。
// 它的目的是在接近出口的区域中抑制界面的垂直运动,以消除反射。
// 通过对动量方程施加一个阻尼力来实现,这个力与流体在重力方向上的动量成正比。
// 比例常数由系数给出,单位是 s-1。
// 在没有任何其他力的情况下,将产生垂直速度的指数衰减。
// src\fvOptions\sources\derived\damping\verticalDamping\verticalDamping.H
option1
{
type verticalDamping;
selectionMode all;
origin (1200 0 0);
direction (1 0 0);
scale
{
type halfCosineRamp; //Half-cosine ramp function starting from 0 and increasing to 1 from \c start over the \c duration and remaining at 1 thereafter.
// src\OpenFOAM\primitives\functions\Function1\halfCosineRamp\halfCosineRamp.H
start 0;
duration 600;
}
lambda 0.5;
timeStart 0;
duration 1e6;
}
【system\controlDict】
application interFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 200;
deltaT 0.05;
writeControl adjustableRunTime;
writeInterval 1;
purgeWrite 0;
writeFormat binary;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
adjustTimeStep no;
maxCo 1;
maxAlphaCo 1;
maxDeltaT 1;
libs // 调用库
(
"libwaves.so"
);
functions
{
interfaceHeight1
{
type interfaceHeight;
libs ("libfieldFunctionObjects.so");
locations ((300 0 0) (450 0 0) (600 0 0));
alpha alpha.water;
}
}
【0\U.org】
dimensions [0 1 -1 0 0 0 0];
internalField uniform (2 0 0);
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
left
{
type waveVelocity;
}
right
{
type outletPhaseMeanVelocity;
// 该边界条件调整给定相的速度以达到指定的平均值,从而使相分数根据质量流量进行调整。
// 典型应用是作为拖船模拟的出口条件,使出口水位保持在进口水平。
// 参考 https://www.openfoam.com/documentation/guides/latest/api/classFoam_1_1outletPhaseMeanVelocityFvPatchVectorField.html#details
UnMean 2; // 垂直于边界的平均速度[m/s]
alpha alpha.water; // 相分数场
}
top
{
type pressureInletOutletVelocity;
value uniform (0 0 0);
}
bottom
{
type noSlip;
}
}
【0\alpha.water.org】
dimensions [0 0 0 0 0 0 0];
internalField uniform 0;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
"(right|bottom)"
{
type zeroGradient;
}
left
{
type waveAlpha;
U U;
inletOutlet true;
}
top
{
type inletOutlet;
inletValue uniform 0;
value uniform 0;
}
}