本文介绍OpenFOAM随机算例中potentialFoam求解器下的算例cylinder。
算例路径:$FOAM_TUTORIALS/basic/potentialFoam/cylinder
”
算例文件结构如下图所示。
本算例计算的是二维问题,不过在OpenFOAM中需要创建三维几何模型。
potentialFoam求解计算的是无粘瞬态流动问题,因此算例中无需提供介质属性参数。几何模型中包含一个速度入口(如下图中的边界left),速度沿x轴正方向1 m/s,包含一个静压为0的出口(图中边界right),另外包含的边界为up(symmetryPlane边界)、down(symmetryPlane边界)、cylinder(symmetry边界),另外没有标明的边界为empty。
注:symmetryPlane边界与symmetry边界存在区别,前者要求必须为平面,后者仅具有物理意义(类似与slip壁面,法向速度为零,物理量的法向梯度为零),并不严格要求对称面为平面。
”
本算例采用blockMesh生成计算网格。通过将几何模型分解为下图所示的区域,划分全六面体网格。
在blockMeshDict文件中指定网格分块情况。
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices #codeStream
{
codeInclude
#{
#include "pointField.H"
#};
code
#{
pointField points(19);
points[0] = point(0.5, 0, -0.5);
points[1] = point(1, 0, -0.5);
points[2] = point(2, 0, -0.5);
points[3] = point(2, 0.707107, -0.5);
points[4] = point(0.707107, 0.707107, -0.5);
points[5] = point(0.353553, 0.353553, -0.5);
points[6] = point(2, 2, -0.5);
points[7] = point(0.707107, 2, -0.5);
points[8] = point(0, 2, -0.5);
points[9] = point(0, 1, -0.5);
points[10] = point(0, 0.5, -0.5);
points[11] = point(-0.5, 0, -0.5);
points[12] = point(-1, 0, -0.5);
points[13] = point(-2, 0, -0.5);
points[14] = point(-2, 0.707107, -0.5);
points[15] = point(-0.707107, 0.707107, -0.5);
points[16] = point(-0.353553, 0.353553, -0.5);
points[17] = point(-2, 2, -0.5);
points[18] = point(-0.707107, 2, -0.5);
// Duplicate z points
label sz = points.size();
points.setSize(2*sz);
for (label i = 0; i < sz; i )
{
const point& pt = points[i];
points[i sz] = point(pt.x(), pt.y(), -pt.z());
}
os << points;
#};
};
blocks
(
hex (5 4 9 10 24 23 28 29) (10 10 1) simpleGrading (1 1 1)
hex (0 1 4 5 19 20 23 24) (10 10 1) simpleGrading (1 1 1)
hex (1 2 3 4 20 21 22 23) (20 10 1) simpleGrading (1 1 1)
hex (4 3 6 7 23 22 25 26) (20 20 1) simpleGrading (1 1 1)
hex (9 4 7 8 28 23 26 27) (10 20 1) simpleGrading (1 1 1)
hex (15 16 10 9 34 35 29 28) (10 10 1) simpleGrading (1 1 1)
hex (12 11 16 15 31 30 35 34) (10 10 1) simpleGrading (1 1 1)
hex (13 12 15 14 32 31 34 33) (20 10 1) simpleGrading (1 1 1)
hex (14 15 18 17 33 34 37 36) (20 20 1) simpleGrading (1 1 1)
hex (15 9 8 18 34 28 27 37) (10 20 1) simpleGrading (1 1 1)
);
edges
(
arc 0 5 45.0 (0 0 1)
arc 5 10 45.0 (0 0 1)
arc 1 4 45.0 (0 0 1)
arc 4 9 45.0 (0 0 1)
arc 19 24 45.0 (0 0 1)
arc 24 29 45.0 (0 0 1)
arc 20 23 45.0 (0 0 1)
arc 23 28 45.0 (0 0 1)
arc 11 16 45.0 (0 0 -1)
arc 16 10 45.0 (0 0 -1)
arc 12 15 45.0 (0 0 -1)
arc 15 9 45.0 (0 0 -1)
arc 30 35 45.0 (0 0 -1)
arc 35 29 45.0 (0 0 -1)
arc 31 34 45.0 (0 0 -1)
arc 34 28 45.0 (0 0 -1)
);
boundary
(
down
{
type symmetryPlane;
faces
(
(0 1 20 19)
(1 2 21 20)
(12 11 30 31)
(13 12 31 32)
);
}
right
{
type patch;
faces
(
(2 3 22 21)
(3 6 25 22)
);
}
up
{
type symmetryPlane;
faces
(
(7 8 27 26)
(6 7 26 25)
(8 18 37 27)
(18 17 36 37)
);
}
left
{
type patch;
faces
(
(14 13 32 33)
(17 14 33 36)
);
}
cylinder
{
type symmetry;
faces
(
(10 5 24 29)
(5 0 19 24)
(16 10 29 35)
(11 16 35 30)
);
}
);
mergePatchPairs
(
);
鉴于本算例几何模型较为简单,因此建议采用第三方软件(如ICEM CFD等)生成计算网格,然后利用网格转换命令将其转化为OpenFOAM网格。
potentialFoam求解器需要指定p文件与U文件。算例提供了名为p.orig及U.orig文件。这是p文件与U文件的备份文件,当p文件与U文件不存在时求解器会自动调用orig文件。
1、p.orig文件
p文件内容如下所示。
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
down
{
type symmetryPlane;
}
// 右侧出口静压为0
right
{
type fixedValue;
value uniform 0;
}
up
{
type symmetryPlane;
}
left
{
type zeroGradient;
}
cylinder
{
type symmetry;
}
defaultFaces
{
type empty;
}
}
2、U.orig文件
文件内容如下所示。
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
down
{
type symmetryPlane;
}
right
{
type zeroGradient;
}
up
{
type symmetryPlane;
}
// left入口速度1 m/s
left
{
type uniformFixedValue;
uniformValue constant (1 0 0);
}
cylinder
{
type symmetry;
}
defaultFaces
{
type empty;
}
}
1、controlDict文件
文件内容如下所示。
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * //
application potentialFoam;
startFrom latestTime;
startTime 0;
stopAt nextWrite;
endTime 1; //势流求解器计算很快,通常1步即可
deltaT 1;
writeControl timeStep;
writeInterval 1;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
2、fvSchemes文件
文件内容如下所示。
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default steadyState;
}
gradSchemes
{
default leastSquares;
}
divSchemes
{
default none;
div(phi,U) bounded Gauss linear;
div(div(phi,U)) Gauss linear;
}
laplacianSchemes
{
default Gauss linear corrected;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default corrected;
}
3、fvSolution文件
文件内容如下所示。
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSolution;z
}
// * * * * * * * * * * * * * * * * * * //
solvers
{
Phi
{
solver GAMG;
smoother DIC;
tolerance 1e-06;
relTol 0.01;
}
p
{
$Phi;
}
}
potentialFlow
{
nNonOrthogonalCorrectors 3;
}
执行命令进行求解并进入后处理器。
potentialFoam
paraFoam
计算完毕后可查看速度分布,如下图所示。
注:potentialFoam常用于获取一个较为合理的初始解,有点儿类似Fluent中的hybrid初始化。在利用potentialFoam计算完毕后,可以改用更复杂的求解器进行求解。
---------------------------------------------------------------------------------------------
版权声明:
原创文章,来源CFD之道,本文已经授权,欢迎分享,如需转载请联系作者。