# How to Add Boundary Layers in SnappyHexMesh

@Runmin ZHAO  July 26, 2018

To well capture the properties of fluid near boundaries, the high quality layered mesh should be taken care of.

# Enable Layering

To enable the layering functionality, set the addLayers option to true in the snappyHexMeshDict.

FoamFile
{
version     2.0;
format      ascii;
class       dictionary;
object      snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// Which of the steps to run
castellatedMesh true;
snap            true;
addLayers       true;

In the addLayersControls section, call the patches where you want to add layers, and determine how many layers(nSurtaceLayers) you want.

addLayersControls
{
...
layers
{
wall      //The patch name
{
nSurfaceLayers 3;  //The number of layers
}
}

...
}


# How the layers grow

Since the number of layers is given, we should tell snappyHexMesh how we want the layers to grow and thickness values should be assigned.

addLayersControls
{
...
relativeSizes true
expansionRatio 1.2;
finalLayerThickness 0.5; //or thickness or firstLayerThickness
...
}


There are different methods to specify the thickness values:

• expansionRatio and finalLayerThickness
• expansionRatio and firstLayerThickness
• expansionRatio and thickness, thickness representing the overall thickness of the layers

But snappyHexMesh does not necessarily follow the thickness values you manually set if you set the relativeSizes option to true when snappyHexMesh would define the final layer thickness and minimum thickness being relative to the background spacing. The advantage is the smooth transition from layers to volume mesh while the disadvantage is the thickness distribution of the layers would be out of control and the layers would seem distorted.

Under such circumstances, uniform surface refinement is needed to devote to a uniform boundary layer, while the layer thickness is still not controlled by you.

If you set the relativeSizes option to false, then the preset layer thickness is guaranteed, but you would also come across problems like the sudden transition from fine layered mesh to coarse volume mesh. A good way to cope with this problem is to use the help of distance mode surface refinement.

# How the layers collapse

addLayersControls
{
...
minThickness 0.1
featureAngle 45

...
}

There are certain circumstances when layers are automatically collapsed.
When the overall thickness of the layer is less than a preset minThickness, certain parts of the layers may collapse to protect the cell shapes and mesh quality.
When the angle between the two surfaces is larger than the parameter featureAngle value, the mesh will collapse in the corner. Increase the value to prevent collapsing.

# Summary

• If you want convenience, set relativeSizes to true, use uniform surface refinement and larger featureAngle
• If you want the accurate thickness of the layers, especially the first layer, set relativeSizes to false, use distance mode surface refinement and adjust the thickness values.