CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Native Meshers: snappyHexMesh and Others (
-   -   Add Layers in snappyHexMesh (

shchepan December 9, 2010 12:29

Add Layers in snappyHexMesh
I have the problem with adding layers in snappyHexMesh.
My geometry is:

        type triSurfaceMesh;
        name topSurf;

        type triSurfaceMesh;
        name sideWall;

        type triSurfaceMesh;
        name botWall;

And I try to add layer:


    relativeSizes true;
            nSurfaceLayers 1;
    expansionRatio 1.0;
    finalLayerThickness 1.0;
    minThickness 0.9;
    nGrow 1;
    featureAngle 60;
    nRelaxIter 5;
    nSmoothSurfaceNormals 1;
    nSmoothNormals 3;
    nSmoothThickness 10;
    maxFaceThicknessRatio 0.5;
    maxThicknessToMedialRatio 0.3;
    minMedianAxisAngle 130;
    nBufferCellsNoExtrude 0;
    nLayerIter 50;

But no layer is created:


No layers to generate ...
Layer mesh : cells:835968 faces:2744876 points:1073627
Cells per refinement level:
0 163968
1 120336
2 551664
Writing mesh to time 10.015
Written mesh in = 69.17 s.
Finished meshing in = 403.37 s.
What should I do?

spatz June 17, 2012 02:39

Same problem: no layers added
2 Attachment(s)
This is my first post on these forums.

I am having more or less the same exact issue in trying to mesh a boundary layer region on a pipe made in FreeCAD. As the previous poster did (over a year ago) I have explicitly specified patches to add layers in the same way yet find no layers added and a message "No layers to generate ..."

Attached is my case file. I already have made .eMesh files for the edge snapping feature so it can be run by

tar xvzf SimplePipe-SAV02.tar.gz
cd SimplePipe-SAV02

Any suggestion on how to change snappyHexMeshDict will be appreciated. Obviously a lot of people have got this working so I'm sure it's something simple.

lovecraft22 June 17, 2012 06:23

Haven't ran you case but I'm pretty sure that if you look for "layers" within your sHM log file, you'll see that it's probably complaining about the patch WALL that is not found and it may suggest you to use WALL_patch0 instead.

So WALL_patch0 is what you should have in the layers section of your sHMDict.

spatz June 17, 2012 14:23

1 Attachment(s)

Thank you so much for your advice. That was exactly my problem. I'm almost there, just having a lot of trouble figuring out what parameter to tweak so the BL region will extend all the way to the inlet and outlet. Does someone know this off-hand?

Thanks for the help.


spatz June 17, 2012 14:55

Never mind my above post. I found a sufficient example here which should do fine.

Thanks again.

Rophys October 23, 2013 07:12

Hi all,

I am trying to add a layer in my geometry but I didn't manage to do it.
I already tried to change the patch name, run sHM using geometry in binary and ascii, etc. Could you have a look in my case and give some tip in how to properly add layers on it ? I tried to upload the case here but it's bigger than 97.7 kb. I can send it by email.

Thanks a lot.

Tobi October 23, 2013 07:17

Maybe I can have a look today evening.
  • Can you put your Output for the layer adding Phase ?

Rophys October 23, 2013 08:17

Hi Tobias,

Thanks for you quickly response. I tried to upload the out (just the layer part) here, but I got the message: "The text that you have entered is too long (68499 characters). Please shorten it to 20000 characters long".

I sent you the case anyway, you be able to see the output for the sHM.

Thanks again.

Tobi October 23, 2013 13:37

For all,

the problem was the OF version.
After starting sHM with 2.2.x everything works fine.

In OpenFOAM-2.1.x I realized that the layer thickness calculation in the beginning is a bit strange. To be sure you have to do the following steps:

1. sHMDict: castellated and snapping on // layer generation off
2. snappyHexMesh -overwrite
3. sHMDict: castellated and snapping off // layer generation on
4. snappyHexMesh -overwrite


Have Fun.

Rophys October 23, 2013 13:42

Yes, it's working perfectly with 2.2.x openFoam version.

Thanks Tobi. :D

hasanmas November 4, 2013 12:53


i am also having problems adding layers. i have tried changing many different parameters, but still i cant get the layers to grown. i am sure that i now have the write patch name!

i think its might be the geometry. the best way to describe it would be a flying carpet. a thin wall ( 1- 2 cm thick) but with waved surface. much more like a sail.

could you please help me with some tips or ideas how to solve the problem.

thank you!

Tobi November 4, 2013 14:48

what is the output of the layer generation?

lav April 29, 2015 01:01

Add layers in snappyHexMesh _realtive sizes vs absolute
Hi ,

I am running simulation using relative size as "false" in add layers.

I want the first layer thickness to be specific, so I happen to figure out with relative size as false but couldn't understand when set as true.

Please can you detail about how its meshed when it is set as "true". In some tutorials, I have found that its relative to the surface mesh size - -i.e., final layer thickness / surface mesh size. How do I calculate that? Is surface mesh size =Surface area / no of surface elements?

How to go about setting values for maxFaceThicknessRatio and maxThicknessToMedialRatio ?


Tobi April 29, 2015 05:29


check out the snappyHexMesh section in the wiki.
There is a good presentation from Engis. There you find the necessary stuff.

pagru April 29, 2015 10:39

Hi everybody,

I'm also having a problem in the layers section of sHM.

In my volume mesh I have two neighbouring regions of different cell density (lets say: R1 and R2), where R2 is twice as dens as R1. (e.g. R1 -> 20 mm cell length; R2 -> 10 mm cell length)

Both regions are bordering a solid wall where boundary layers shall be applied.

The entry "finalLayerThickness" is set to 0.4.
5 Layers shall be applied at the wall.
Since finalLayerThickness is calculated relative to the last cell of the volume mesh, i get boundary layers of different height.

To avoid this, I want to set an override for the finalLayerThickness in region R2. That way, the final layer of both regions has the same height and since the expansion ratio is constant, the remaining cells of the layer will also evolve equally.

THE PROBLEM: I heard that an override for fLT can be set in the layers part like that:

R1 {nSurfaceLayers5;}
R2 {nSurfaceLayers5; finalLayerThickness 0.8;}

expansionRatio 1.25;

finalLayerThickness 0.4;

Unfortunately, during the run of sHM it says that the expression of the override in brackets is "ill defined".
Did anybody encounter a similar problem or has any suggestions to solve this?

Many thanks in advance!

lav May 5, 2015 01:19

Hi ,
It should look like the following.

relativeSizes true;
expansionRatio 1.0;
finalLayerThickness 0.3;
minThickness 0.25;

nSurfaceLayers 1;

nSurfaceLayers 1;

expansionRatio 1.3;
finalLayerThickness 0.3;
minThickness 0.1;

nSurfaceLayers 0;

//Advanced settings


pagru May 11, 2015 09:19

Thank you very much, i will try that as soon as possible.

However, i tried adding a value for finalLayerThickness directly in the 'layers' section, e.g.:

geoBody (nSurfaceLayers 5; finalLayerThickness 0.8)

expansionRatio 1.25;

finalLayerThickness 0.4;

This works fine for my problem.


probpst November 20, 2015 04:15

How can get the connectivity of Boundary Layer in different Dense of mesh using snapp
Hello guys.

This is the first time to me writing some letter about OpenFOAM.

Any way, in these days, using snappyHexMesh, I have calculated the vessel of KCS with multiphase flow.

But, I don’t know how can I put the layer mesh around the hull well.

Especially, if the Dense of grid is differ from other region(As different Level of refinementRegions)

Then, the boundary layer mesh is just cutting out. I can’t give it the connectivity of layer.

Also, if the surface normal vector is changing suddenly, or something like vessel’s Bulbosbow,

The Boundary layer is also just stopped. Not connected across the surface.

Please check the below picture which is the best snappyHexMeshing for me yet…

Using STAR-CCM, making Grid more easier just like below picture.
Boundary prism layer is well inserted. But, you know Star-CCM is very expensive.
OpenFOAM is Free

Actually, with the current snappyHexMesh, the result of hull’s resistance
is almost correct (1.5 % Error by Experiment Result)
But I still want to find the way how can I make the more stable Grid.

If any one who know the way or get some experience, please give me some tip.
Thank you. ^-^/~

All times are GMT -4. The time now is 13:47.