CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Native Meshers: snappyHexMesh and Others

SnappyHexMesh - How to set-up to avoid skewfaces?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   December 2, 2009, 13:37
Default SnappyHexMesh - How to set-up to avoid skewfaces?
  #1
Member
 
Pablo Caron
Join Date: Nov 2009
Location: Buenos Aires, Argentina
Posts: 73
Rep Power: 7
pcaron is on a distinguished road
Hello forum!

I started using snappy a few weeks ago. So I haven't too much experience using it.

I'm trying to mesh the air around a body. I changed almost every parameter I think can improve my mesh. No matter what I change I always get some skewfaces. These skewfaces always follow the same patern: It's an hex over the patch in the castellated mesh, in the snap step it become a skewfaces.

What I did: I Changed the number of refinement steps in this patch, I changed the tolerance in the snap settings.

I attached two screenshots and below there's my snappyHexMeshDict

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  1.6                                   |
|   \\  /    A nd           | Web:      http://www.OpenFOAM.org               |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// Which of the steps to run
castellatedMesh true;
snap            true;
addLayers       false;


// Geometry. Definition of all surfaces. All surfaces are of class
// searchableSurface.
// Surfaces are used
// - to specify refinement for any mesh cell intersecting it
// - to specify refinement for any mesh cell inside/outside/near
// - to 'snap' the mesh boundary to the surface
geometry
{
    bodyCompleto.stl
    {
        type triSurfaceMesh;
    regions
    {
        body
        {
        name body;
        }
        anotherPart
        {
        name anotherPart;
        }
    }
    }

    refinementBox
    {
        type searchableBox;
        min ( 0     -2200 -60);
        max ( 1100   8000  1500);
    }
};



// Settings for the castellatedMesh generation.
castellatedMeshControls
{

    // Refinement parameters
    // ~~~~~~~~~~~~~~~~~~~~~

    // While refining maximum number of cells per processor. This is basically
    // the number of cells that fit on a processor. If you choose this too small
    // it will do just more refinement iterations to obtain a similar mesh.
    maxLocalCells 1000000;

    // Overall cell limit (approximately). Refinement will stop immediately
    // upon reaching this number so a refinement level might not complete.
    // Note that this is the number of cells before removing the part which
    // is not 'visible' from the keepPoint. The final number of cells might
    // actually be a lot less.
    maxGlobalCells 4000000;

    // 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;

    // Number of buffer layers between different levels.
    // 1 means normal 2:1 refinement restriction, larger means slower
    // refinement.
    nCellsBetweenLevels 3;



    // Explicit feature edge refinement
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    // Specifies a level for any cell intersected by its edges.
    // This is a featureEdgeMesh, read from constant/triSurface for now.
    features
    (
        //{
        //    file "someLine.eMesh";
        //    level 2;
        //}
    );



    // Surface based refinement
    // ~~~~~~~~~~~~~~~~~~~~~~~~

    // Specifies two levels for every surface. The first is the minimum level,
    // every cell intersecting a surface gets refined up to the minimum level.
    // The second level is the maximum level. Cells that 'see' multiple
    // intersections where the intersections make an
    // angle > resolveFeatureAngle get refined up to the maximum level.

    refinementSurfaces
    {
    bodyCompleto.stl
      {
        level (0 0);
        regions
        {
            body
        {
            level (5 6);
        }
            anotherPart
        {
            level (8 8);
        }
        }
      }
    }

    // Resolve sharp angles
    resolveFeatureAngle 20;


    // Region-wise refinement
    // ~~~~~~~~~~~~~~~~~~~~~~

    // Specifies refinement level for cells in relation to a surface. One of
    // three modes
    // - distance. 'levels' specifies per distance to the surface the
    //   wanted refinement level. The distances need to be specified in
    //   descending order.
    // - inside. 'levels' is only one entry and only the level is used. All
    //   cells inside the surface get refined up to the level. The surface
    //   needs to be closed for this to be possible.
    // - outside. Same but cells outside.

    refinementRegions
    {
        refinementBox
        {
            mode inside;
            levels ((1E15 2));
        }
    }


    // Mesh selection
    // ~~~~~~~~~~~~~~

    // After refinement patches get added for all refinementSurfaces and
    // all cells intersecting the surfaces get put into these patches. The
    // section reachable from the locationInMesh is kept.
    // NOTE: This point should never be on a face, always inside a cell, even
    // after refinement.
    locationInMesh (1000 -2000 100);
}



