openfoam v8 波浪算例学习日记: 3.手动运行算例

openfoam8 wave算例学习记录

手动运行算例

网格处理

Allrun里第一步为blockMesh划分网格。

此命令读取system/blockMeshDict字典文件。以下为该字典文件内容(已去掉文件头):

$ cat system/blockMeshDict
...
convertToMeters 1; //顾名思义,直译为转换成米,1表示以下数字的单位为米

vertices //顶点
(
    (0 -300 -10)  //以下八个点坐标可以想象出其为长方体
    (1200 -300 -10)
    (1200 300 -10)
    (0 300 -10)
    (0 -300 10)
    (1200 -300 10)
    (1200 300 10)
    (0 300 10)
);

blocks
(
    hex (0 1 2 3 4 5 6 7) (67 40 1) simpleGrading (1 1 1) //网格数量,x方向67个,y方向40个,z方向1个网格
);

edges
(
);

defaultPatch
{
    name frontAndBack; 
    type empty; //这个类型一看到,就说明本算例为2维
}

boundary //其他四个面的定义
(
    left
    {
        type patch;
        faces
        (
            (0 4 7 3)
        );
    }
    right
    {
        type patch;
        faces
        (
            (2 6 5 1)
        );
    }
    bottom
    {
        type wall;
        faces
        (
            (0 1 5 4)
        );
    }
    top
    {
        type patch;
        faces
        (
            (2 3 7 6)
        );
    }
);

mergePatchPairs
(
);

// ************************************************************************* //

blockMeshDict内容较简单,此时终端中运行blockMesh命令。

$ blockMesh
...
Create time

Creating block mesh from
    "system/blockMeshDict" //读取的字典文件
Creating block edges
No non-planar block faces defined
Creating topology blocks
Creating topology patches

Creating block mesh topology
--> FOAM Warning :
    From function Foam::polyMesh::polyMesh(const Foam::IOobject&, Foam::pointField&&, const cellShapeList&, const faceListList&, const wordList&, const Foam::PtrList<Foam::dictionary>&, const Foam::word&, const Foam::word&, bool)
    in file meshes/polyMesh/polyMeshFromShapeMesh.C at line 873
    Found 2 undefined faces in mesh; adding to default patch. //此default patch字典里也定义了。

Check topology

        Basic statistics
                Number of internal faces : 0
                Number of boundary faces : 6
                Number of defined boundary faces : 6
                Number of undefined boundary faces : 0
        Checking patch -> block consistency

Creating block offsets
Creating merge list .

Creating polyMesh from blockMesh
Creating patches
Creating cells
Creating points with scale 1
    Block 0 cell size :   //网格大小信息
        i : 17.9104 .. 17.9104
        j : 15
        k : 20

Writing polyMesh
----------------
Mesh Information
----------------
  boundingBox: (0 -300 -10) (1200 300 10)
  nPoints: 5576
  nCells: 2680   //网格数
  nFaces: 10827
  nInternalFaces: 5253
----------------
Patches
----------------
  patch 0 (start: 5253 size: 40) name: left
  patch 1 (start: 5293 size: 40) name: right
  patch 2 (start: 5333 size: 67) name: bottom
  patch 3 (start: 5400 size: 67) name: top
  patch 4 (start: 5467 size: 5360) name: frontAndBack

End

运行结束后,继续运行paraFoam查看模型。

blockMesh

Allrun里第二步为extrudeMesh

这条命令几乎没用过,根据名称大致为扩展(延伸、拉长)网格。记得system文件夹中有extrudeMeshDict文件,此命令读取该文件。以下为该字典文件

FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      extrudeMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

constructFrom   mesh;

sourceCase      ".";

sourcePatches   (right); //猜测以right边界面为源

flipNormals     false;

nLayers         25; // xx层网格

expansionRatio  1.09; //直译:膨胀率。如何计算呢,是最后一层网格是第一层的1.09倍还是1.09^25倍呢。

extrudeModel    linearNormal;

