使用snappyHexMesh绘制2D网格

思路

使用snappyHexMesh绘制3D网格,然后使用extrudeMeshfront或者back的面网格沿面法向方向extrude出2D网格,在extrude方向上只有一层网格。

步骤

1、使用snappyHexMesh绘制3D网格,注意在extrude方向上的厚度不能太薄,应与长和宽的尺度基本一致,否则snappyHexMesh生成网格的过程收敛性会出现问题。

2、使用extrudeMesh命令extrude front或者back面生成2D网格,OpenFOAM v1806的控制文件为system/extrudeMeshDict,而foam-extend-4.0的控制文件为constant/extrudeProperties。下面是一个extrudeMeshDict的例子:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | foam-extend: Open Source CFD                    |
|  \\    /   O peration     | Version:     4.0                                |
|   \\  /    A nd           | Web:         http://www.foam-extend.org         |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      extrudeProperties;
}
constructFrom patch;
sourceCase "../ground_effect_snappyHexMesh";
sourcePatches (front);
exposedPatchName back;

flipNormals true;   //改成false可以改变extrude的方向
extrudeModel        linearNormal;
nLayers             1;
expansionRatio      1.0;
linearNormalCoeffs
{
    thickness       4;
}
mergeFaces false;

foam-extend-4.0extrudeProperties与上面的例子有以下几处不同:

  • sourcePatches (front);更改为sourcePatch front;
  • thickness的值不能大于1

到此为止,对于OpenFOAM v1806来说,已经完成了绘制2D网格的全部工作,而对于foam-extend-4.0来说,extrudeMesh会使之前定义的patch全部消失,所以接下来还需要完成patch的重新定义。

3、在终端运行:

autoPatch 90 -overwrite    #90为特征角

程序将会根据外部面之间连接的特征角,当特征角大于或等于我们设定的角度时,程序会自动将外部面分解成多个patch

4、在终端运行:

createPatch -overwrite

将多个小的patch合并成一个大的patch,该命令的运行需要system/createPatchDict文件。下面是一个createPatchDict的例子:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | foam-extend: Open Source CFD                    |
|  \\    /   O peration     | Version:     4.0                                |
|   \\  /    A nd           | Web:         http://www.foam-extend.org         |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

matchTolerance 1E-3;

pointSync true;

patchInfo
(
    {
        name bottom;
        dictionary
        {
            type patch;
        }
        constructFrom patches;
        patches ( auto1 );
    }
    {
        name top;
        dictionary
        {
            type patch;
        }
        constructFrom patches;
        patches ( auto2 );
    }
    {
        name inlet;
        dictionary
        {
            type patch;
        }
        constructFrom patches;
        patches ( auto0 );
    }
    {
        name outlet;
        dictionary
        {
            type patch;
        }
        constructFrom patches;
        patches ( auto3 );
    }
    {
        name wing;
        dictionary
        {
            type wall;
        }
        constructFrom patches;
        patches ( auto4 );
    }
    {
        name back;
        dictionary
        {
            type empty;
        }
        constructFrom patches;
        patches ( auto6 );
    }
    {
        name front;
        dictionary
        {
            type empty;
        }
        constructFrom patches;
        patches ( auto5 );
    }
);

到此为止,foam-extend-4.0也完成了2D网格的绘制。

你可能感兴趣的:(使用snappyHexMesh绘制2D网格)