// Settings for the snapping.
snapControls
{
    //- Number of patch smoothing iterations before finding correspondence
    //  to surface
    nSmoothPatch 5;

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

    //- Number of mesh displacement relaxation iterations.
    nSolveIter 30;

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



// Settings for the layer addition.
addLayersControls
{
    relativeSizes true;

    // Per final patch (so not geometry!) the layer information
    layers
    {
        minZ
        {
            nSurfaceLayers 1;
        }
        motorBike_frt-fairing:001%1
        {
            nSurfaceLayers 1;
        }
    }

    // Expansion factor for layer mesh
    expansionRatio 1.0;

    //- Wanted thickness of final added cell layer. If multiple layers
    //  is the
    //  thickness of the layer furthest away from the wall.
    //  Relative to undistorted size of cell outside layer.
    finalLayerThickness 0.3;

    //- Minimum thickness of cell layer. If for any reason layer
    //  cannot be above minThickness do not add layer.
    //  Relative to undistorted size of cell outside layer.
    minThickness 0.1;

    //- If points get not extruded do nGrow layers of connected faces that are
    //  also not grown. This helps convergence of the layer addition process
    //  close to features.
    nGrow 1;


    // Advanced settings

    //- When not to extrude surface. 0 is flat surface, 90 is when two faces
    //  make straight angle.
    featureAngle 30;

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

    // Number of smoothing iterations of surface normals
    nSmoothSurfaceNormals 1;

    // Number of smoothing iterations of interior mesh movement direction
    nSmoothNormals 3;

    // Smooth layer thickness over surface patches
    nSmoothThickness 10;

    // Stop layer growth on highly warped cells
    maxFaceThicknessRatio 0.5;

    // Reduce layer growth where ratio thickness to medial
    // distance is large
    maxThicknessToMedialRatio 0.3;

    // Angle used to pick up medial axis points
    minMedianAxisAngle 130;

    // Create buffer region for new layer terminations
    nBufferCellsNoExtrude 0;

    // Overall max number of layer addition iterations
    nLayerIter 50;
}



// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
meshQualityControls
{
    //- Maximum non-orthogonality allowed. Set to 180 to disable.
    maxNonOrtho 65;

    //- Max skewness allowed. Set to <0 to disable.
    maxBoundarySkewness 20;
    maxInternalSkewness 4;

    //- Max concaveness allowed. Is angle (in degrees) below which concavity
    //  is allowed. 0 is straight face, <0 would be convex face.
    //  Set to 180 to disable.
    maxConcave 80;

    //- Minimum projected area v.s. actual area. Set to -1 to disable.
    minFlatness 0.5;

    //- Minimum pyramid volume. Is absolute volume of cell pyramid.
    //  Set to very negative number (e.g. -1E30) to disable.
    minVol 1e-13;

    //- Minimum face area. Set to <0 to disable.
    minArea -1;

    //- Minimum face twist. Set to <-1 to disable. dot product of face normal
    //- and face centre triangles normal
    minTwist 0.02;

    //- minimum normalised cell determinant
    //- 1 = hex, <= 0 = folded or flattened illegal cell
    minDeterminant 0.001;

    //- minFaceWeight (0 -> 0.5)
    minFaceWeight 0.02;

    //- minVolRatio (0 -> 1)
    minVolRatio 0.01;

    //must be >0 for Fluent compatibility
    minTriangleTwist -1;


    // Advanced

    //- Number of error distribution iterations
    nSmoothScale 4;
    //- amount to scale back displacement at error points
    errorReduction 0.75;
}


// Advanced

// Flags for optional output
// 0 : only write final meshes
// 1 : write intermediate meshes
// 2 : write volScalarField with cellLevel for postprocessing
// 4 : write current intersections as .obj files
debug 0;


// Merge tolerance. Is fraction of overall bounding box of initial mesh.
// Note: the write tolerance needs to be higher than this.
mergeTolerance 1E-6;


// ************************************************************************* //
I would appreciate any help in setting-up my snappyHexMeshDict.

Regards

Pablo
Attached Images
File Type: jpg castellated.jpg (76.5 KB, 827 views)
File Type: jpg snaped.jpg (34.7 KB, 842 views)
pcaron is offline   Reply With Quote

Old   March 31, 2010, 02:02
Default
  #2
New Member
 
Prashant
Join Date: Mar 2010
Posts: 1
Rep Power: 0
prashantsonakar is on a distinguished road
Nice illustration
Thanks
prashantsonakar is offline   Reply With Quote

Old   March 31, 2010, 08:19
Default
  #3
Member
 
Pablo Caron
Join Date: Nov 2009
Location: Buenos Aires, Argentina
Posts: 73
Rep Power: 7
pcaron is on a distinguished road
Dear Prashant, Thank you,

Have you had similar problems? I've used snappy a bit more, but I couldn't solve this problem yet.

Regards

Pablo
pcaron is offline   Reply With Quote

Old   April 20, 2010, 10:49
Default
  #4
Senior Member
 
louisgag's Avatar
 
Louis Gagnon
Join Date: Mar 2009
Location: Québec, QC, Canada
Posts: 208
Rep Power: 9
louisgag is on a distinguished road
Send a message via ICQ to louisgag
I also have issues with skew faces and am not yet able to tell you how to avoid it.

-Louis
louisgag is offline   Reply With Quote

Old   April 20, 2010, 11:46
Default
  #5
Member
 
Pablo Caron
Join Date: Nov 2009
Location: Buenos Aires, Argentina
Posts: 73
Rep Power: 7
pcaron is on a distinguished road
Louis, thanks for your reply. This problem arises when your surface is almost aligned with the mesh. Then some nodes and/or elements are deleted. In my pictures the element is deleted so the surface has a cube inside the mesh, so in the snap stage the nodes are attracted by the stl surface. But, this is the problem, not the solution I don't have a solution either.

Some hints
1) Start with a coarse mesh and add layers. I don't have layer in my pictures.
2) Increase the tolerance in snapControls. In this case the resulting surface has a lot of bumps.

