@daidezhi
2016-07-01T07:50:52.000000Z
字数 4103
阅读 4098
CFD OpenFOAM
方腔内部等温不可压流动算例常用于测试不可压流动求解器的计算准确性,测试数据通常使用Ghia等人[1]的数据。如下图所示,方腔左表面、右表面和底部均为静止壁面,顶部为运动壁面,速度为。

这里使用OpenFOAM标准不可压求解器icoFoam对雷诺数的工况进行数值模拟,并比较了upwind、linearUpwind和vanLeer三种对流格式的精度。
这里使用的网格为适用于OpenFOAM二维模拟的多边形棱柱体网格,如下图所示

关于多边形棱柱体网格的生成可参考教程OpenFOAM二维多面体网格准备。
本教程算例文件结构如下:
$case 算例根目录
├──constant 网格和输运参数目录
│ ├──polyMesh 网格目录,网格格式详见CFD多面体网格数据结构—OpenFOAM
│ └──transportProperties 输运参数设置
├──0 初始和边界条件目录
│ ├──p 变量p初始和边界条件设置
│ └──U 速度U初始和边界条件设置
└──system 求解器设置目录
├──controlDict 计算控制参数设置,设置起始终止时间,时间步长,输出控制等
├──fvSchemes 微分算子离散格式设置
├──fvSolution 代数方程组求解和PISO算法设置
└──sampleDict 数据采样设置
下面按照上面文件出现的次序依次列出其具体内容(略去文件头部说明)。
transportPropertiestransportProperties字典文件的内容如下
//文件说明FoamFile{version 2.0; //版本号format ascii; //文本格式class dictionary; //类型为字典文件location "constant"; //所在目录object transportProperties; //对象名}//设置运动粘性系数nu的单位和值nu nu [ 0 2 -1 0 0 0 0 ] 0.001;
pp文件的内容如下
//文件说明FoamFile{version 2.0; //版本号format ascii; //文本格式class volScalarField; //类型为体心标量场object p; //对象名}dimensions [0 2 -2 0 0 0 0]; //设置单位internalField uniform 0; //内场初始化为0//边界条件boundaryField{leftWall{type zeroGradient;}rightWall{type zeroGradient;}lowerWall{type zeroGradient;}topWall{type zeroGradient;}defaultFaces{type empty;}}
UU文件的内容如下
//文件说明FoamFile{version 2.0; //版本号format ascii; //文本格式class volVectorField; //类型为体心矢量场object U; //对象名}dimensions [0 1 -1 0 0 0 0]; //设置单位internalField uniform (0 0 0); //内场初始化为0矢量//边界条件boundaryField{leftWall{type fixedValue;value uniform (0 0 0);}rightWall{type fixedValue;value uniform (0 0 0);}lowerWall{type fixedValue;value uniform (0 0 0);}topWall{type fixedValue;value uniform (1 0 0);}defaultFaces{type empty;}}
controlDictcontrolDict字典文件的内容如下
FoamFile{version 2.0; //版本号format ascii; //文本格式class dictionary; //类型为字典文件location "system"; //所在目录object controlDict; //对象名}application icoFoam;startFrom startTime;startTime 0;stopAt endTime;endTime 50.0;deltaT 0.01;writeControl runTime;writeInterval 1.0;purgeWrite 0;writeFormat ascii;writePrecision 6;writeCompression off;timeFormat general;timePrecision 6;runTimeModifiable true;//设置探针类型和位置,用于判断流动是否达到稳态functions{UProbe{type probes;functionObjectLibs ("libsampling.so");outputControl outputTime;probeLocations((0.5 0.5 0.125));fields(U);}pProbe{type probes;functionObjectLibs ("libsampling.so");outputControl outputTime;probeLocations((0.5 0.5 0.125));fields(p);}}
fvSchemesfvSchemes字典文件的内容如下
//文件说明FoamFile{version 2.0; //版本号format ascii; //文本格式class dictionary; //类型为字典文件location "system"; //所在目录object fvSchemes; //对象名}ddtSchemes{default Euler;}gradSchemes{default Gauss linear;grad(p) Gauss linear;}divSchemes{default none;div(phi,U) Gauss upwind phi; //之后将"upwind"替换为"linearUpwind"和"vanLeer"}laplacianSchemes{default Gauss linear corrected;}interpolationSchemes{default linear;}snGradSchemes{default corrected;}fluxRequired{default no;p ;}
fvSolutionfvSolution字典文件的内容如下
//文件说明FoamFile{version 2.0; //版本号format ascii; //文本格式class dictionary; //类型为字典文件location "system"; //所在目录object fvSolution; //对象名}solvers{p{solver PCG;preconditioner DIC;tolerance 1e-08;relTol 0;}U{solver smoothSolver;smoother symGaussSeidel;tolerance 1e-08;relTol 0;}}PISO{nCorrectors 5;nNonOrthogonalCorrectors 5;pRefCell 0;pRefValue 0;}
sampleDictsampleDict字典文件的内容如下
//文件说明FoamFile{version 2.0; //版本号format ascii; //文本格式class dictionary; //类型为字典文件location "system"; //所在目录object sampleDict; //对象名}interpolationScheme cellPoint; //设置插值方式setFormat raw; //常规文本输出//采样集合sets(//垂直中心线verticalCenterLine{type uniform;axis y;start (0.5 0.0 0.25);end (0.5 1.0 0.25);nPoints 100;}//水平中心线horizontalCenterLine{type uniform;axis x;start (0.0 0.5 0.25);end (1.0 0.5 0.25);nPoints 100;});//采样对象fields(U);
由于icoFoam求解器属于非定常求解器,因此需要按时间推进模拟顶盖驱动流,到达一定时间后流动趋于稳定。用来对比验证的数据是稳态数据,因此需要确定何时流动能够趋于稳定。
下面三幅图分别是压力p,速度U的x和y分量随时间的变化曲线,从图中可以看出流动大概在后趋于稳定。
探针位置p随时间变化曲线
探针位置U.x()随时间变化曲线
探针位置U.y()随时间变化曲线
upwind对流格式使用upwind对流格式得到的计算结果与基准解的对比如下所示
垂直中线上U.x()变化曲线
水平中线上U.y()变化曲线
linearUpwind对流格式使用linearUpwind对流格式得到的计算结果与基准解的对比如下所示
垂直中线上U.x()变化曲线
水平中线上U.y()变化曲线
vanLeer对流格式使用vanLeer对流格式得到的计算结果与基准解的对比如下所示
垂直中线上U.x()变化曲线
水平中线上U.y()变化曲线
不难看出,计算结果和基准解的吻合度linearUpwind vanLeer upwind。
感谢您的阅读,欢迎讨论和批评指正。
作者:戴得志