CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Native Meshers: snappyHexMesh and Others (
-   -   How to get a snapped mesh with SnappyHexMesh? (

jackeyhust June 6, 2013 12:52

How to get a snapped mesh with SnappyHexMesh?
4 Attachment(s)
Hi, Foamers,

I am new in OpenFoam and study it now. I just start it from a simple model.
Though it is small model, I still met some problems. Hopefully I can get your support.

The model consists of three parts : Extr1, Poro, Extr2. Each of them consists of inlet, outlet, and wall. I am now doing the multiregions meshing for these three parts together with snappyhexmesh. But I cannot get a perfectly snapped mesh. The edges and somewhere in the faces look not very smooth. I have struggled with this for a week. :(

Could someone help me a little bit? I attached the case folder and the pictures which indicate the results I have obtained. I have written the commands I ran the case in command.txt. I am now using OpenFOAM 2.2.0

I have tried to add the featureEdges for all of them and increase the surface refine mesh level, it is better now, but the surface is still not so flat. Could anybody tell me why?

Really thank you for your kind support!;)


Attachment 22506

Attachment 22507

Attachment 22508

Attachment 22509

cutter June 7, 2013 09:30

Try to align your blockMesh with your geometry (start with its real bounding box). This should give you much better results.


wyldckat June 9, 2013 07:49

Greetings to all!

@Jackie: Sorry, I don't enough time to go through testing this. Please check the tutorials at the following link for more ideas:

Best regards,

niklas June 10, 2013 04:13

5 Attachment(s)
Conforming a hexmesh to a general geometry implies a few things.
If you want to have a 'perfect' mesh with only orthogonal cells you can not expect it to fit the surface of
the geometry.
And vice versa,
if you want the mesh to fit your geometry perfectly you can not
expect it to consist of only perfectly shaped hex cells.

So it is up to the user to decide what you want the most, good conformity or good quality, usually you can not have both.

Therefore it is a good thing if you can align the mesh with the geometry, since this will allow the mesh to conform to the geometry with less modifications, and not do what you have done here...

You can play with these parameters and see how they affect the mesh.

maxNonOrtho 80;
maxBoundarySkewness 20;
maxInternalSkewness 5;
maxConcave 80;

Start by setting everything to 90, which should make the mesh fit as good as possible given the resolution.
If this looks good you can start reducing the numbers and see what happens.

Below I've made a few such tests just to illustrate how the mesh is unable to conform to the surface when you
start reducing the maxNonOrtho value.
Watch how the surface starts to look 'wavy' as the maxNonOrtho is lowered.

here's a new version of snappyHexMeshDict


/*--------------------------------*- C++ -*----------------------------------*\
|      o          |                                                          |
|    o    o      | HelyxOS                                                  |
|  o  O  o      | Version: 1.0.0                                          |
|    o    o      | Web:                            |
|      o          |                                                          |
    version 2.0;
    format ascii;
    class dictionary;
    location system;
    object snappyHexMeshDict;

castellatedMesh true;
snap true;
addLayers false;

        type triSurfaceMesh; 
        name Extr1;

        type triSurfaceMesh;
        name Extr2;
        type triSurfaceMesh; 
        name Poro;

        file "Poro.eMesh";     
        level 5;
        file "Extr2.eMesh";
        level 5;
        level ( 3 4 ); 
        faceZone Extr1;
        cellZone Extr1;
        cellZoneInside inside;

        level ( 3 4 );
        faceZone Extr2;
        cellZone Extr2;
        cellZoneInside inside;

        level ( 3 4 );
        faceZone Poro;
        cellZone Poro;
        cellZoneInside inside;
resolveFeatureAngle 30;


  locationInMesh ( 0.4 -0.03  0.6 );         

    // The surface refinement loop might spend lots of iterations
    // refining just a few cells. This setting will cause refinement
    // to stop if <= minimumRefine are selected for refinement. Note:
    // it will at least do one iteration (unless the number of cells
    // to refine is 0)
    minRefinementCells 10;

    maxLocalCells  1000000;                        //original 100 000
    maxGlobalCells 10000000;                      //original 2 000 000
    minRefinementCells 0;
    // Number of buffer layers between different levels.
    // 1 means normal 2:1 refinement restriction, larger means slower
    // refinement.
    nCellsBetweenLevels 1;                        //original 1,  others 5

    resolveFeatureAngle 30;
    //  allowFreeStandingZoneFaces true; 
        allowFreeStandingZoneFaces false;
    // Settings for the snapping.
        //- Number of patch smoothing iterations before finding correspondence
        //  to surface
        nSmoothPatch 10;                        //original 3            others 10

    //- Relative distance for points to be attracted by surface feature point
    //  or edge. True distance is this factor times local
    //  maximum edge length.
        tolerance 1;

    //- Number of mesh displacement relaxation iterations.
        nSolveIter 10;                                            //others 300          original 30

    //- Maximum number of snapping relaxation iterations. Should stop
    //  before upon reaching a correct mesh.
        nRelaxIter 10;

    // Feature snapping

        //- Number of feature edge snapping iterations.
        //  Leave out altogether to disable.
        nFeatureSnapIter 10;            //original 10

        //- Detect (geometric) features by sampling the surface
        implicitFeatureSnap true;

        //- Use castellatedMeshControls::features
        explicitFeatureSnap false;

        //- Detect features between multiple surfaces
        //  (only for explicitFeatureSnap, default = false)
        multiRegionFeatureSnap true;


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

        maxNonOrtho        80;
        maxBoundarySkewness 20;
        maxInternalSkewness 5;
        maxConcave          80;
        minFlatness        0.5;
        minVol              1.00E-13;
        minTetQuality      -1e30;
        //1e-30 ;
        minArea            -1;
        minTwist            0.05;
        minDeterminant      0.01;
        minFaceWeight      0.01;
        minVolRatio        0.001;            //0.01
        minTriangleTwist    -1;
        nSmoothScale        4;
        errorReduction      0.75;

    debug 0;
    mergeTolerance 1E-6;

niklas June 10, 2013 04:16

4 Attachment(s)
just some more pics

kingmaker August 8, 2013 08:08

Mesh Quality in Nikla's Experimnent
Hello Niklas...

It would be very very nice if you can also the mesh quality for the above experimental cases. like the results form checkMesh. I am also now experimenting with these parameters. As far as I can understand in the above experiments of yours the mesh quality should be relatively bad for the case with all 90(good surface fit). But my question is if we have a lot of non-orthogonal and skewed faces then the simulation may not converge .. am I correct ... ??

That exactly is my problem now. I am trying to get a good mesh of a blower. But I cannot get the number of skewed faces low. I am getting about 300 skewed faces (total number of faces ~18Millon ) and my solver(MRFSimpleFoam) is not converging. I think these 300 skewed cells are causing it to diverge. Any suggestion on this issue ?? Any one ?? ..

Thank you

niklas August 8, 2013 12:18

my first question is obvious.

Are you 100% sure that it is the mesh quality that is the cause of the divergence?

I have found that usually the cause lies in the choice of the initial values of k and epsilon.
What is the initial turbulent viscosity (or length scale)?

kingmaker August 9, 2013 03:27

Mesh Quality in Nikla's Experimnent
Hello Niklas

Thank you for the reply. I think the turbulence settings are good because, the same parameters gave me ok solution previously. I mean the solution converged. But as I wanted to get good solution I started to look at the mesh and make improvements and experiments with mesh quality parameters. And am caught in this problem I mentioned

niklas August 9, 2013 03:37


..still havent answered my question though

kingmaker August 9, 2013 04:09

Sorry I was away from the data so could not post it. I am using a k-omega model for turbulence and my turbulence values are :

inital K = 0.0015
initial Omega = 5
Both are uniform on the inlet which is a 140x140(mm) square

I have an inlet flow rate of 0.0011 m3/s

Thank you in advance.

niklas August 12, 2013 07:48

ok, those values are pretty acceptable, so thats not it then.

dont know then.

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