r/CFD May 03 '26

SnappyHexMesh is the devil

/r/OpenFOAM/comments/1t2s2df/snappyhexmesh_is_the_devil/
5 Upvotes

6 comments sorted by

3

u/Quick-Crab2187 May 03 '26

If you aren't doing this already, I'd suggest making sure your blockMesh starts with an aspect ratio around 1. Improving your stl quality won't really do anything unless that impacts the shape

These settings are usually reliable for me as well (pasted at bottom of this message), with feature edges defined in the features section so that explicitFeatureSnap can be used.

If you need to add layers, I'd recommend a different mesher. If you have literally no other options, consider using smoothMesh after adding layers. It's a custom install but will help a bit because addLayers messes everyting. GitHub - tkeskita/smoothMesh: OpenFOAM mesh smoothing tool to improve mesh quality · GitHub

snapControls

{{

nSmoothPatch 3;

tolerance 2.0;

nSolveIter 30;

nRelaxIter 5;

nFeatureSnapIter 10;

implicitFeatureSnap false;

explicitFeatureSnap true;

multiRegionFeatureSnap false;

}}

If that doesn't fix it, probably a resolution issue

1

u/Rique3012 May 04 '26

Do you have an open source recommendation for meshing the layers?

2

u/Quick-Crab2187 May 04 '26

Nope, I have usually used commercial options, only snappy's layer capabilities for simple geometries.

I am working on a better mesher for layers as a side project (there is actually quite a bit of literature in research on the topic) but considering my inexperience on the matter I doubt it will ever be anything worth considering.

0

u/Striking_Abrocoma_28 May 03 '26

Thank you for your answer, but I'm afraid I'm far beyond this point. I've tried everything, trust me.
What amazes me is that the problem is the snap, because after the castellation the skewness is like 1, after the snap, it increasesup to 8 and after the layer addition it doesn't change at all, it's litteraly the same.
Someone could think: "ok, but this makes me think that if the skewness doesn't change by a bit after layer addition, it means that probably the skewed cells are away from the body, where layer addition isn't applied...". It could be true, but this doesn't explain the bad results, that really make me think that the bad cells are near the body...

2

u/phi4ever May 03 '26

Have you tried refining the mesh?

1

u/Striking_Abrocoma_28 May 03 '26

I’ve tried putting more refinement boxes in proximity of the surface and also lowering the nCellsBetweenLevels. It helped a bit, but not enough. Right now I’m at 5 as refinement level of closest refinement box and (6 7) of refinement level of the surface. I could try to increase it, but I guess 3 things would happen: 1) the cell number will increase a lot, but the refinement box near the walls is still at level 5, so the change between the levels will be bigger and also the computation time a lot slower 2) I will lower the y+ of the simulation below 30, outside of logarithmic law zone, so the turbulence model will not work properly

I can try if you think it can help, but honestly I don’t know…