linearNormalCoeffs
{
    thickness       1500;
}

mergeFaces      false;


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

由于该命令几乎没用过,里面各项意义不太理解。大致能猜测是以right边界面为起点,向其法向延伸1500,添加25个网格。接下来在终端中运行此命令。

$ extrudeMesh
...
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Selecting extrudeModel linearNormal
Extruding from mesh using model linearNormal
Collapsing edges < 0.0001 of bounding box

Extruding patches 1(right) on mesh "/home/yuno/OpenFOAM/yuno-8/run/tutorials/multiphase/interFoam/laminar/wave"

Create mesh for time = 0

Adding overall 0 processor patches.
Testing:"/home/yuno/OpenFOAM/yuno-8/run/tutorials/multiphase/interFoam/laminar/wave/system/fvSchemes"
Mesh bounding box : (0 -300 -10) (2700 300 10)
        with span : (2700 600 20)
Merge distance    : 0.002

Collapsing edges < 0.002 ...

            Uncollapsed edges = 0 / 18797
    Number of points : 7626
    Not visited      : 0
    Not collapsed    : 7626
    Collapsed        : 0

Collapsing 0 cells
Writing mesh to "constant/region0"

Writing added cells to cellSet addedCells

End

paraFoam中查看

extrudeMesh

可以看到如猜测般从right边界延正法向延伸了1500,并添加了25层网格。最后一层大约140=17.9104(见blockMesh输出网格大小)*1.09^25。可见膨胀率是层层叠加的。

第三步 网格加密

Allrun里一共加密了6次,其中前两次为x方向,后四次为y方向。接下来一次一次来运行。

topoSet与refineMesh组合为加密网格常用命令。topoSet选取加密区域,refineMesh进行网格加密(选定方向网格小一半)。

接下来先查看topoSetDict1

$  cat system/topoSetDict1
...
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

actions
(
    {
        name    box; //域名称,可自定义名称
        type    cellSet; // 直译:单元集和
        action  new;  //新生成一个cellSet
        source  boxToCell; //通过boxToCell的方式选定区域
        sourceInfo
        {
            box (-1e6 -40 -1e6) (1300 40 1e6); //矩形体的长对角点
        }
    }
);

// ************************************************************************* //

在终端中运行topoSet -dict system/topoSetDict1-dict指定该命令读取的字典文件,默认为(comandName)Dict

$ topoSet -dict system/topoSetDict1
...
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create polyMesh for time = 0

Reading topoSetDict

Time = 0
    mesh not changed.
Created cellSet box
    Applying source boxToCell
    Adding cells with center within boxes 1((-1e+06 -40 -1e+06) (1300 40 1e+06))
    cellSet box now size 432
End

此步无法在paraview中观察到,此命令会在constant/polyMesh/sets中生成一个域名称的文件,此处为box。文件中为432个网格(的编号)。

topoSetDict1

其中adddedCells是上一步extrudeMesh生成的文件。

接下来查看refineMesh读取的refineMeshDictX文件。

$ cat system/refineMeshDictX
...
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      refineMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

set box; //上一步topoSet中定义的域名称

coordinateSystem global;

globalCoeffs
{
    tan1 (1 0 0); //X方向
    tan2 (0 1 0); //Y方向
}

directions
(
    tan1   //此处选择了X方向,可以选择多个方向
);

useHexTopology  true;

geometricCut    false;

writeMesh       false;


// ************************************************************************* //

继续在终端运行 refineMesh -dict system/refineMeshDictX -overwrite。其中选项-overwrite是将加密后的网格写入初始时刻,读者们可以试试不加此选项以了解其文件的输出。
现在可以在paraFoam中查看网格了。
refineMeshX

该命令在topoSet中选定的区域在选定的方向对半分网格。

refineMeshDictYrefineMeshDictX的区别只在 directions里。
接下来的五组网格加密做完之后,网格如图所示。
refineMeshAll

到此,网格划分的操作就结束了。接下来为设定初始场。

  • 11
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值