openfoam自学03

接着进行网格控制文件的编写

打开controlDict文件,可以看到求解控制代码。

这里主要针对,求解器选择 icoFoam;

开始时间设置为0,结束时间设置为2.5s,时间步长为0.0005,写入间隔为50

其他的默认就好,整体代码如下:

/*--------------------------------*- C++ -*----------------------------------*\| =========                 |                                                 || \      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           ||  \    /   O peration     | Version:  5                                     ||   \  /    A nd           | Web:      www.OpenFOAM.org                      ||    \/     M anipulation  |                                                 |\*---------------------------------------------------------------------------*/FoamFile{    version     2.0;    format      ascii;    class       dictionary;    location    "system";    object      controlDict;}application     icoFoam;startFrom       startTime;startTime       0;stopAt          endTime;endTime         2.5;deltaT          0.0005;writeControl    timeStep;writeInterval   50;purgeWrite      0;writeFormat     ascii;writePrecision  6;writeCompression off;timeFormat      general;timePrecision   6;runTimeModifiable true;

接下来进行边界条件的设置,也就是0文件夹的内容,此次只设置压力p和速度U。

以速度U为例:

dimensions,表示量纲,也就是速度的单位;

internalFiel,内部场的信息,一般设为0;

boundaryField,边界条件,这也是最主要的设置部分,设置块和网格设置的边界条件一致。

由于之前设置了inlet入口,outlet出口,wall墙,以及frontAndBack。

一般情况下,入口设置一定的速度,这里是设置的速度分量,x,y,z,但是为了简单,这里只设置了y方向的速度,值得大小为1。

出口设置为zeroGradient;

墙设置为noSlip,无滑移,也就是基本保持和内部场信息一致;

前后面为空,保证二维条件设置。

具体代码如下:

U

/*--------------------------------*- C++ -*----------------------------------*\| =========                 |                                                 || \      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           ||  \    /   O peration     | Version:  5                                     ||   \  /    A nd           | Web:      www.OpenFOAM.org                      ||    \/     M anipulation  |                                                 |\*---------------------------------------------------------------------------*/FoamFile{    version     2.0;    format      ascii;    class       volVectorField;    object      U;}dimensions      [0 1 -1 0 0 0 0];internalField   uniform (0 0 0);boundaryField{    inlet    {        type            fixedValue;        value           uniform (0 1 0);    }   outlet   {type            zeroGradient;   }    wall    {        type            noSlip;    }    frontAndBack    {        type            empty;    }}


p

/*--------------------------------*- C++ -*----------------------------------*\| =========                 |                                                 || \      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           ||  \    /   O peration     | Version:  5                                     ||   \  /    A nd           | Web:      www.OpenFOAM.org                      ||    \/     M anipulation  |                                                 |\*---------------------------------------------------------------------------*/FoamFile{    version     2.0;    format      ascii;    class       volScalarField;    object      p;}dimensions      [0 2 -2 0 0 0 0];internalField   uniform 0;boundaryField{    inlet    {        type            zeroGradient;    }  outlet   {type            fixedValue;value           uniform 0;     }   wall    {        type            zeroGradient;    }   frontAndBack    {        type            empty;    }}

然后,整个case设置完毕,在命令行输入:

icoFoam

运行完毕后,将结果导入paraview中后处理即可。

发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章