v2312: New and improved pre-processing

snappyHexMesh: writing faces from the automatic leak path closure


snappyHexMesh has an option to automatically close any surface leaks, defined as a path between any location inside the mesh and location outside the mesh. In this release the faces used to close the leak are written to a file in the postProcessing directory.

The figure below shows a test case comprising a sphere with a gap (in grey), snapped mesh lines (in blue) and the leak closure faces (in red):

The file write format can be chosen with a new entry in the snappyHexMeshDict:

//// Format for writing lines. E.g. leak path. Default is vtk format.
//setFormat ensight;

//// Format to use for surfaces. E.g. leak-closure faces. Default is vtk format.
//surfaceFormat vtk;


Source code

snappyHexMesh: new multiple inside points


Cell zones in snappyHexMesh can be created by providing an insidePoint:

    cellZoneInside insidePoint;    // outside/insidePoint
    insidePoint    (1 1 1);        // if (cellZoneInside == insidePoint)

Instead of a single insidePoint there is now provision for multiple insidePoints:

cellZoneInside insidePoints;      // outside/insidePoint
insidePoints   ((1 1 1));         // if (cellZoneInside == insidePoint)

In the figure below, the geometry consists of two boxes (in wireframe) where the top box covers two disconnected mesh regions. The cellZone shown in red has been created using three separate mesh regions. The checkMesh utility can be used to show disconnected regions - however not split by cellZone.


Source code

snappyHexMesh: parallel meshing load balancing


snappyHexMesh can automatically balance the mesh when running in parallel. It will either

  • not balance if the change was too small - see maxLoadUnbalance or maxCellUnbalance settings; or
  • refine and then balance or balance before refinement - see the maxLocalCells setting.

In this release at every step the mesh unbalance will be printed:

Layer mesh : cells:353749  faces:1108448  points:406303  unbalance:0.00110248

Note that balance-before-refine is implemented by supplying cell weights. Each cell-to-be-refined counts for 8. This, however, only works well for simple decomposition methods, e.g. hierarchical. The scotch and KaHip methods minimise any unbalance using a weight which also includes the number of cuts made.


  • any parallel snappyHexMesh case

Source code

Related issues

snappyHexMesh: layer-by-layer addition


The OpenFOAM v2206 release extended snappyHexMesh to add layers in multiple passes using the nOuterIter entry. Here, we'd like to demonstrate how you can perform improved layer addition using the $FOAM_TUTORIALS/incompressible/pisoFoam/LES/motorBike/motorBike tutorial as a starting point:

relativeSizes false; // true

// Per final patch (so not geometry!) the layer information
        nSurfaceLayers 16;

// Expansion factor for layer mesh
expansionRatio 1.2;

The important settings are the number of outer iterations and the mesh motion solver:

// Overall max number of layer addition iterations
nLayerIter      25;

// Add layers in multiple passes - gives layers a chance to rotate
nOuterIter      4;

meshShrinker    displacementMotionSolver;
solver          displacementLaplacian;
    diffusivity quadratic inverseDistance (lowerWall upperWall "motorBike*")

With the mesh quality criteria loosened (while retaining decent overall mesh quality) the layer coverage can be dramatically increased even on this complex geometry.



Source code

Improved Nastran surface reader


The NASTRAN parser has been updated to accommodate newer ANSA conventions for PSHELL names. This allows direct use of NASTRAN files in more places, e.g. in snappyHexMesh.

Source code


Improved checkMesh utility


The checkMesh utility now includes a writeChecks option:

checkMesh -writeChecks <format>

This will generate a file containing the mesh checks using the format:

  • dictionary : OpenFOAM dictionary;
  • json : JSON format.

For example, using the commands

checkMesh -allGeometry -allTopology -writeChecks json

the motorBike tutorial yields a checkMesh.json file in the case directory, containing:

    "maxNonOrth" : 64.9999,
    "aveNonOrth" : 9.92427,
    "maxSkew" : 9.25719,
    "nWarnSkew" : 12,
    "minDeterminant" : 0,
    "aveDeterminant" : 1.55371,
    "thresholdDeterminant" : 0.001,
    "nErrorDeterminant" : 1274,
    "minFaceWeight" : 0.0216708,
    "aveFaceWeight" : 0.465687,
    "thresholdFaceWeight" : 0.05,
    "nErrorFaceWeight" : 1143,
    "minFaceVolumeRatio" : 0.0101126,
    "aveFaceVolumeRatio" : 0.846049

Source code

Improved subsetMesh utility


The subsetMesh utility has been updated to accept an -exclude-patches option to modify the regular -patches selection.

This modification simplifies the specification of nearest exposed patches.