CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Native Meshers: snappyHexMesh and Others (
-   -   problems with sHM: it doesn't snap! (

Claudio87 August 13, 2013 07:26

problems with sHM: it doesn't snap!
5 Attachment(s)
Dear Foamers,

I'm writing because I'm having many troubles with snappyHexMesh: it doesn't snap!
I know this is "common": looking around in the forum, I found many others who have had similar problems, but none of the suggested solutions seems working in my case!

My best results are:
- one in which, starting from a very coarse background mesh, it does the snap stage, but the final mesh is useless for the simulation;
- another that would be good for the simulation (I think) but it doesn't snap, so all the surface is done by steps!

The strange thing in the second case is that in the log file of sHM I don't find the typical sentence "did not succesfully snap mesh. Giving up", and in the checkMesh I have no errors!

I tried many different combinations with the Dicts (blockMeshDict and snappyHexMeshDict):
- increasing or decreasing the intial number,
- increasing or decreasing the number of levels in sHMDict, directly for the refinementSurface or in the feature obteined with the command surfaceFeatureExtract,
- increasing the parameters in the subDict "snapControls".

Often it doesn't snap, saying "did not succesfully snap mesh. Giving up"; sometimes it doesn't say anithing, but it similarly doesn't snap!

I have no ideas now about what I can do, and about what is wrong!

I attach these two cases I obtained, with some images.
I hope someone could help me!

Best regards,

Artur August 13, 2013 09:27

While this doesn't answer all your problems it may help: in the "partially snapped case" I would try reducing the tolerance in snap control to an even lower number (your uploaded case has it at 1.0). I have had similar problems with a fine mesh resolution in the past and it seemed to have helped. I think the problem here might be that the mesh does snap but too many or too few points are attracted to the surface.

Claudio87 August 13, 2013 10:12

Dear Artur,

thank you for your quick answer!
Effectively, I didn't try to reduce tolerance less than 1: I will! Do you say to try changing just that value, or maybe some other snap parameter? (I tried yet increasing the different numbers of iterations, but nothing seems to change!)

Thank you,

Artur August 13, 2013 10:15

Personally I try to change them one by one because that makes it easier to figure out what the effect of each of them is on your mesh. I would try keeping them as they are at the moment and see where it gets you.

Claudio87 August 14, 2013 11:18

2 Attachment(s)
Dear Artur,

I tried to reduce the tolerance in snap control, as you suggested, but nothing seems changed :(. In the log of sHM I find a very very long list of warnings like this:

--> FOAM Warning :
From function autoSnapDriver::calcNearestSurface(..)
in file autoHexMesh/autoHexMeshDriver/autoSnapDriver.C at line 914
For point:16 coordinate:(0.0464325 0.0225236 -0.00174957) did not find any surface within:8.66976e-07 meter.

I tried this with both the cases, partially snapped and without snap stage done.
So, I didn't any new step, as you can see from the pictures attached.
I accept any other suggestion!

Artur August 14, 2013 11:33

This warning indicates that the tolerance is reduced too much and so the algorithm can't find a point which is close to the surface and hence it doesn't snap. In which case I'm not sure what's wrong, I'm afraid. If you want you can send me your case by email or upload here and I can have a quick look at it tomorrow.

Claudio87 August 14, 2013 11:45

I think I could send you my case by email, because the stl is too big to be uploaded here.
If you could have a look I'd be really grateful, because are about 3 weeks I'm fighting with this mesh!

Artur August 15, 2013 07:57

1 Attachment(s)
Try this.

It seems it was one of the mesh quality parameters. Didn't have time to verify which one exactly but I've indicated which ones I changed so you can work it out yourself if you so wish.

Claudio87 August 15, 2013 11:31

Thank you very much Artur. I'll try this tonight, then I'll give you a feedback. :)

Claudio87 August 16, 2013 07:53

3 Attachment(s)
Dear Artur,

I tried using your suggestions, unfortunely without good results.
I have run it not in parallel, but I don't think this can be the problem. Did you try it and it worked correctly?!

As you can see opening the sHM log files attached, it doesn't snap (the typical sentence "Did not succesfully snap mesh. Giving up." appears!), and I don't understand why: apparently, there are no errors.
The unique warnig gived is like this:

--> FOAM Warning : Displacement (-5.47403e-07 9.12509e-07 3.62186e-06) at mesh point 551088 coord (0.0485061 0.0227736 -0.00144371) points through the surrounding patch faces

after Morph iteration 0.

Moreover, another "error" appear: some closed regions are now meshed, thing doesn't desired! (you can see the difference comparing the images).
Now I'm tring replacing the old control parameters, once per time, to understand which one is the "guilty"!
However, remain my problem: it doesn't snap!

Thank you for your patience!


linnemann August 16, 2013 08:13


Is it possible for you to share the full case with the geometry file etc?

Otherwise the help can get very lengthy if we can play around with all possible options.

Artur August 16, 2013 08:29

3 Attachment(s)
Just to make sure, I re-ran your case on a single core with the exact same settings as the ones I posted and here's the result. No error messages, checkMesh ok. sHM log says it didn't snap successfully for some reason but by inspecting it I'd say it's snapped. I am running 2.2.0. Perhaps you are using a different version and that's where the problems are coming from?

Claudio87 August 16, 2013 09:22


I'm running OF 2.1.0, but looking the images you posted, the result seems the same. I'm just worried about sHM log says it didn't snap successfully. With the snap stage completed I'd expected a smooth surface, instead of that kind of waves on it; but I can't be sure, because my experience is still limited!
If you think this is good enough to try a simulation, I'll start with the next step.

What about the unwanted mesh in the closed zones? Do they appear also to you?


Thank you for your answer.
Unfortunately, the geometry file (STL) is too big to post the full case on the forum. But if you want, I can send you it by email (if you give me your address), as I did with Artur.

Artur August 16, 2013 09:57

4 Attachment(s)
This setup gives you better snapping and no warnings but for me it produced a few highly skewed faces (although tolerable I think with max skewness 4.5).

Claudio87 August 16, 2013 10:04

I'll try also this one; it seems better :)!

linnemann August 17, 2013 06:19

Could you not just use one of the file sharing options we have nowadays like dropbox, box, google drive, skydrive, etc.

They all make it possible to share a public link to a file.

miro2000 August 19, 2013 12:29


has anyone tried to refine .stl? Your stl should be as fine as possible. Also, you can check if your stl is OK; I use Netgen for that. If your stl passes check in netgen, you can be sure that it is not the problem

sudo apt-get install Netgen
- miro

Claudio87 August 19, 2013 19:27

Dear Niels,

there is the link you asked for, with my case (the same I sent to Artur, the one that doesn't snap).
I'm still looking for a better solution, because I did some steps with the help of Artur's suggestions, but it isn't how I would like it!

Dear Miro,

I checked the .stl just using Catia: effectively, there were many "holes" and I had to connect some surfaces. But now it seems to be good; only that, changing some parameters I have the problem I exposed in post #10. I'll check also with Netgen (or gmsh), even if I don't know how to use them...I'll try to learn fast!

Best regards,

miro2000 August 20, 2013 01:55

I'm glad it worked. Note that you should make your .stl as fine as possible.

It's really simple to check stl in netgen. It's something like edit -> checkMesh or something like that. After you import it of-course.

- miro

sivakumar August 22, 2013 10:14

2 Attachment(s)
Dear All,
I have some problem with edge snapping.

the steps I followed is:

1) I executed blockMesh after setting up the case ( 0 cons-> ( poly, trisurf) sys), see fig 1.

2) Secondly, as Bruno's post, the surfaceFeatureExtract command has been executed.
  • surfaceFeatureExtract -includedAngle 150 -writeObj constant/triSurface/fanGeo.stl fanGeo
