snappyHexMesh

"...The snappyHexMesh utility generates 3-dimensional meshes containing hexahedra (hex) and split-hexahedra (split-hex) automatically from triangulated surface geometries in Stereolithography (STL) format. The mesh approximately conforms to the surface by iteratively refining a starting mesh and morphing the resulting split-hex mesh to the surface. An optional phase will shrink back the resulting mesh and insert cell layers. The specification of mesh refinement level is very flexible and the surface handling is robust with a pre-specified final mesh quality. It runs in parallel with a load balancing step every iteration..."

OpenFOAM User Guide

STL

The geometry stl file should be of good quality because it will be the reference surface for the snapping process. Expecially if there are curved surfaces, they will be jagged following the trace of stl file. If they are provided specific thickening to a particular surface of geometry, is recommended to define specific patch in stl file, this patch can be recognized and imported in snappyHexMeshDict file. The stl must be in constant/triSurface directory, in ASCII format and should be like this

solid patch1

facet normal ni nj nk outer loop vertex v1x v1y v1z vertex v2x v2y v2z vertex v3x v3y v3z endloop endfacet

endsolid

solid patch2

facet ...

...

endfacet

endsolid

blockMesh

After stl creation is necessary to create the reference hexaedra mesh with blockMesh utility. This will be the "raw piece of rock" modelled by the sculptor (snappyHexMesh in this case) following the geometry described in stl files. The dimension of these blocks is the reference dimension (corresponding to 0 levels of refinement), starting from this it is possible to calculate the minimum cell size. The block can contain the whole stl surface, or you may decide to make it smaller in order to cut the geometry, it depends also on the type of mesh, internal or external.

The blockMeshDict file must be in constant/polyMesh directory and the blockMesh process can be started by typing blockMesh in the main folder of the case. It creates all mesh files (boundary, owner, points, ecc ecc) in constant/polyMesh directory.

snappyHexMesh is designed to work properly on base elements with unitary aspect ratio, despite this it is possible to operate on slightly stretched cells.

However in order to obtain elongated elements, the best procedure is to snap on unitary aspect ratio cells and then stretch with transformPoints utility (as in wigleyHull tutorial of OpenFOAM).

snappyHexMesh

Obviously is the main process of snappyHexMesh utility, it can be launched by typing snappyHexMesh in the main folder of the case and read the command and parameters contained in snappyHexMeshDict file, located in system folder. It creates three (or less) time directories (according to the step time set in controlDict file), in the first there is the castellated mesh, in the second you can find the result of snapping process and in the last directories the program adds the layers to the snapped mesh.

Options

Usage: snappyHexMesh [-overwrite] [-parallel] [-case dir] [-help] [-doc] [-srcDoc]

-overwrite: with this option the process doesn't create three folders but overwrite the new mesh files on the olders contained in constant/polyMesh

-parallel: with this option snappyHexMesh can run in parallel on more than one processor (first the blockMesh must be decomposed with decomposePar)

paraView

As usual, with paraView (automatically installed with the ThirdParty software of OpenFOAM) is possible to see the results.

Remember that snappyHexMesh will create three folders and you have to choose the right step to visualize.