Overview

snappyHexMesh is a fully parallel, split hex, mesh generator that guarantees a minimum mesh quality. Controlled using OpenFOAM dictionaries, it is particularly well suited to batch driven operation.

Key features:

  • starts from any pure hex mesh (structured or unstructured)
  • reads geometry in triangulated formats, e.g. in stl, obj, vtk
  • no limit on the number of input surfaces
  • can use simple analytically-defined geometry, e.g. box, sphere, cone
  • generates prismatic layers
  • scales well when meshing in parallel
  • can work with dirty surfaces, i.e. non-watertight surfaces

Quick reference

Meshing process

The overall meshing process is summarised by the figure below:

snappyHexMesh overview

This includes:

  • creation of the background mesh using the blockMesh utility (or any other hexahedral mesh generator)
  • extraction of features on the surfaces with surfaceFeatureExtract utility
  • setting up the snappyHexMeshDict input dictionary
  • running snappyHexMesh in serial or parallel

Evolution of the snappy mesh for the iglooWithFridges tutorial is shown below:

Configuration

Meshing controls are set in the snappyHexMeshDict located in the case system directory. This has five main sections, described by the following:

  • Geometry: specification of the input surfaces
  • Castellation: starting from any pure hex mesh, refine and optionally load balance when running in parallel. The refinement is specified both according to surfaces, volumes and gaps
  • Snapping: guaranteed mesh quality whilst morphing to geometric surfaces and features
  • Layers: prismatic layers are inserted by shrinking an existing mesh and creating an infill, subject to the same mesh quality constraints
  • Mesh quality: mesh quality settings enforced during the snapping and layer addition phases
  • Global

Usage

The command snappyHexMesh executes the meshing process. Adding the -help option, i.e.

snappyHexMesh -help

returns the list of available options:


Usage: snappyHexMesh [OPTIONS]
Options:
  -case <dir>       Case directory (instead of current directory)
  -checkGeometry    Check all surface geometry for quality
  -decomposeParDict <file>
                    Alternative decomposePar dictionary file
  -dict <file>      Alternative snappyHexMeshDict
  -dry-run          Check case set-up only using a single time step
  -outFile <file>   Name of the file to save the simplified surface to
  -overwrite        Overwrite existing mesh/results files
  -parallel         Run in parallel
  -patches <(patch0 .. patchN)>
                    Only triangulate selected patches (wildcards supported)
  -profiling        Activate application-level profiling
  -region <name>    Specify alternative mesh region
  -surfaceSimplify <boundBox>
                    Simplify the surface using snappyHexMesh starting from a
                    boundBox
  -doc              Display documentation in browser
  -help             Display short help and exit
  -help-compat      Display compatibility options and exit
  -help-full        Display full help and exit

Automatic split hex mesher. Refines and snaps to surface

Using: OpenFOAM-2306 (2306) - visit www.openfoam.com
Build: _fbf00d6b-20230626
Arch:  LSB;label=32;scalar=64


By default, each of snappyHexMesh’s phases, i.e castellation, snapping and layer addition will write a complete mesh in time folders. This behaviour can be suppressed by using the option

snappyHexMesh `-overwrite`