新浪博客

OpenFOAM中原生网格生成方法与操作组件介绍

2014-05-30 21:42阅读:
Notes for Native Mesh Method in OpenFOAM
The OpenFOAM tutorials and CFD-online forum are the two most useful tools!
1. blockMesh
Keyword: structure mesh(Hex), base grids for snappyHexMesh
Execute: blockMesh
Requirements:
Dictionary file constant/polyMesh/blockMeshDict
Dictionary system/controlDict
blockMeshDict:
convertToMeters : used for unit conversion, default unit in OF is m(SI). (it seems no use)
vertices: define points of the domain in 3D format, and number them from 0 (feature in C++).
blocks: define blocks (list of vertices must start from the face with minX and then to the face with maxX when use as the base mesh for snappyHexMesh)
.
edges: use to describe arc or spline edges (U-139).
boundary : define and name the faces which could be used later as boundaries.
mergePatchPairs: list of patches to be merged and can be omitted.
OpenFOAM中原生网格生成方法与操作组件介绍
Fig 1 a simple hex block
Notes: blockMesh can be used to generate structured mesh, but it could be very complicated to manipulate for 3 dimensional model and other complex geometries the curves and surfaces. However it is essential to use blockMesh to generate the base mesh for snappyHexMesh.
Example:
convertToMeters 1;
vertices
(
(-15000 -10000 -10000) // 0
(-15000 20000 -10000) // 1
(15000 20000 -10000) // 2
(15000 -10000 -10000) // 3
(-15000 -10000 10000) // 4
(-15000 20000 10000) // 5
(15000 20000 10000) // 6
(15000 -10000 10000) // 7
);
blocks
(
//hex (0 1 2 3 4 5 6 7) (25 20 20) simpleGrading (1 1 1)
hex (0 1 5 4 3 2 6 7) (25 20 20) simpleGrading (1 1 1)
// hex must starts with the face at minX then the face at maxX(or from maxX to minX)
// ! Otherwise, it will go wrong when doing snappyHexMesh
);
edges // Ref U-139
(
);
boundary
(
frontAndBack
{
type patch;
faces
(
(3 7 6 2)
(1 5 4 0)
);
}
inlet
{
type patch;
faces
(
(0 4 7 3)
);
}
outlet
{
type patch;
faces
(
(2 6 5 1)
);
}
lowerWall
{
type wall;
faces
(
(0 3 2 1)
);
}
upperWall
{
type patch;
faces
(
(4 5 6 7)
);
}
);

2. snappyHexMesh
Keywords: hex-dominate mesh, cut-cell, complex (or called arbitrary) geometry
Execute: snappyHexMesh [-overwrite]
Requirements:
Essential:
system/snappyHexMeshDict the control file for this utility
constant/triSurface/ the geometry of the target, can be in the format of stl, obj or nas.
Optional:
systemt/surfaceFeatureExtractDict the control file for surface feature extract. In order to capture the features of a geometry with complicated surfaces, users should extract these features by run the utility called surfaceFeatureExtract before snappyHexMesh. During the extraction, a series of files will be generated in directory constant/extendedFeatureEdgeMesh.
system/decomposeParDict control file for snappyHexMesh in parallel.
system/meshQualityDict control file could be included in file snappyHexMeshDict.
Advantages:Being native in OpenFoam, snappyHexMesh is fully compatible with parallel process, zonal meshing for MRF and boundary layers.
Steps:
a) Creat the base mesh with blockMesh.
b) Check the domain and boundaries in ParaView and prepare the refine zone(refinement box etc.). Open both of the geometry(*.stl etc.) and the base mesh.
c) (optional) Run surfaceFeatureExtract to generate all the needed features of your geometry.
d) Define the parameters in snappyHexMeshDict including geometry, refinementBox, feature, refinementSurfaces, refinementRigion, locationInMesh, layers etc.
e) (optional) Run decomposePar to get the processors’ directories.
f) Run snappyHexMesh or mpirun -np 4 snappyHexMesh -overwrite –parallel to generate grids.
g) (optional) reconstructParMesh –constant.
Notes:
l snappyHexMeshDict (geometry + castellatedMeshControls + snapControls + addLayersControls + meshQualityControls)
l Be careful with all the geometry names use in files, even the name exist in the file header of *.stl.
Example:
The helicopter called SA342 includes complicated surfaces and gaps, and this problem also belong to the external aerodynamic. Therefore, the SA342 was chosen as the geometry in this section.
OpenFOAM中原生网格生成方法与操作组件介绍
Fig 2 snappyHexMesh for SA342 helicopter
The easiest way to set up your case is copy a similar tutorial into your working directory and then change some specified parameters to yours. As a kind of incompressible external flow at low Reynolds number, the tutorial called motorBike in OpenFOAM became the templates. Some important codes with comments were listed in the following.
surfaceFeatureExtractDict
SA342.stl
{
// How to obtain raw features (extractFromFile || extractFromSurface)
extractionMethod extractFromSurface;

extractFromSurfaceCoeffs
{
// Mark edges whose adjacent surface normals are at an angle less
// than includedAngle as features
// - 0 : selects no edges
// - 180: selects all edges
includedAngle 150;
}

subsetFeatures
{
// Keep nonManifold edges (edges with >2 connected faces)
nonManifoldEdges no;

// Keep open edges (edges with 1 connected face)
openEdges yes;
}


// Write options

// Write features to obj format for postprocessing
writeObj yes;
}
surfaceFeatureExtractDict is often been kept as default except for the includedAngle in extractFromSurfaceCoeffs.