These are just some ideas. I think there isn't a unique solution.

Regards

Pablo
pcaron is offline   Reply With Quote

Old   April 20, 2010, 12:07
Default
  #6
Senior Member
 
louisgag's Avatar
 
Louis Gagnon
Join Date: Mar 2009
Location: Québec, QC, Canada
Posts: 208
Rep Power: 9
louisgag is on a distinguished road
Send a message via ICQ to louisgag
although if you reduce the max skewness setting in the snappyHexMeshDict to something very low (eg. 0.5 for both) it seems to help.

-Louis

PS: thanks for your help also

EDIT: It seems however that seeting my max skewneww really low makes the mesh really coarse.. perhaps not the best solution..!

Last edited by louisgag; April 20, 2010 at 14:28.
louisgag is offline   Reply With Quote

Old   April 27, 2010, 09:23
Default
  #7
Member
 
Moritz Wied
Join Date: Mar 2010
Location: suttgart, germany
Posts: 35
Rep Power: 7
Mo-ITB is on a distinguished road
hi everybody,

may it be that the layer-addition phase is the problem here? i also have problems with "bumps" on my surface at the moment, and if i dont add layers and leave everything else the same, everything is smooth...

regards,
moritz
Mo-ITB is offline   Reply With Quote

Old   April 27, 2010, 10:02
Default
  #8
Senior Member
 
louisgag's Avatar
 
Louis Gagnon
Join Date: Mar 2009
Location: Québec, QC, Canada
Posts: 208
Rep Power: 9
louisgag is on a distinguished road
Send a message via ICQ to louisgag
Hi Moritz,

for me it seems that layers usually reduce the skewness, however, if I set the skewness tolerance in snappyhexmeshdict to a very low value (ex: below 0.5) that's when I see a very rough surface mesh, even without layers, but, skewness is reduced.. which is useless since my mesh is wrong!
louisgag is offline   Reply With Quote

Old   May 1, 2010, 12:28
Default I agree
  #9
Member
 
Pablo Caron
Join Date: Nov 2009
Location: Buenos Aires, Argentina
Posts: 73
Rep Power: 7
pcaron is on a distinguished road
Hi Louis and Moritz

I agree with Louis, I test to reduce the skewness option recently. The result is a bumped surface . I solved it with a higher value in maxBoundarySkewness option, say 10. But with a lower value in maxInternalSkewness.

I have no tested to add layers yet. So, I haven't experience using that option.

Regards

Pablo
pcaron is offline   Reply With Quote

Old   May 2, 2010, 19:24
Default
  #10
Member
 
Alan Russell
Join Date: Aug 2009
Location: Boise, Idaho USA
Posts: 61
Rep Power: 8
AlanR is on a distinguished road
I had a lot of strange problems with snappy - not exactly as described above. The source was the fvSolution and fvSchemes files. These files in the motorbike tutorial are not the right ones for mesh generation with snappy (they are for running the wind tunnel simulation part of the motorbike tutorial, not the mesh part). Using the fvSolution and fvSchemes from the moveDynamicMesh tutorial fixed all of my mesh problems. Check both files and make sure they have settings for cellDisplacement, cellMotionU, etc.

Good luck,

Alan
AlanR is offline   Reply With Quote

Old   May 5, 2010, 16:34
Default
  #11
Senior Member
 
louisgag's Avatar
 
