OpenFOAM中设置多孔介质
通过在流体中的特定区域添加阻力源项,模拟流体流过多孔介质后的动量损失
其源项由DarcyForchheimer定律得到
S
i
=
−
(
μ
d
+
ρ
∣
U
∣
2
f
)
U
i
S_{i}=-\left(\mu d+\frac{\rho|U|}{2} f\right) U_{i}
Si=−(μd+2ρ∣U∣f)Ui式中
i
i
i取
x
,
y
,
z
x,y,z
x,y,z方向,第一项类似于附加粘性,第二项类似于气动阻力
OpenFOAM v9中可以通过添加system/topoSetDict
和constant/fvModels
这两个字典实现多孔介质区域的设置
system/topoSetDict
文件
使用圆柱来划分一个区域,命名该区域的名称为porosz
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions
(
{
name poros; // 区域命名为poros
type cellSet;
action new;
source cylinderToCell; // 圆柱区域
sourceInfo
{
p1 (0.438 0.048 0); // 圆柱体上表面的中心点
p2 (0.438 0 0); // 圆柱体下表面的中心点
radius 0.017; // 圆柱半径
}
}
{
name porosz; // 区域命名
type cellZoneSet;
action new;
source setToCellZone; // 将圆柱区域转换为网格区域
sourceInfo
{
set poros; // 给定source信息
}
}
);
// ************************************************************************* //
constant/fvModels
文件
fvModels类是v9版本新增加的内容,用于替换原本的fvOptions类
fvModels文件用于指定porosz
区域为explicitPorositySource
类型,即多孔介质
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "constant";
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
poros
{
type explicitPorositySource; // 类型
explicitPorositySourceCoeffs
{
selectionMode cellZone;
cellZone porosz; // 已经产生的网格区域
type DarcyForchheimer; // 达西定律
D 1e15; // 非常大的粘性阻力
d ($D $D $D); // 各向同性
f (0 0 0);
coordinateSystem // 旋转坐标系的设定
{
type cartesian; // 笛卡尔坐标系
origin (0 0 0);
coordinateRotation
{
type axesRotation; // 此算例设定无旋转,e1, e2, e3分别为x, y, z轴
e1 (1 0 0);
e2 (0 1 0);
e3 (0 0 1);
}
}
}
}
案例结果
找到湍流VOF两项流的溃坝案例(/opt/openfoam9/tutorials/multiphase/interFoam/RAS/damBreak
),以该案例为基础,使用topoSet
命令在指定区域加入多孔介质(下图中紫色区域为多孔介质)
然后使用system/setFieldsDict
文件和setFields
命令设置初始水的位置
为了使用多核计算,使用
decomposePar -force
将网格分配给不同处理器,使用mpirun -np 8 interFoam -parallel | tee log
命令开始计算,计算完成后使用reconstructPar
命令将不同处理的结果汇总到项目根目录,最后使用paraFoam
命令打开paraView实现后处理。
这里推荐一个制作gif动态图的网站https://www.matools.com/gif
计算结果如下
可以看出由于多孔介质的阻力非常之大,以致于水是不能进入其中的。多孔介质区始终保留了最初储存的空气。所以使用多孔介质是可以模拟固体的。