Professional Documents
Culture Documents
A Comprehensive Tour of snappyHexMesh PDF
A Comprehensive Tour of snappyHexMesh PDF
snappyHexMesh
7th OpenFOAM Workshop
25 June 2012
info@engys.eu | Tel: +44 (0)20 32393041 | Fax: +44 (0)20 33573123 | www.engys.eu
Copyright © 2012 Engys Ltd.
You Will Learn About...
• Mesh Creation
blockMesh
snappyHexMesh
• Mesh Checks
checkMesh
• Requirements:
Dictionary file constant/polyMesh/blockMeshDict
Dictionary system/controlDict
vertices
(
(0.0 0.0 -0.038)
(0.038 0.0 -0.038)
(0.076 0.0 -0.038)
(0.0 1.09 -0.038)
(0.038 1.09 -0.038)
(0.076 1.09 -0.038)
(0.0 2.18 -0.038) List of all vertices on each block
(0.038 2.18 -0.038)
(0.076 2.18 -0.038)
(0.0 0.0 0.038)
• Cartesian coordinates (x, y, z)
(0.038 0.0 0.038)
(0.076 0.0 0.038) • Each vertex in list = 1 index
(0.0 1.09 0.038)
(0.038 1.09 0.038)
(0.076 1.09 0.038)
(0.0 2.18 0.038)
(0.038 2.18 0.038)
(0.076 2.18 0.038)
);
edges();
All vertices in order
Number of nodes
per side (x, y, z)
Mesh grading
patches
Define curved edges
(
wall ffmaxy
(
• Edge is straight if not listed
)
(6 15 16 7)
(7 16 17 8) • Arc and Spline available
wall ffminy
(
(0 1 10 9)
(1 2 11 10)
Patches
)
wall cold
(
• Boundary (base) type
)
(3 12 15 6)
(0 9 12 3) • Patch name
wall hot
(
(2 5 14 11)
• List of vertices (one per patch)
)
(5 8 17 14)
• Order follows right-hand rule
empty frontAndBack
(
(0 3 4 1)
(1 4 5 2)
(3 6 7 4)
Merge multiple (separated)
(4 7 8 5)
(9 10 13 12)
(10 11 14 13)
blocks into one mesh
(12 13 16 15)
(13 14 17 16) • One-to-one correspondence
)
);
if blocks are not listed
mergePatchPairs();
Copyright © 2012 Engys Ltd.
You Will Learn About...
• Mesh Creation
blockMesh
snappyHexMesh
• Mesh Checks
• Requirements:
Dictionary file system/snappyHexMeshDict
Geometry data (stl, nas, obj) in constant/triSurface
Hexahedral base mesh (decomposed if running in parallel)
Dictionary file system/decomposeParDict for parallel runs
All system dictionaries (e.g controlDict, fvSchemes, fvSolutions)
STL or Nastran
(constant/triSurface)
NOTE: File names must not
contain any spaces, unusual
characters or begin with a
number. The same applies to the
names of the parts and regions
defined within the geometry files.
Note: All steps are automatic. Reproduced here for information purposes only.
geometry
{
flange.stl
{
type triSurfaceMesh;
name flange;
}
sphereA
{
type searchableSphere;
centre (0 0 -0.012);
radius 0.003;
}
}
sphere
{
type searchableSphere;
centre (3 3 0);
radius 4;
}
cylinder
{
type searchableCylinder;
point1 (0 0 0);
point2 (1 0 0);
radius 0.1;
}
plate
{
type searchablePlate;
origin (0 0 0);
span (0.5 0.5 0);
}
boxA
shapes scaled and transformed
{
surface box;
scale (1.0 1.0 2.1);
transform
{
type cartesian;
origin (2 2 0);
e1 (1 0 0);
e3 (0 0 1);
}
}
boxB
{
surface box;
scale (1.0 1.0 2.1);
transform
{
type cartesian;
origin (3.5 3 0);
e1 (1 0 0);
e3 (0 0 1);
}
}
}
Copyright © 2012 Engys Ltd.
snappyHexMeshDict | Refinement
The first meshing stage is called
“Refinement”. This is where the initial block
mesh is refined based on surface and
volumetric refinement settings in the
castellatedMeshControls sub-dictionary
features();
• Buffer layers
refinementSurfaces
{
flange
{ nCellsBetweenLevels 1
level (2 3);
regions{“*.inlet|*.outlet”{level(3,4);}}
}
sphereA
{
level (3 3);
faceZone zoneA; cellZone zoneA; cellZoneInside inside;
}
}
resolveFeatureAngle 30;
refinementRegions nCellsBetweenLevels 3
{
sphereA
{
mode inside;
levels ((1E15 3));
}
}
locationInMesh (-9.23149e-05 -0.0025 -0.0025);
allowFreeStandingZoneFaces true;
}
}
regions{“*.inlet|*.outlet”{level(3,4);}} Level 0 Level 1 Level 1
sphereA
{
level (3 3); Level 2
faceZone zoneA; cellZone zoneA; cellZoneInside inside;
}
}
resolveFeatureAngle 30;
refinementRegions
{
sphereA
{
mode inside;
levels ((1E15 3));
Surface Mesh Refinements
}
}
locationInMesh (-9.23149e-05 -0.0025 -0.0025);
allowFreeStandingZoneFaces true;
}
features();
• patchInfo keyword can be used to set
refinementSurfaces
the boundary type on a per surface basis
{
flange
{
level (2 3);
regions{“*.inlet|*.outlet”{level(3,4);}} refinementSurfaces
} {
sphereA flange
{ {
level (3 3); level (2 3);
faceZone zoneA; cellZone zoneA; cellZoneInside inside; patchInfo
} {
} type wall;
}
resolveFeatureAngle 30; regions
{
refinementRegions “*.inlet|*.outlet”
{ {
sphereA level(3,4);
{ }
mode inside; }
levels ((1E15 3)); }
} }
}
locationInMesh (-9.23149e-05 -0.0025 -0.0025);
allowFreeStandingZoneFaces true;
}
features();
• Cell zone name
refinementSurfaces
• Face zone name
{
flange • Area selection: inside, outside or
{
level (2 3); insidepoint
regions{“*.inlet|*.outlet”{level(3,4);}}
}
sphereA
{
level (3 3);
faceZone zoneA; cellZone zoneA; cellZoneInside inside;
}
}
resolveFeatureAngle 30;
refinementRegions
{
sphereA
{
mode inside;
levels ((1E15 3));
}
}
locationInMesh (-9.23149e-05 -0.0025 -0.0025);
}
allowFreeStandingZoneFaces true; Mesh Zones
Copyright © 2012 Engys Ltd.
snappyHexMeshDict | castellatedMesh
castellatedMeshControls
{ Additional feature refinements:
maxGlobalCells 2000000;
minRefinementCells 0; • Local curvature
nCellsBetweenLevels 1;
features();
• Feature angle refinement
refinementSurfaces
{
flange
{
level (2 3);
regions{“*.inlet|*.outlet”{level(3,4);}}
}
Level 1 Level 1 Level 2
sphereA
{
level (3 3); Level 2
faceZone zoneA; cellZone zoneA; cellZoneInside inside;
}
}
resolveFeatureAngle 30;
refinementRegions
{
sphereA
{
mode inside;
levels ((1E15 3));
}
} Level 3 → Local curvature
locationInMesh (-9.23149e-05 -0.0025 -0.0025);
allowFreeStandingZoneFaces true;
refinement
}
features();
• distance
refinementSurfaces
{
flange
{
level (2 3);
regions{“*.inlet|*.outlet”{level(3,4);}}
}
sphereA
{
level (3 3);
faceZone zoneA; cellZone zoneA; cellZoneInside inside;
}
}
resolveFeatureAngle 30;
refinementRegions
{
sphereA
{
mode inside;
}
levels ((1E15 3)); mode inside;
}
locationInMesh (-9.23149e-05 -0.0025 -0.0025);
levels ((1E15 3));
allowFreeStandingZoneFaces true;
}
features();
refinementSurfaces
{
flange
Keep Point in cell
{
level (2 3);
regions{“*.inlet|*.outlet”{level(3,4);}}
}
sphereA
{
level (3 3);
Level 1 Level 1
faceZone zoneA; cellZone zoneA; cellZoneInside inside;
}
} Level 2 Level 2
resolveFeatureAngle 30;
refinementRegions
{
sphereA
{
mode inside;
levels ((1E15 3));
}
}
locationInMesh (-9.23149e-05 -0.0025 -0.0025);
allowFreeStandingZoneFaces true;
}
features();
If kept these can cause quality issues
refinementSurfaces
when the zone faces are snapped to the
{
flange surface
{
level (2 3); allowFreeStandingZoneFaces true; allowFreeStandingZoneFaces false;
regions{“*.inlet|*.outlet”{level(3,4);}}
}
sphereA
{
level (3 3);
faceZone zoneA; cellZone zoneA; cellZoneInside inside;
}
}
resolveFeatureAngle 30;
refinementRegions
{
sphereA
{
mode inside;
levels ((1E15 3));
}
}
locationInMesh (-9.23149e-05 -0.0025 -0.0025);
allowFreeStandingZoneFaces true;
Cell Zone
}
Face Zone
Copyright © 2012 Engys Ltd.
snappyHexMeshDict | Surface Snapping
The second meshing stage is called
“Snapping” where patch faces are
projected down onto the surface
geometry. This stage is controlled by
settings in the snapControls sub-
dictionary
nSolveIter 300;
surface is performed
nRelaxIter 5;
Scaling of the maximum edge length for
nFeatureSnapIter 10;
} attraction to the surface
tolerance 1.0;
perform. Features edges to attract to are
nSolveIter 300;
defined by an .eMesh file setup in
nRelaxIter 5; castellatedMeshControls which can also
nFeatureSnapIter 10; be used for feature refinement.
}
minThickness 0.2;
relativeSizes true;
// Advanced settings
featureAngle 30;
nSmoothSurfaceNormals 1;
nSmoothNormals 3;
nSmoothThickness 10;
minMedianAxisAngle 80;
maxThicknessToMedialRatio 0.3;
maxFaceThicknessRatio 0.5;
nLayerIter 50;
meshQualityControls::relaxed.
nRelaxedIter 20;
nRelaxIter 5;
}
minMedianAxisAngle 80;
maxThicknessToMedialRatio 0.3;
maxFaceThicknessRatio 0.5;
nLayerIter 50;
meshQualityControls::relaxed.
nRelaxedIter 20;
nRelaxIter 5;
}
// Advanced settings
featureAngle 30;
nSmoothSurfaceNormals 1;
nSmoothNormals 3;
nSmoothThickness 10;
minMedianAxisAngle 80;
maxThicknessToMedialRatio 0.3;
maxFaceThicknessRatio 0.5;
nLayerIter 50;
meshQualityControls::relaxed.
nRelaxedIter 20;
nRelaxIter 5;
}
finalLayerThickness 0.4;
expansionRatio 1.15;
minThickness 0.2;
relativeSizes true;
// Advanced settings
Specification of a minimum layer
featureAngle 30;
thickness below which height layers will
nSmoothSurfaceNormals 1;
nSmoothNormals 3; automatically be collapsed.
nSmoothThickness 10;
minMedianAxisAngle 80;
maxThicknessToMedialRatio 0.3;
The final layer thickness and minimum
maxFaceThicknessRatio 0.5;
thickness can be defined as either being
nLayerIter 50; relative (true) to the background spacing
meshQualityControls::relaxed. ΔS or defined as an absolute (false)
nRelaxedIter 20;
length.
nRelaxIter 5;
}
finalLayerThickness 0.4;
expansionRatio 1.15;
minThickness 0.2;
relativeSizes true;
featureAngle 45;
// Advanced settings
featureAngle 30;
nSmoothSurfaceNormals 1;
nSmoothNormals 3;
nSmoothThickness 10;
minMedianAxisAngle 80;
maxThicknessToMedialRatio 0.3;
maxFaceThicknessRatio 0.5;
nLayerIter 50;
meshQualityControls::relaxed.
featureAngle 180;
nRelaxedIter 20;
nRelaxIter 5;
}
nSmoothSurfaceNormals 1;
nSmoothNormals 3;
nSmoothThickness 10;
minMedianAxisAngle 80;
maxThicknessToMedialRatio 0.3;
maxFaceThicknessRatio 0.5;
nLayerIter 50;
meshQualityControls::relaxed.
nRelaxedIter 20;
nRelaxIter 5;
} Smoothed surface normals
minThickness 0.2;
relativeSizes true;
nSurfaceLayers >0
// Advanced settings
featureAngle 30;
nSmoothSurfaceNormals 1;
nSmoothNormals 3;
nSmoothThickness 10;
minMedianAxisAngle 80; H
maxThicknessToMedialRatio 0.3;
M
maxFaceThicknessRatio 0.5;
nLayerIter 50;
meshQualityControls::relaxed.
nRelaxedIter 20;
Medial Axis
nRelaxIter 5;
}
nSurfaceLayers =0
minThickness 0.2;
relativeSizes true;
nSurfaceLayers >0
// Advanced settings
featureAngle 30;
nSmoothSurfaceNormals 1;
nSmoothNormals 3;
nSmoothThickness 10;
minMedianAxisAngle 80; H
maxThicknessToMedialRatio 0.3;
M
maxFaceThicknessRatio 0.5;
nLayerIter 50;
meshQualityControls::relaxed.
nRelaxedIter 20;
Medial Axis
nRelaxIter 5;
}
nSurfaceLayers =0
relativeSizes true;
the layer addition loop early with the
// Advanced settings
currently generated layer
featureAngle 30;
If layer iteration has not converged
nSmoothSurfaceNormals 1;
nSmoothNormals 3;
nSmoothThickness 10;
after a specified number of iterations
minMedianAxisAngle 80;
then use a set of relaxed mesh
maxThicknessToMedialRatio 0.3;
quality metrics, set in
maxFaceThicknessRatio 0.5;
meshQualityControls, to achieve
nLayerIter 50;
convergence
meshQualityControls::relaxed.
nRelaxedIter 20;
nRelaxIter 5;
Controls number of scaling back iterations
} during error reduction stage
minArea 1e-13;
minTetQuality 1e-30;
minTwist 0.05;
minDeterminant 0.001;
ci Ai
minFaceWeight 0.05;
minVolRatio 0.01;
minTriangleTwist -1;
//minVolCollapseRatio 0.5;
// Advanced Ai .ci
nSmoothScale 4;
errorReduction 0.75;
metric face,orthogonality
relaxed
Ai ci
{
maxNonOrtho 75;
}
}
// Advanced
nSmoothScale 4;
errorReduction 0.75;
relaxed
{
maxNonOrtho 75;
}
}
maxConcave 80;
minVol 1e-13;
minArea 1e-13;
>100 degrees
minTetQuality 1e-30;
minTwist 0.05;
minDeterminant 0.001;
minFaceWeight 0.05;
minVolRatio 0.01;
minTriangleTwist -1;
//minVolCollapseRatio 0.5;
// Advanced
nSmoothScale 4;
errorReduction 0.75;
relaxed
{
maxNonOrtho 75;
}
}
1
minTetQuality 1e-30;
minTwist 0.05;
metric face,pyramid volume Ai bi
minDeterminant 0.001; 3
minFaceWeight 0.05;
minVolRatio 0.01;
bi
minTriangleTwist -1; Ai
//minVolCollapseRatio 0.5;
// Advanced
nSmoothScale 4;
errorReduction 0.75;
relaxed
{
maxNonOrtho 75;
}
}
minTetQuality 1e-30;
1
minTwist 0.05;
1 (b a ) (c a )
minDeterminant 0.001; cr (a tv a b c
minFaceWeight 0.05; 2 c (b a ) 6
minVolRatio 0.01;
tv
minTriangleTwist -1; metric face,tet quality
8
* cr 3
//minVolCollapseRatio 0.5;
1 c
// Advanced 2
nSmoothScale 4; 9*3
errorReduction 0.75; b
a
relaxed
{
maxNonOrtho 75;
}
}
minArea 1e-13;
minTetQuality 1e-30;
minTwist 0.05;
minDeterminant 0.001;
minFaceWeight 0.05;
minVolRatio 0.01;
minTriangleTwist -1;
//minVolCollapseRatio 0.5;
// Advanced
nSmoothScale 4;
errorReduction 0.75;
relaxed
{
maxNonOrtho 75;
}
}
minTwist 0.05;
f i .ci
minDeterminant 0.001; metric face,twist
minFaceWeight 0.05; f i ci
ci
minVolRatio 0.01;
bi
minTriangleTwist -1;
//minVolCollapseRatio 0.5;
fi
// Advanced
nSmoothScale 4;
errorReduction 0.75;
relaxed
{
maxNonOrtho 75;
}
}
minDeterminant 0.001; A Ai ti , j
Ai
faces
minFaceWeight 0.05; faces
minVolRatio 0.01;
ti , j
minTriangleTwist -1;
metriccell ,determinant / 0.03703
//minVolCollapseRatio 0.5;
A
// Advanced
nSmoothScale 4;
errorReduction 0.75;
relaxed
{
maxNonOrtho 75;
}
}
//minVolCollapseRatio 0.5;
// Advanced
nSmoothScale 4; ci
errorReduction 0.75; A
i
relaxed
{
bi
maxNonOrtho 75;
}
}
minArea 1e-13;
min(Vnei ,Vown )
minTetQuality 1e-30; metric face, volumeratio
minTwist 0.05;
max( Vnei ,Vown )
minDeterminant 0.001;
minFaceWeight 0.05;
minVolRatio 0.01;
minTriangleTwist -1;
//minVolCollapseRatio 0.5;
// Advanced
nSmoothScale 4;
errorReduction 0.75;
relaxed
{
maxNonOrtho 75;
}
}
minDeterminant 0.001;
metric face, triangle twist
minFaceWeight 0.05;
ab
minVolRatio 0.01;
minTriangleTwist -1;
a
//minVolCollapseRatio 0.5;
// Advanced
nSmoothScale 4;
errorReduction 0.75;
b
relaxed
{
maxNonOrtho 75;
}
}
minDeterminant 0.001;
because of poorly connected regions that
minFaceWeight 0.05;
may form
minVolRatio 0.01;
minTriangleTwist -1;
relaxed
{ //minVolCollapseRatio 0.5
maxNonOrtho 75;
}
}
minArea 1e-13;
The keyword errorReduction scales the
minTetQuality 1e-30;
displacement field locally where ther are
minTwist 0.05;
minDeterminant 0.001;
errors by the specified amount for each
minFaceWeight 0.05;
recovery iteration.
minVolRatio 0.01;
relaxed
{
maxNonOrtho 75;
}
}
minVol 1e-13;
As a guide to the importance of the
minArea 1e-13;
various mesh quality metrics a colour
minTetQuality 1e-30;
coding is used here. This varies from red
minTwist 0.05;
minDeterminant 0.001;
where it is important to satisfy the mesh
minFaceWeight 0.05;
quality metric settings to green where
minVolRatio 0.01; satisfying the metric may not be as critical
minTriangleTwist -1;
//minVolCollapseRatio 0.5;
// Advanced
nSmoothScale 4;
errorReduction 0.75;
relaxed
{
maxNonOrtho 75;
}
}
• Requirements:
OPENFOAM® mesh files in polyMesh folder(s)
Dictionary system/controlDict
Overall domain bounding box (-1.0 -1.0 -1.0) (1.0 1.0 1.0)
Bounding box dimensions
Mesh (non-empty, non-wedge) directions (1 1 1)
End
Summary of checks →
All failed written to sets
Copyright © 2012 Engys Ltd.
Meshing | Misc
• Surface Manipulation
surfaceCheck
surfaceTransformPoints
surfaceMeshTriangulate
• Mesh Manipulation
reconstructParMesh
renumberMesh (before using mesh)
topoSet with splitMeshRegions for CHT
transformPoints