OpenFOAM SnappyHexMesh Tutorial
OpenFOAM SnappyHexMesh Tutorial
Jukka-Pekka Keskinen,
Ville Vuorinen & Martti Larmi
Aalto University
School of Science and Technology
Internal Combustion Engine Research Group
Finnish OpenFOAM Users Day
22nd April 2010
Our Motivation for Using snappyHexMesh
snappyHexMeshDict dictionary:
If one is not satised with the mesh after the snapping phase,
additional surface layers can be added.
The earlier phases of SHM will have created patches from the
input geometries so these can be used.
Layer addition does not work properly near the limits of the
input surface.
s
s
s
s
s
s
s
s
s
s
s
s
s
Final Comments on snappyHexMesh
+ Able to produce meshes for complex geometries with small
eort
+ Plenty of controls to play with
+ Open and free
- Poor documentation and thus the eects of some controls
remain unclear
- Diculties with sharp edges
Bibliography, Sources, Additional Material and
More Information on SnappyHexMesh
Tutorials in tutorials/mesh/snappyHexMesh/.
When set to the interval [4, 12], cell splitting and snapping
phases are performed but snapping produces poor results.
When set to the interval [13, 43], cell splitting and snapping
phases are performed with reasonable results.
When set to [44, 180], all of the phases are performed. The
quality control is disabled when set to 180.
Highest values that still allow surface layer addition are 1.10
and 0.45 respectively.
Some Statistics (Acquired with checkMesh
Mesh Splitting Snapping Layers
No. of cells 1 280 8 880 8 880 13 896
Hex cells 1 280 7 680 7 680 11 808
Prism cells 0 0 0 800
Polyhedral cells 0 1 200 1 200 1 288
Min. vol. (m
3
) 3.91 10
3
6.10 10
5
6.10 10
5
4.14 10
5
Max. vol. (m
3
) 3.91 10
3
3.91 10
3
3.91 10
3
3.69 10
3
Tot. vol. (m
3
) 5.00 4.06 3.92 3.91
NB: The volume of the input cylinder is 3.93 m
3
.
The Used blockMeshDict, part 1
convertToMeters 1;
vertices
(
( 0 0 0 ) ( 1 0 0 ) ( 1 1 0 ) ( 0 1 0 )
( 0 0 5 ) ( 1 0 5 ) ( 1 1 5 ) ( 0 1 5 )
);
blocks
(
hex (0 1 2 3 4 5 6 7) (8 8 20) simpleGrading (1 1 1)
);
edges
();
The Used blockMeshDict, part 2
patches
(
patch in ( (0 1 2 3) )
patch out ( (7 6 5 4) )
wall right ( (2 6 5 1) )
wall left ( (3 7 4 0) )
wall up ( (2 6 7 3) )
wall down ( (4 5 1 0) )
);
mergePatchPairs
();
Geometry Entries
geometry {
pipe {
type searchableCylinder;
point1 (0.5 0.5 -1);
point2 (0.5 0.5 6);
radius 0.5; }
innerPipe {
type searchableCylinder;
point1 (0.5 0.5 0);
point2 (0.5 0.5 5);
radius 0.1; }
};
Entries of castellatedMeshControls
castellatedMeshControls {
maxLocalCells 1000000;
maxGlobalCells 2000000;
minRefinementCells 0;
nCellsBetweenLevels 1;
refinementSurfaces {
pipe { level (2 1); } }
refinementRegions {
innerPipe {
mode inside;
levels ((1 2)); } }
resolveFeatureAngle 20;
locationInMesh (0.54 0.52 0.16);
features (); }
The used snapControls entry
snapControls
{
nSmoothPatch 6;
tolerance 10;
nSolveIter 60;
nRelaxIter 10;
}
The Used addLayersControls Entry
relativeSizes true;
layers { "pipe_region0" {
nSurfaceLayers 3; } }
expansionRatio 2;
finalLayerThickness 0.5;
minThickness 0.05;
nGrow 1;
featureAngle 60;
nRelaxIter 5;
nSmoothSurfaceNormals 1;
nSmoothNormals 3;
nSmoothThickness 10;
maxFaceThicknessRatio 0.5;
maxThicknessToMedialRatio 0.3;
minMedianAxisAngle 130;
nBufferCellsNoExtrude 0;
nLayerIter 50;
The Used meshQualityControls Entry
meshQualityControls
{ maxNonOrtho 65;
maxBoundarySkewness 20;
maxInternalSkewness 4;
maxConcave 80;
minFlatness 0.5;
minVol -1e13;
minArea -1;
minTwist 0.05;
minDeterminant 0.001;
minFaceWeight 0.05;
minVolRatio 0.01;
minTriangleTwist -1;
nSmoothScale 4;
errorReduction 0.75; }
A Slice of the Cylinder at 2 Original Cell Lengths
(0.5 m) from the End
A Slice of the Cylinder at 1/5 Original Cell
Lengths (0.05 m) from the End