3) Thirdly, I have edited the sHMDict as below,

castellatedMesh true;
snap true;
addLayers false;

type triSurfaceMesh;
name fanGeo;

type searchableBox;
min (-0.4 0.2 -0.1);
max (0.4 0.8 0.1);

// Settings for the castellatedMesh generation.

maxLocalCells 2000000;
maxGlobalCells 20000000;
minRefinementCells 3;
maxLoadUnbalance 0.10;
nCellsBetweenLevels 5;

file "fanGeo.eMesh";
level 4;

level (4 4);

// Resolve sharp angles
resolveFeatureAngle 30;



locationInMesh (0.15 0.46 1);

allowFreeStandingZoneFaces true;

// Settings for the snapping.
nSmoothPatch 5;
tolerance 1;
nSolveIter 300;
nRelaxIter 5;
nFeatureSnapIter 20;

// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
maxNonOrtho 65;
maxBoundarySkewness 20;
maxInternalSkewness 4;
maxConcave 80;
minVol 1e-13;
minTetQuality 1e-30;
minArea -1;
minTwist 0.02;
minDeterminant 0.001;
minFaceWeight 0.02;
minVolRatio 0.01;
minTriangleTwist -1;

nSmoothScale 4;
errorReduction 0.75;

I tried many cases, but still the edge of the fan is not on the line. see fig.2 (bladeEdge)

please help me to get the good edge snapping.


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