CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Mesh Utilities (
-   -   SnappyHexMesh (

erik023 September 10, 2008 05:56

dear all, thank you for help w
dear all, thank you for help with my last Q. now i have another:
i have created a .stl file, in 3D, and i like to try the snappyHexMesh.

what do i need to do?
i do not find the user manual in 1.4.1 sufficient for me to get the whole thing working.
what files do i need to create and how do i order thm, in what catalog structure i mean?
has anybody a simple example i could use? a snappyHexMeshDict file!?
i would like to do some multiphase simulations on my .stl geometry

thankful for help!
erik ekedahl

aunola September 10, 2008 06:31

I doubt you will find any usef
I doubt you will find any useful information on snappyHexMesh in the 1.4.1 manual as it was released only in 1.5. Before going any further, can I ask if you have indeed installed 1.5 and had a look at the motorcycle example?

Having said that, I find the description of snappyHexMesh in the 1.5 manual somewhat terse. I am left with the impression that an underlying paper or report would come in handy in understanding some of the parameters.

erik023 September 10, 2008 07:27

Thank you Martin for this resp
Thank you Martin for this response!
I have the 1.4.1 version and will try to install 1.5 right away!

young October 16, 2008 00:33

Dear all! I got the polyMe
Dear all!
I got the polyMesh from SnappyHexMesh in OF-1.5, but I acctually use the OF-1.4.1-dev's solver. I copy the polyMesh directory into my case, however the solver cannot work!
what's wrong?

thankful for help
Yang Luchun

wikstrom October 27, 2008 05:20

Hi, appending a different m

appending a different matter to this thread:

I have gotten into snappy-troubles; Creating a mesh around a STL-geometry (fairly complex with bluff and slender bodies, built from many surfaces of which a bunch is overlapping etc. ugly geometry, achieved from architects...)

All looks well during testing stages with very moderate refinement levels. Then, getting serious, during a shell refinement step,snappyHexMesh bails out with this:

Could not find point 129196 in the anchorPoints for cell 97678

Does your original mesh obey the 2:1 constraint and did you use consistentRefinement to make your cells to refine obey this constraint as well?#0 Foam::error::printStack(Foam: in "/home/OpenFOAM/OpenFOAM-1.5.x/lib/linux64GccDPOpt/"

Does anyone have a clue as to whence the problem originates?

aunola October 27, 2008 10:41

I had the same error whilst ge
I had the same error whilst generating a mesh around a sphere using snappy. If memory serves me right this error occurred with a graded background mesh. Changing the background mesh to uniform cell size alleviated the problem. I could be mistaking this for some of the other errors I have seen though.

wikstrom October 27, 2008 11:20

Hi again, that was my initi
Hi again,

that was my initial thought too. However, removing grading in my case did not solve the problem.

But, I had tried to keep the cell expansion slow with nCellsBetweenLevels 3;. Reducing to nCellsBetweenLevels 2; "solved" the problem. Maby this is an issue of "meeting" refinement regions? I.e. when refining two opposite surfaces, the "second" surface can get refinement troubles when refining into the "first" surface refinement zone?


mattijs October 27, 2008 16:17

It should not depend on geomet
It should not depend on geometry. You checked you don't have a cellLevel or pointLevel file hanging around (e.g. in constant/)? There might be a problem in the refinement expansion nCellsBetweenLevels. Can you produce a testcase and report a bug on OpenFOAM-bugs?

wikstrom October 29, 2008 14:50

No *Level files haning around.
No *Level files haning around. I'll ask the customer if it's ok to publish the geometry tomorrow. Not easily reproduceable on simple test stl, I guess.


wikstrom December 5, 2008 05:50

Hi again, In some cases, th
Hi again,

In some cases, the BL generation produces "spikes" at the boundary. It allways occurs at geometry features and in most cases, but not all it occur at the intersection of two STL-regions (solids). How come? The image show the boundary mesh after snapping (on top) and after layering (bottom).

wikstrom December 5, 2008 05:59

Hi again, In some cases, th
Hi again,

In some cases, the BL generation produces "spikes" at the boundary. It allways occurs at geometry features and in most cases, but not all it occur at the intersection of two STL-regions (solids). How come? The images show the boundary mesh after snapping and after layering.

Any ideas? Parameters?

mattijs December 9, 2008 05:37

Hi Niklas, Seems a bit weir
Hi Niklas,

Seems a bit weird. Is it an small testcase? Can you send it?

fabrizio December 12, 2008 14:48

Hi dear foamers I'm using S
Hi dear foamers

I'm using Snappy too, I find it a very powerful tool; I have 3 questions for you:

1 - after meshing with Snappy I obtain cells with 9,10 even 12 faces, so they are no hex cells. How can I obtain only hex cells after meshing with Snappy?

2 - In general, does Snappy support other cells shapes (tet for example) in addition to hex?

3 - After converting the mesh with foamToVTK, is it possible to export the .vtk files in stl format from Paraview?

Thanks to all for help


mattijs December 13, 2008 12:43

1 - you cannot. Or you can hav
1 - you cannot. Or you can have a look at how paraFoam/foamToVTK decomposes non-hex cells into pyramids and tets.
2 - the starting mesh has to be hex only. These might get refined.
3 - stl is a surface format. Do you want to extract the surface of the mesh as an stl file? Use surfaceMeshTriangulate for that.

fabrizio December 15, 2008 12:40

Hi Mattijs thank you for your
Hi Mattijs thank you for your advice. I find surfaceMeshTriangulate very useful for me, but I have a problem. If I type

surfaceMeshTriangulate -case analisi ext.stl

I can correctly export the outside mesh created with BlockMesh; after using SnappyHexMesh in the boundary file there is a new patch, named part2, that I want to convert in stl; but when I type

surfaceMeshTriangulate -case analisi -patches part2 ext.stl

I obtain this output:

Create time

Extracting triSurface from boundaryMesh ...

Reading mesh from time 0
Create polyMesh for time = 0

incorrect first token, expected <int> or '(', found on line 0 the word 'part2'

file: IStringStream.sourceFile at line 0.

From function operator>>(Istream&, List<t>&)
in file /home/dm2/henry/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/ListIO.C at line 155.

FOAM exiting

I receive the same output even changing the patch.
Can you help me?

This is mu boundary file:

type patch;
nFaces 1600;
startFace 223232;
type patch;
nFaces 1600;
startFace 224832;
type wall;
nFaces 7680;
startFace 226432;
type empty;
nFaces 0;
startFace 234112;
type wall;
nFaces 384;
startFace 234112;

Thank you


braennstroem January 12, 2009 02:46

Hi, is there a chance to di

is there a chance to display the distance between the stl and snappyHex meshes? If so, could it be a good approach to keep those hexa cells, which don't get snapped to the stl features, in place and use an immersed boundary approach for these regions!?


maruthamuthu_venkatraman February 5, 2010 11:36

Uniform Boundary layer in snappyhexmesh
1 Attachment(s)
Dear Foamers,
I am a quite new user with Snappyhexmesh. I would like to generate a uniform boundarylayer normal to the walls for an aerofoil section. Due to curvature the cell levels has been increased to attach to the the surface. When the boundary layer i.e addlayer is set to 4 or 5 with the expansion ratio set as 0.3 (constant) due to large cells at flat surface locations boundary layers are non-uniform.

Is there is any way to make a uniform boundary layer along the curvature of the profile?Attached herewith the cutsection for the profile.

Greg Givogue October 16, 2010 22:58

I've had this problem before and resorted to setting addLayers to false and refining the BL using the distance option in refinement regions... how did you solve this problem? Were you able to use addLayers? Thanks

maruthamuthu_venkatraman October 17, 2010 08:16

Thanks for your interest in posting this reply.

I will try to use it in my next case. Actually I heard, snappyhex mesh is not a good choice for meshing geometries involving sharp corners. So I havent spend much time in investigated it.

May be this new OpenFOAM version can resolve it ?

Greg Givogue October 17, 2010 10:09

Yeah it's pretty cumbersome and very RAM intensive. It can deal with sharp edges and thin plates if you specify edges (.emesh) in features. I've spent a lot of time playing around with sHM and I think your better off using gmesh... good luck!

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