CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Native Meshers: snappyHexMesh and Others (
-   -   snappyHexMesh geometry (

Kristianur May 15, 2009 07:59

snappyHexMesh geometry

I'm trying to generate a mesh from a stl-file consisting of several different solids and I'm not sure what to type into the geometry subdirectory. I've tried to do it similarly to the motorBike tutorial but it doesn't work.

Here's the message I get when I try running Snappy:

Cannot find triSurfaceMesh starting from "/home/kristian/OpenFOAM/kristian-1.5/run/localHawk/constant/triSurface/LocalHawk.stl"

From function triSurfaceMesh::checkFile(const fileName&, const fileName&)
in file searchableSurface/triSurfaceMesh.C at line 56.

FOAM exiting

Is this because of an error in the geometry subdirectory?


btw: I'm a beginner to openFOAM.

dani May 15, 2009 09:02

Hello Kristian,
make sure to have in the snappyHexMeshDict all the subsequent entries:

type triSurfaceMesh;
name NACAgeo1;
// Surface-wise min and max refinement level
level (0 0);
locationInMesh (0.001 0.001 0.001);



Kristianur May 15, 2009 10:31

Thank you dani.

I've read through the file several times and I'm almost certain I've included the stl-file name correctly everywhere I'm supposed to.

Could any other errors result in the same message?

e.g if there's something wrong with the stl?

I am also not sure about the refinementbox entry. can someone explain to me what exactly the "min" and "max" entries are?

Kristianur May 15, 2009 11:43

Okay.. I just found out it would be a good idea to check and see if my model was even inside the background mesh. Which it wasn't, so I'm guessing that is the problem.

Why has the origin moved from where it originally was in my SolidWorks-file and what can i do to align it?

Edit: Nope. That didn't solve it either. Any Ideas?

wolle1982 May 15, 2009 12:44

hi kristianur,

1. min/max refinement level means what is says: force to minimum refinement, and limit maximum. My hint: make both the same (eg. (3 3) then the mesh even looks better.

2. on the STL file: make sure, the STL file contains the region name of the "patch" you want to use and refine. see
remember: the filename is a different from the geometry name inside the file.

3. most CAD progs work in mm. OF and sHM work in m. So maybe your geometry i just 1000times bigger. or if it's offseted from the origin in the CAD prog by 1 mm, in OF it is offseted 1m ! check that! in that case, just mesh 1000times bigger and later transformate with the transformPoints Tool.

hope that helps a little

Kristianur May 15, 2009 16:34

Yes thank you, that helped a lot.

I was actually wondering about the
type searchableBox;
min (-0.3 -0.4 -0.1);
max ( 3.0 0.4 1.4);
entry in the motorBike example. but I saw you hadn't typed it into your example so I guess it's not necessary?

The modell is 790mm long in SolidWorks. Does that mean that it's probably 790m in the stl file?

wolle1982 May 18, 2009 04:06


yes, the CAD Prog works in mm. the STL File doesn't contain any units. so it says: "lenght 790" eg. importing it into OF which works in m would make it 790m wide. but, as i said, don't worry. just mesh it like this and afterwards use the command
transformPoints -scale "(0.001 0.001 0.001)"
that will solve it. you can check with checkMesh there it prints out the bounding box of your model in m.
Otherwise there are some openSource tools to scale/transform/rotate STL files. just search for...

The searchable box is only a BOX where the mesh will get refined in (the name "searchable" is a little missunderstanding, i know). it is useful in refining the wake area behind a geometry. the searchable box can also be a sphere, as can be seen in the igloo tutorial.

Kristianur May 20, 2009 13:24


I think I have understood all that now. There's an option in the export window in SW that allows you to change the units from mm to m f.ex.

But I still can't run my snappy. when I try running it now it tells me that snapControls is undefined:

<< keyword snapControls is undefined in dictionary "/home/kristian/OpenFOAM/kristian-1.5/run/localHawk/system/snappyHexMeshDict"

file: /home/kristian/OpenFOAM/kristian-1.5/run/localHawk/system/snappyHexMeshDict from line 9 to line 180.

From function dictionary::subDict(const word& keyword)
in file db/dictionary/dictionary.C at line 288. >>

Du I have to specify the snapControls for each region in the geometry? If yes, how?

I tried running a code with the exact same syntax on a single body geometry and that worked fine.

wolle1982 May 20, 2009 13:36


the error sounds like you've deleted sometihing BEFORE the snapcontrol command. most likely a ";" or "." oder ")" oder "}" .....

no, you don't have to define multi snap control...

Kristianur May 21, 2009 08:25

you were right. A missing ";" was the problem.

But here's another (probably simple) question:

What can cause the program to think that the "locationInMesh" is "not inside the mesh or on a face or edge" when in fact it isn't?
I am sure I've positioned the point right next to my geometry and I tried moving it slightly to make sure it's not on a face or edge, and moving it to the edge of the domain and inside the geometry.

no matter where I move it I get the same message.

thanks for all the help.

wolle1982 May 25, 2009 02:56


i also once had the same problem. the geometry MUST have the same coordinate system as later used in openfoam. so check already while building in CAD.

then again: mm and m checked??

s.sivakumar July 29, 2009 02:07

how to use snappy mesh
Hi foamers,
i am trying to use snappy mesh for simpleFoam solver (snappy motor bike tutorial case), just increased the cells 100000 in to 3400000.
my questions are:

*) this is confusing question for me, can we use minX, maxX, minY,maxY,minZ, maxZ as a boundary?
if yes i am using like this
minX= inlet, maxX=outlet, minY,maxY,minZ and maxZ are wall.
please tell me is it right or not?

the remaining motor bike as wall

1) if it is wrong how can we give the inlet and outlet conditions?

in the inlet 0/U
type fixedValue;
value uniform (20 0 0);

in the outlet 0/p
type fixedValue;
value uniform 0;

when i run simpleFoam solver i am getting the following error message;

Create mesh for time = 0

Reading field p

ill defined primitiveEntry starting at keyword 'boundaryField' on line 18 and ending at line 388

file: /volume/cfd4_shared/2009-ct-PI-004/OpenFOAM/sivakumar1.5.x/run/tutorials/snappyHexMesh/motorBike/0/p at line 388.

From function primitiveEntry::readEntry(const dictionary& dict,Istream& is)
in file db/dictionary/primitiveEntry/primitiveEntryIO.C at line 210.

FOAM exiting

i have attached k epsilon U and p as well the boundary please have a look and help me to overcome this problem

Thanks All,

openfoam_user March 3, 2010 11:59

1 Attachment(s)

I have attached an image of the motorbike tutorial after just 50 iterations.

The case seems to run fine.

The question is about the surface mesh on the side of the motorbike.

In some places it is very strange (like 2 cells; the first over the second) with green spots.

Is it just a problem of viewing correctly the surface mesh or not ?

What is the 'best way' to view grids done with snappyHexMesh ?

Best regards,


wyldckat March 3, 2010 16:37

Greetings Stephane,

Let's see, by what I know:
  1. if you are using OpenFOAM 1.6, the solver will start do give out garbage results at about 300 iterations. You'll have to upgrade to OpenFOAM 1.6.x.
  2. if it's just the mesh you want to see/debug, I just found about this, that using the ExtractCellsByRegion in Paraview helps to not get triangulated meshes, which is the standard when we cut the mesh to see how it is inside.
  3. as for "like 2 cells; the first over the second", the bike is hollow, and has puncture holes in it, so you'll get a single two sided mesh around the bike surface, so it's only natural that you get overlayed cells.
And that's all I know to answer your questions.

Best regards,

openfoam_user March 4, 2010 04:16

Hi Bruno,

thanks for your advices.

I use 1.6.x version.

The "ExtractCellsByRegion" tool works well.



Curro5150 April 4, 2010 10:06


I am trying to evaluate the possibilities of OpenFOAM in the field of ship hydrodynamics, for the moment I want to try to get the wave field generated by a single catamaran hull using interFOAM. However, after creating the background mesh, I am having the same problem as the OP, I get the error with the .stl file. I have checked everything in this post but I keep getting the same message. The ASCII stl file looks ok, I even changed the solid name in the stl file to match the file name and the name I want to give the patch.
żAny other suggestions?

Curro5150 April 4, 2010 10:14

Ok, forget about my previous post... The cause of the error is mainly that I am an idiot (and that the folder names are case sensitive)...

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