snappyHexMesh in BARAM

baramMesh is a program that uses snappyHexMesh to generate meshes.

This section explains how the various settings and execution of baramMesh drive snappyHexMesh.

1. Geometry

When you import a geometry using “Import” or create one using “Add,” a volume and a surface are generated; you then specify the type for each of these.

Type of volume

  • Select None or cellZone
  • For cellZone, set as faceZone in surface of castellatedMeshControls.refinementSurfaces

Type of surface

  • Select None, Boundary or Interface(with Non-Conformal and Inter-Region option)
  • Set as faceType in surface of castellatedMeshControls.refinementSurfaces
    • None : Internal
    • Interface
      • Non-conformal : boundary
      • Conformal : baffle
//snappyHexMeshDict
...
refinementSurfaces
{
cellZone_surface
{
faceZone cellZone_surface;// if None, this line is omiited
faceType boundary;
patchInfo
{
type patch;
}
level (0 0);
}
...

feature line

When reading an STL file or adding an object, use vtkFeatureEdges of vtk to generate feature lines → Save as an OBJ file in the constant/triSurface folder


2. Regions

To define a region, you can either enter coordinates directly within the region, move the pointer with the mouse, or select a volume. In all cases, the coordinates of a single point are obtained.

Since snappyHexMesh does not have a function to create regions, you should first create the region as a cellZone and then use OpenFOAM utilities and the cellZones to divide it into a multi-region mesh during export.

  • Set point coordinate to castellatedMeshControls.locationInMesh
  • For multi-region, it is used in the insidePoint field of the topoSetDict file to convert the section set to region into a cellZone.
//topoSetDict
...
{
name Region_1;
type cellSet;
action new;
source regionToCell;
insidePoints ((-2.28338 -0.46829 -1.36195));
}
...

3. Base Grid

Numbers in Grid Span

  • The numbers displayed represents the size of the bounding box for the entire geometry; the actual base grid uses a value that is 0.1% larger than this, but if the “use Hex6” option is selected, the displayed value is used as-is.
  • Set to vertices in blockMeshDict

Number of Cells per Direction

  • Set to blocks blockMeshDict
//blockMeshDict
vertices
(
(-0.200286 -0.299694 -0.300286)
(0.800286 -0.299694 -0.300286)
(0.800286 0.299694 -0.300286)
(-0.200286 0.299694 -0.300286)
(-0.200286 -0.299694 0.300286)
(0.800286 -0.299694 0.300286)
(0.800286 0.299694 0.300286)
(-0.200286 0.299694 0.300286)
);
blocks
(
hex (0 1 2 3 4 5 6 7) (35 20 20) simpleGrading (1 1 1)
);

Run

  • Execute blockMesh utility

4. Castellation

These settings are used for the following properties of snappyHexMeshDict.

Configuration

  • Number of Cells between Levels : castellatedMeshControls.nCellsBetweenLevels
  • Feature Angle Threshold : castellatedMeshControls.resolveFeatureAngle
  • Keep Non-manifold Edges & Keep Open Edges : vtkFeatureEdges

Advanced

  • Max. Global Cell Count : castellatedMeshControls.maxGlobalCells
  • Max. Local Cell Count : castellatedMeshControls.maxLocalCells
  • Min. Refinement Cell Count : castellatedMeshControls.minRefinementCells
  • Max. Load Unbalance : castellatedMeshControls.maxLoadUnbalance
  • Allow Free Standing Zone Faces : castellatedMeshControls.allowFreeStandingZoneFaces

Surface/Feature Refinement

  • Surface Refinement
    • Minimum Level : castellatedMeshControls.refinementSurfaces – <surface name> – first number of level
    • Maximum Level : castellatedMeshControls.refinementSurfaces – <surface name> – second number of level
  • Feature Edge Refinement Level : castellatedMeshControls.features – <feature name> – level
  • Curvature Refinement : castellatedMeshControls.refinementSurfaces – <surface name> – curvatureLevel
    • Number of Cells per Radius of Curvature : first number of curvatureLevel
    • Maximum Cell Levels : third number of curvatureLevel
    • Do not refine sharp surface : fourth number of curvatureLevelif off, set to 0
      • Minimum Radius of Curvature : fourth number of curvatureLevel – if on, size level for the curvature
    ...
propeller
{
patchInfo
{
type patch;
}
level (2 2);
curvatureLevel (10 0 7 1);
}
...

Volume Refinement

  • Volume Refinement Level : castellatedMeshControls.refinementRegions – <volume name> – levels, second number
  • Gap Refinement : castellatedMeshControls.refinementRegionsgapLevel
    • Min. Cell Layers in a gap : first number of gapLevel
    • Gap Detaction Start Level : second number of gapLevel
    • Max. Refinement Level : third number of gapLevel
    • Direction : gapMode
    • Include surface’s own gap : gapSelf
  • Level Increment : castellatedMeshControls.refinementRegionslevelIncrement
    • Split Count per Direction – x, y, z : third tuple of levelIncrement
    • Min. Level : first number of levelIncrement
    • Max. Level : second number of levelIncrement
    ...
volumeName
{
mode inside;
levels ((1000000000000000.0 1));
gapLevel (4 1 3);
gapMode mixed;
gapSelf true;
levelIncrement (0 10 (1 0 0));
}
...

Run for Single region

  • Set only castellatedMesh to true and run snappyHexMesh

Run for Multi-region

  • Set only castellatedMesh to true and run snappyHexMesh
  • Inter-Region Interface의 faceType은 baffle(conformal일 때) 혹은 boundary(non-conformal일 때)로, Inter-Region이 아닌 Interface의 faceType을 internal로 주고 snappyHexMesh 실행
    • Region이 아닌 cellZone 내부 영역에 격자가 만들어지지 않는 것을 방지하기 위해 internal로 설정

5. Snap

snapControls에서 설정

  • Interation Count
    • Smoothing for Surface : nSmoothPatch
    • Smoothing for Internal : nSmoothInternal
    • Mesh Displacement Relaxation : nSolveIter
    • Snapping Relaxation : nRelaxIter
  • Feature Snapping
    • Snapping Relaxation : nFeatureSnapIter
    • Feature Snap Type : implicitFeatureSnap
    • Multi-surface Feature Snap : multiRegionFeatureSnap
  • Tolerance : tolerance
  • Concave Angle : concaveAngle
  • Min. Area Ratio : minAreaRatio
  • Buffer Layer : solver – displacementPointSmoothing
    • Point Smoothing Method : displacementPointSmoothingCoeffs.pointSmoother
    • Number of Point Smoother Iteration per Time step : displacementPointSmoothingCoeffs.nPointSmootherIter
    • GETMe Transformation Parameter : displacementPointSmoothingCoeffs.transformationParameter
snapControls
{
nSmoothPatch 1;
nSmoothInternal 0;
tolerance 3;
nSolveIter 30;
nRelaxIter 5;
implicitFeatureSnap false;
explicitFeatureSnap true;
nFeatureSnapIter 15;
multiRegionFeatureSnap no;
concaveAngle 45;
minAreaRatio 0.3;
solver displacementPointSmoothing;
displacementPointSmoothingCoeffs
{
pointSmoother geometricElementTransform;
nPointSmootherIter 10;
transformationParameter 0.667 ;
}
}

Single region일 때 실행

  • snap 만 true로 주고 snappyHexMesh 실행

Multi-region일 때 실행

  • Inter-Region이 아닌 interface의 faceType을 internal로 주고 snappyHexMesh를 실행
  • topoSet
    • 각 region의 locationInMesh Point를 topoSet의 insidePoints로 사용해 각 리전을 셀존으로 나눈다
  • Inter-Region이 아닌 interface가 있을 때, 이 Interface들의 faceType을 baffle(conformal일 때) 혹은 boundary(non-conformal일 때)로 변경하고 snappyHexMesh를 “*-*overwrite” 옵션과 함께 실행
//topoSetDict
actions
(
{
name Region_1;
type cellSet;
action clear;
}
{
name Region_1;
type cellSet;
action new;
source regionToCell;
insidePoints ((-2.28338 -0.46829 -1.36195));
}
{
name Region_1;
type cellZoneSet;
action new;
source setToCellZone;
sourceInfo
{
set Region_1;
}
}
{
name Region_2;
type cellSet;
action clear;
}
{
name Region_2;
type cellSet;
action new;
source regionToCell;
insidePoints ((0 0 0));
}
{
name Region_2;
type cellZoneSet;
action new;
source setToCellZone;
sourceInfo
{
set Region_2;
}
}
);

6. Boundary Layer

addLayersControls에서 설정

Configurations

layers.<boundary name>의 설정

  • Number of Layers : nSurfaceLayers
  • Thickness Model Specification : thicknessModel
  • Size Specification : relativeSizes
  • First Layer Thickness : firstLayerThickness
  • Expansion Ratio : expansionRatio
  • Min. Total Thickness : minThickness
  • Final Layer Thickness : finalThickness
  • Total Thickness : totalThickness
  layers
{
propeller
{
nSurfaceLayers 3;
thicknessModel firstAndExpansion;
relativeSizes on;
expansionRatio 1.2;
firstLayerThickness 0.3;
minThickness 0.3;
}
}

Advanced Configurations

  • Number of Grow : nGrow
  • Static Analysis of Starting Mesh
    • Feature Angle Threshold : featureAngle
    • Max. Thickness Ratio : maxFaceThicknessRatio
  • Patch Displacement Smoothing
    • Number of Iterations : nSmoothSurfaceNormals
    • Smooth Layer Thickness : nSmoothThickness
  • Medial Axis
    • Min. Axis Angle : minMedialAxisAngle
    • Max. Thickness Ratio : minThickness
    • Number of Smoothing Iter. : nSmoothNormals
    • Max. Snapping Relaxation Iter. : nRelaxIter
  • Mesh Shrinking
    • Num. of Buffer Cells : nBufferCellsNoExtrude
    • Max. Layer Addition Iter. : nLayerIter
    • Max. Iter. Before Relax : nRelaxedIter
addLayersControls
{
layers
{
}
nGrow 0;
featureAngle 60;
maxFaceThicknessRatio 0.5;
nSmoothSurfaceNormals 1;
nSmoothThickness 10;
minMedialAxisAngle 90;
maxThicknessToMedialRatio 0.3;
nSmoothNormals 3;
nRelaxIter 10;
nBufferCellsNoExtrude 1;
nLayerIter 50;
nRelaxedIter 20;
thicknessModel finalAndExpansion;
relativeSizes on;
finalLayerThickness 0.5;
expansionRatio 1.2;
minThickness 0.3;
}

실행

  • addLayers 만 true로 주고 snappyHexMesh 실행

7. Export

Export as BaramFlow project

  • Single region mesh 일 때
    • topoSet 실행 – cellZone을 만드는 과정
    • createPatch 실행
  • Multi-region mesh 일 때
    • splitMeshRegions -cellZoneOnly 실행
    • topoSet 실행 – cellZone을 만드는 과정
      • region 생성을 위해 만들었던 셀존은 삭제하고 사용자가 설정한 셀존을 생성
    • createPatch 실행
//topoSetDict file
actions
(
{
name cube;
type cellSet;
action clear;
}
{
name cube;
type cellSet;
action new;
source surfaceToCell; //boxToCell; cylinderToCell; sphereToCell;
file "constant/triSurface/cube.stl";
useSurfaceOrientation true;
includeInside true;
nearDistance -1;
curvature -100;
outsidePoints ();
includeCut false;
includeOutside false;
}
{
name cube;
type cellZoneSet;
action new;
source setToCellZone;
sourceInfo {set cube;}
}
);

2D Plane

  • Boundary : extrudeMeshDict 파일의 sourcePatchesexposedPatchName에 사용
  • Thickness : extrudeMeshDict 파일의 thickness에 사용
  • 실행
    • extrudeMesh -region <regionName> -dict system/extrudeMeshDict
    • collapseEdges -overwrite 실행
//extrudeMeshDict
...
constructFrom patch;
sourceCase ".";
sourcePatches ( far_surface );
exposedPatchName far_surface;
extrudeModel plane;
flipNormals false;
mergeFaces false;
thickness 1;
...

Axi-symmetry

  • Source Boundary, P1 : extrudeMeshDict 파일의 sourcePatches에 사용
  • Exposed Boundary, P2 : extrudeMeshDict 파일의 exposedPatchName에 사용
  • Angle : extrudeMeshDict 파일의 wedgeCoeffs.angle에 사용
  • Axis origin : extrudeMeshDict 파일의 wedgeCoeffs.point에 사용
  • Axis direction : extrudeMeshDict 파일의 wedgeCoeffs.axis에 사용
  • 실행
    • extrudeMesh -region <regionName> -dcit system/extrudeMeshDict
//extrudeMeshDict
...
constructFrom patch;
sourceCase ".";
sourcePatches ( patchName );
exposedPatchName patchName-1;
extrudeModel wedge;
wedgeCoeffs
{
point (0 0 0);
axis (1 0 0);
angle 10;
}
flipNormals false;
mergeFaces false;
...