snappyHexMeshDict:
geometry // define the geometry in your project
{
SA342.stl // the geometry file’s name in constant/triSurface
{
type triSurfaceMesh;
name SA342; // give a name to your geometry which will be used later.
}

refinementBox // zone of refinement, could be Box, Sphere, and cylinder
{
type searchableBox;
min (-4000 -1500 -1000);
max ( 4000 8000 5000);
} // this zone could also be visualized and checked in ParaView
};

//
features
(
{
file 'SA342.eMesh'; // *.eMesh file is generated by surfaceFeatureExtract
level 6;
}
);
//
refinementSurfaces
{
SA342
{
// Surface-wise min and max refinement level
level (5 6);

// Optional specification of patch type (default is wall). No
// constraint types (cyclic, symmetry) etc. are allowed.
patchInfo
{
type wall;
inGroups (SA342); // this name should be the same with that in your *.stl file
}
}
//
refinementRegions
{
refinementBox
{
mode inside; // select the region which will be refined
levels ((1E15 4));
}

}
locationInMesh (0.05 6000.05 2000.05); // This point should better to be in this style rather than only integer
//
layers
{
'SA342'
{
nSurfaceLayers 1; // the number of layers
}
}

// Expansion factor for layer mesh
expansionRatio 1.0;


3. Other utilities for mesh maniputation
1. autoPatch
Execution: autoPatch [-overwrite]
Identify different patches by featured angle.

2. checkMesh
Keywords: mesh quality and write different zones into set directory
Execution: checkMesh [–allGeometry] [–allTopology] [–constant] [-noZero]
Requirements
mesh file in constant/polyMesh
Dictionary system/controlDict
The utility will check whether your mesh can be calculated by OpenFOAM and report the quality of you mesh. In addition, users can get some summary information form the check report.
In addition, after executing this utility, different zones will be distinguished and the results will exist in the directory constant/polyMesh/sets.

3. createPatch
Keywords: create / modify patches
Execution: createPatch [–dict] [–overwrite]
Requirements
Dictionary system/createPatchDict
// Patches to create.
patches
(
{
name inlet;
patchInfo
{
type patch;
}
constructFrom set;
set inletFaces;
}
);

4. decomposePar / recomposeParMesh
Keywords: parallel
Only used in parallel calculation.

5. extrudeMesh
Keywords: 2D/3D mesh
Execution: extrudeMesh [-overwrite]
Requirements:extrudeMeshDict
This utility extrudes 2D mesh (or patch) into 3D mesh, or can be used to generate a OpenFOAM 2D mesh by extruding a patch by one element in z direction. Results will be saved in a new time sequence file.
extrudeMeshDict:
constructFrom patch; // indicate the source to be extrude is patch
sourceCase '../rotor'; // source case directory
sourcePatches (auto2); // source patch name

extrudeModel linearNormal; // model: linearNormal or wedge
nLayers 50;
expansionRatio 1.0;
linearNormalCoeffs
{
thickness 1.21; // thickness
}

6. mergeMeshes
Keywords:hybrid mesh
Execution: mergeMeshes masterDir addDir [-overwrite]
This utility can be used to merge different meshes in to one. And its most important use may be to generate a hybrid mesh.

7. patchSummary
This is useful to check your patches or boundaries.


8. renumberMesh
Execution: renumberMesh
This utility is used for renumbering the mesh and reducing the bandwidth of the unstructured grids(CM method), which could improve the efficiency of iteration.

9. transformPoints
Keywords:scale, translate, rotate
Execution: transformPoints –translate ‘(0 0 0.1)’

10. topoSet
Keywords:topology, zones
Execution: topoSet
Requirements:topSetDict
Set up basic topology with specified rules, including geometry and patches.
topoSetDict:
actions
(
{
name rotor;
type cellSet; // type: cellSet => constant/polyMesh/cellZones
action new;
source cylinderToCell; // more types on google
sourceInfo
{
p1 (0.121 0.0 0.00684432); // start point on cylinder axis//
p2 (0.121 0.0 -0.174509); // end point on cylinder axis//
radius 0.242;
}
}

{
name interAMI;
type faceSet;
action new;
source patchToFace;
sourceInfo
{
//
name 'inter.*';
}
}

// write the rotor set to constant/polyMehs/cellZones file
// rotor
{
name rotor;
type cellZoneSet;
action new;
source setToCellZone;
sourceInfo
{
set rotor;
}
}
);


11. potentialFoam
Keywords:potential flow, initialization
Execution: potentialFoam –noFunctionObjects –writep
Requirements:fvSolution
Initialize the flow field by solving the potential equation(Laplacian).
fvSolution:
potentialFlow
{
nNonOrthogonalCorrectors 10; // number of iteration
pRefCell 0;
pRefValue 0;
}
注:在OpenFOAM网格学习中整理的笔记,个人理解可能不全面甚至是有错误,本着交流的心态拿出来与大家共享(软件版本OpenFOAM-2.3.x)。

我的更多文章

下载客户端阅读体验更佳

APP专享