Louis Gagnon
Join Date: Mar 2009
Location: Québec, QC, Canada
Posts: 208
Rep Power: 9
louisgag is on a distinguished road
Send a message via ICQ to louisgag
Hi Alan,

thanks for pointing this out; however, changing to the fvSchemes and fvSolution files that do contain de CellMotion part does not change anything in the mesh that snappyHexMesh generates for me.

My solution so far has been to tolerate the maximum skewness of 5-6 since the results still seem very reasonable and my simulation converges.

Best regards,


-Louis

PS: as for trying a low internalSkew and high boundaryskew, it still does the rough mesh problem.
louisgag is offline   Reply With Quote

Old   February 3, 2011, 11:44
Default
  #12
cjm
New Member
 
Carl
Join Date: Jan 2011
Location: Bremen /Gothenburg
Posts: 11
Rep Power: 6
cjm is on a distinguished road
Hi there,

I have the very same problem with skewed faces on a very complex geometry. ca. 300 SF with the max bound. skewness of 10 and 2. Does anyone have a solution yet for that problem or is it something you have to live with using sHM? How do you set it up the right way without making the mesh to coarse?

Open for any answers.

Bye cjm
cjm is offline   Reply With Quote

Old   March 2, 2011, 08:30
Default
  #13
cjm
New Member
 
Carl
Join Date: Jan 2011
Location: Bremen /Gothenburg
Posts: 11
Rep Power: 6
cjm is on a distinguished road
Hej all,

I found the same as Louis. MaxBoundSkew ~5 give the best results by keeping the shape of the grid (at least for the case I am working on). Another important thing is to make the blockMesh cells the way that the edge length in X,Y,Z are more or less the same or times 0.5 of each other, i.e. cube like or semi-cube like. This enables sHM to produce less skewed Faces as well.

Bye cjm
cjm is offline   Reply With Quote

Old   June 14, 2013, 12:15
Default
  #14
New Member
 
Peng Zhong
Join Date: Jun 2013
Posts: 12
Rep Power: 4
panpanzhong is on a distinguished road
You may need to set surface refinement levels so that min and max are the same number.
panpanzhong is offline   Reply With Quote

Old   July 9, 2013, 13:01
Default
  #15
New Member
 
Ole Richter
Join Date: Jun 2013
Posts: 11
Rep Power: 4
kuechenrole is on a distinguished road
solution for my case

i set up a few cases and raised always another setting.
nSmoothPatch killed the skew faces at my case without decreasing the quality of my mesh.
kuechenrole is offline   Reply With Quote

Old   August 14, 2014, 05:03
Default
  #16
New Member
 
Join Date: Mar 2014
Posts: 17
Rep Power: 3
BenJ is on a distinguished road
Hi everybody!

I have been reading your solutions, but I still have bad cells on surface (see attachement).

I am using OpenFoam 2.3.0. I already changed the following parameters:
maxNonOrtho
maxBoundarySkewness
maxInternalSkewness
nSmoothPatch
tolerance
And it did not help.

I also tried to run the three snappyHexMesh steps separately, but it did not help.

Has anybody experienced such difficulty and could give me a tip?

Best regards
Benjamin
Attached Images
File Type: jpg badCell.jpg (31.7 KB, 83 views)
BenJ is offline   Reply With Quote

Old   August 19, 2014, 03:12
Default
  #17
New Member
 
Join Date: Mar 2014
Posts: 17
Rep Power: 3
BenJ is on a distinguished road
Hi!

I have been changing other parameters in snapControls:
nSolveIter
nSmoothPatch
nRelaxIter
nFeatureSnapIter

without any success.

Has anybody any tip to avoid this kind of cell?

Best regards
BenJ
BenJ is offline   Reply With Quote

Old   September 13, 2014, 15:58
Default
  #18
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,488
Blog Entries: 34
Rep Power: 86
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Greetings BenJ,

I've had this thread on my to-do list for a while now and only now did I manage to come look into this.
I don't know if you've found an answer for this or not, but if not, the problem is that although I think I might be able to help, there isn't much I can do without a test case to work with and test things myself

Therefore, if you could provide a test case where this occurs, I can take a look into it.

Best regards,
Bruno
wyldckat is online now   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
OF 1.6 | Ubuntu 9.10 (64bit) | GLIBCXX_3.4.11 not found piprus OpenFOAM Installation 22 February 25, 2010 14:43
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08
Help with GNUPlot Renato. Main CFD Forum 6 June 6, 2007 19:51
Env variable not set gruber2 OpenFOAM Installation 5 December 30, 2005 05:27
How to set environment variables kanishka OpenFOAM Installation 1 September 4, 2005 10:15


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