CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   problems with snappyHexMesh (

StSchiff August 6, 2010 06:03

problems with snappyHexMesh
4 Attachment(s)
I want to mesh a surface mounted cube in a channel with snappyHexMesh, but since I'm still quite new to snappy I'm unsure about the settings. I started by setting
CastellatedMesh true;
snap false;
addLayers false;
The result (CubeMesh.jpg) looks fine to me so far.
Then I changed the setting to:
CastellatedMesh true;
snap true;
addLayers false;
and the result (CubeMeshSnap.jpg) looks strange to me.
So I tried adding the layers without the snap step:
CastellatedMesh true;
snap false;
addLayers true;
The result (CubeMeshLayers.jpg) looks even worse than without the layers. So I decided to switch the snap step on again:
CastellatedMesh true;
snap true;
addLayers true;
The results (CubeMeshLayersSnap.jpg) looks better than the 3rd result but there are still some weird looking cells.

Can someone give me a hint how to produce a better result with snappy?


Mo-ITB August 6, 2010 07:38

Hi Stefanie,

do you use a stl-file for the cube or are the outer boundaries containing the block definded by blockMesh?
In this case there would be no need to snap.


Mo-ITB August 6, 2010 07:44

if you watch your mesh with paraview try to make a threshold ( filters -> alphabetical -> extract cells by region) instead of a plane to prevent cells from being cut. then it might look better.

StSchiff August 6, 2010 08:01

Hi Moritz,

I'm using an stl file for the cube and the channel walls. But I might try putting the cube and the walls into the bounding box. That would mean I don't need an stl file at all, right? But then how do I add the layers to the cube? Or the refinement at the walls?

With the threshold the mesh looks a log better, thanks for the hint!


Mo-ITB August 6, 2010 08:43

Hi Stefanie,

snappy first snaps the stl out of the volume defined by the bounding box.
the refinement can be done for all patches and surfaces you define.

in snappyHexMeshDict you can do this:

- in the dictionary geometry you can define surfaces. here the patch-name of the stl-surface which is snapped, is defined. also closed surfaces like boxes (searchableBox) or cylinders (searchableCylinder) are defined here.

-in the dictionary refinementSurfaces you can define which ones should be refined how fine.

- in the dictionary refinementRegions the same, here you can chose outside/inside (for closed surfaces like boxes) or distance (for all).

- in the dictionary addLayersControls you can chose which patches should get layers.

in the motorbike tutorial there is snappyhexmeshdict which helped me alot.


DudaAPD August 7, 2010 11:17

I am also having problems with snappyHexMesh. It seems to work well untill it displays this message (after a good while):

keyword relativeSizes is undefined in dictionary "::addLayersControls"

file: ::addLayersControls from line 249 to line 324.

From function dictionary::lookupEntry(const word&, bool, bool) const
in file db/dictionary/dictionary.C at line 388.

FOAM exiting

I checked 3 times my setup against the motorbike tutorial and it is quite the same. Any ideas what the problem can be?

Thank you very much

StSchiff August 9, 2010 02:53

Hi DudaAPD,

can you post your snappyHexMeshDict file? Did you set the variable relativeSize in the addLayersControl subdictionary?


DudaAPD August 9, 2010 11:11

Dear Stefanie,

I managed to solve the problem. Thank you very much for time.


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