Master the Layers: Optimizing snappyHexMesh for High-Fidelity Boundary Layers

Published by Ruggero Poletto on

In the world of OpenFOAM, generating a high-quality mesh is often 80% of the battle. While snappyHexMesh is incredibly powerful for snapping to complex geometries, getting those elusive, crisp boundary layers can feel like more of an art than a science.

If your layers are collapsing or looking “jagged” around sharp edges, it’s time to look deeper into the addLayersControls dictionary. Recently, I’ve been experimenting with a few specific parameters—featureAngle, nSmoothSurfaceNormals, and nSmoothNormals—and the results were eye-opening.

Understanding the Layer Generation Process

Before we dive into the numbers, let’s look at how snappyHexMesh actually builds layers. It doesn’t just “extrude” faces; it shrinks the existing mesh away from the patches and then inserts layers into the gap. This process requires significant smoothing to ensure the cells don’t warp or become “non-orthogonal.”

The Power Trio: Key Parameters Explained

Based on recent testing in a simplified flow case, I’ve found that pushing the default limits on these three parameters can significantly improve layer coverage and smoothness.

1. featureAngle

  • What it does: This defines the maximum angle between two faces where layers will still be added. If the angle between two neighboring face normals exceeds this value, the layer generation “gives up” to prevent self-intersection.
  • The Discovery: While many tutorials suggest 60° or 130°, I found that pushing this to 190 was a game-changer.
  • The Impact: By setting it above 180, you are essentially telling the mesh generator to be extremely aggressive in maintaining layers, even around sharp corners where it would typically terminate them.
featureAngle 150;
nSmoothSurfaceNormals 10;
nSmoothNormals 3;

2. nSmoothSurfaceNormals

  • What it does: This controls how many times the surface normals are smoothed before the mesh is retracted to make room for layers.
  • The Discovery: Increasing this to 50 (the default is often much lower, like 1).
  • The Impact: Smoothing the normals ensures that the “direction” the layer grows in is consistent. In my tests, this eliminated the “wavy” look of layers near geometry transitions, providing a much more uniform thickness.
featureAngle 190;
nSmoothSurfaceNormals 10;
nSmoothNormals 3;

3. nSmoothNormals

  • What it does: Similar to surface normals, this parameter smooths the internal mesh displacement normals.
  • The Discovery: A value of 10 provided the best balance.
  • The Impact: It prevents the internal hex cells from becoming distorted as the layers are pushed into the domain. Too much smoothing here can actually wash out the geometry, but at 10, it keeps the mesh transitions stable.
featureAngle 190;
nSmoothSurfaceNormals 50;
nSmoothNormals 10;

The Results: 190, 50, and 10

By using this specific combination—featureAngle 190, nSmoothSurfaceNormals 50, and nSmoothNormals 10—the boundary layer representation improved drastically.

ParameterTested ValueResulting Effect
featureAngle190Maximum layer continuity around sharp edges.
nSmoothSurfaceNormals50Superior surface normal consistency.
nSmoothNormals10Stable internal cell transition during retraction.

Pro-Tip: While these settings work wonders for simple cases, always keep an eye on your checkMesh results. High smoothing counts can slightly increase mesh generation time, but the payoff in CFD convergence and y+ accuracy is well worth it.

Conclusion

Mesh generation is a game of trade-offs. However, by being more aggressive with your smoothing and feature angles, you can force snappyHexMesh to respect the physics of the boundary layer rather than just the limitations of the initial grid.

Would you like me to help you format a snappyHexMeshDict snippet with these specific parameters for your next project?


CloudHPC is a HPC provider to run engineering simulations on the cloud. CloudHPC provides from 1 to 224 vCPUs for each process in several configuration of HPC infrastructure - both multi-thread and multi-core. Current software ranges includes several CAE, CFD, FEA, FEM software among which OpenFOAM, FDS, Blender and several others.

New users benefit of a FREE trial of 300 vCPU/Hours to be used on the platform in order to test the platform, all each features and verify if it is suitable for their needs


Categories: snappyHexMesh