CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[snappyHexMesh] Low Quality SnappyHexMesh

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By y_jiang

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 28, 2018, 16:13
Default Low Quality SnappyHexMesh
  #1
Member
 
Yijiu Jiang
Join Date: Jan 2013
Location: Michigan, US
Posts: 49
Rep Power: 13
y_jiang is on a distinguished road
Dear Foamers,


I got a problem of meshing complex geometry by using snappyHexMesh. The geometry is a fuel tank and three air needles with small holes. I got 4 failures when I ran checkMesh -allTopology -allGeometry as follow
There are 145 faces with low quality or negative volume decomposition tets. I checked their locations by doing foamToVTK and you can see those faces were mostly near the needle.
I am wondering to how deal to with this problem? My snappyHexMeshDict is posted below. Thank you in advance for your ideas.

Code:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create polyMesh for time = 2

Enabling all (cell, face, edge, point) topology checks.

Enabling all geometry checks.

Time = 2

Mesh stats
    points:           5145844
    faces:            12739506
    internal faces:   11598495
    cells:            3847792
    faces per cell:   6.325186
    boundary patches: 7
    point zones:      0
    face zones:       0
    cell zones:       0

Overall number of cells of each type:
    hexahedra:     2977597
    prisms:        197861
    wedges:        0
    pyramids:      0
    tet wedges:    2663
    tetrahedra:    9
    polyhedra:     669662
    Breakdown of polyhedra by number of faces:
        faces   number of cells
            4   71915
            5   57742
            6   146775
            7   4139
            8   2376
            9   261649
           10   684
           11   1017
           12   88048
           13   134
           14   360
           15   31827
           16   12
           17   110
           18   2874

Checking topology...
    Boundary definition OK.
    Cell to face addressing OK.
    Point usage OK.
    Upper triangular ordering OK.
    Face vertices OK.
    Topological cell zip-up check OK.
  <<Number of duplicate (not baffle) faces found: 1. This might indicate a problem.
  <<Number of faces with non-consecutive shared points: 1. This might indicate a problem.
  <<Writing 3 faces with non-standard edge connectivity to set edgeFaces
    Number of regions: 1 (OK).

Checking patch topology for multiply connected surfaces...
                   Patch    Faces   Points                  Surface topology Bounding box
            geofull_tank   905713   975568  ok (non-closed singly connected) (2887.923 -533.8322 726.5) (4246.172 -73.10504 1014.389)
         geofull_needle1    83855    96516  ok (non-closed singly connected) (3625.611 -279.1003 819.0776) (3681.045 -224.1003 967.889)
         geofull_needle2    72405    84143  ok (non-closed singly connected) (3855.86 -300.8351 817.9538) (3886.03 -270.6655 965.846)
         geofull_needle3    73618    85057  ok (non-closed singly connected) (3294.318 -259.154 853.2154) (3324.488 -228.9405 1002.381)
          geofull_inlet1     3069     3456  ok (non-closed singly connected) (3629.719 -275.3944 967.5517) (3677.178 -227.806 967.9083)
         geofull_outlet2     1075     1240  ok (non-closed singly connected) (3859.041 -297.6346 965.8428) (3882.845 -273.8639 965.846)
         geofull_outlet3     1276     1462  ok (non-closed singly connected) (3297.502 -255.875 1001.981) (3321.293 -232.1773 1002.393)

Checking geometry...
    Overall domain bounding box (2887.923 -533.8322 726.5) (4246.172 -73.10504 1014.389)
    Mesh has 3 geometric (non-empty/wedge) directions (1 1 1)
    Mesh has 3 solution (non-empty) directions (1 1 1)
    Boundary openness (1.144225e-15 1.184377e-14 -1.156493e-15) OK.
    Max cell openness = 4.197517e-16 OK.
    Max aspect ratio = 19.99069 OK.
    Minimum face area = 0.001795068. Maximum face area = 149.5771.  Face area magnitudes OK.
    Min volume = 0.001712738. Max volume = 1811.554.  Total volume = 1.282267e+08.  Cell volumes OK.
    Mesh non-orthogonality Max: 65.19133 average: 13.08045
    Non-orthogonality check OK.
    Face pyramids OK.
 ***Max skewness = 4.223506, 4 highly skew faces detected which may impair the quality of the results
  <<Writing 4 skew faces to set skewFaces
    Coupled point location match (average 0) OK.
 ***Error in face tets: 145 faces with low quality or negative volume decomposition tets.
  <<Writing 145 faces with low quality or negative volume decomposition tets to set lowQualityTetFaces
    Min/max edge length = 0.01192015 12.32616 OK.
   *There are 12317 faces with concave angles between consecutive edges. Max concave angle = 80.09907 degrees.
  <<Writing 12317 faces with concave angles to set concaveFaces
    Face flatness (1 = flat, 0 = butterfly) : min = 0.2413469  average = 0.9988338
   *There are 215 faces with ratio between projected and actual area < 0.8
    Minimum ratio (minimum flatness, maximum warpage) = 0.2413469
  <<Writing 215 warped faces to set warpedFaces
    Cell determinant (wellposedness) : minimum: 3.559069e-05 average: 18.54062
 ***Cells with small determinant (< 0.001) found, number of cells: 6
  <<Writing 6 under-determined cells to set underdeterminedCells
 ***Concave cells (using face planes) found, number of cells: 274561
  <<Writing 274561 concave cells to set concaveCells
    Face interpolation weight : minimum: 0.0537663 average: 0.4509914
    Face interpolation weight check OK.
    Face volume ratio : minimum: 0.01002021 average: 0.7536259
    Face volume ratio check OK.

Failed 4 mesh checks.

End

Code:
FoamFile
 {
    version     2.0;
    format      ascii;
    class       dictionary;
    object      snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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


geometry
{
    geofull.stl 
    {
        type triSurfaceMesh;
        name geofull;
     }
};



castellatedMeshControls
{
    maxLocalCells 2000000;
    maxGlobalCells 20000000;
    minRefinementCells 0;
    maxLoadUnbalance 0.10;
    nCellsBetweenLevels 2;
   
    features
    (
        {
            file "geofull.eMesh";
            level 2;
        }
    );

    refinementSurfaces
    {
        geofull 
        {
            level (3 5);
/*            regions
            {
                needle1
                {
                    level (5 5);
                }
                needle2
                {
                    level (5 5);
                }
                needle3
                {
                    level (5 5);
                }
                inlet1 
                {
                    level (4 4);
                }
            }*/
         }
    }

    resolveFeatureAngle 30;

    refinementRegions
    {
    } 

    locationInMesh (3500.01 -200.01 880.01);

    allowFreeStandingZoneFaces true; 
}


snapControls
{
    nSmoothPatch 3;
    
    tolerance 1.0;

    nSolveIter 300;

    nRelaxIter 5;

    nFeatureSnapIter 10; 
}


addLayersControls
{

    relativeSizes true;

    layers
    {
        geofull_tank 
        {
            nSurfaceLayers 1; 
        }
        geofull_needle1
        {
            nSurfaceLayers 2; 
        }
        geofull_needle2 
        {
            nSurfaceLayers 2; 
        }
        geofull_needle3 
        {
            nSurfaceLayers 2; 
        }
    }

    expansionRatio 1.0;

    finalLayerThickness 0.3;

    minThickness 0.25;

    nGrow 0;

    // Advanced settings

    featureAngle 30;
    
    slipFeatureAngle 30;

    nRelaxIter 5;

    nSmoothSurfaceNormals 1;

    nSmoothNormals 3;

    nSmoothThickness 10;

    maxFaceThicknessRatio 0.5;

    maxThicknessToMedialRatio 0.3;

    minMedianAxisAngle 90;

    nBufferCellsNoExtrude 1;

    nLayerIter 50;

    nRelaxedIter 20; 
}


meshQualityControls
{
//    #include "meshQualityDict"

    maxNonOrtho 65;
    
    maxBoundarySkewness 20;
    maxInternalSkewness 4;
    
    maxConcave 80; 
    
    minFlatness 0.5;

    minVol 1e-13;

    minArea -1;
    
    minTetQuality 1e-30;

    minTwist 0.05;

    minDeterminant 0.001;

    minFaceWeight 0.05;

    minVolRatio 0.01;

    minTriangleTwist -1;

    //minVolCollapseRatio 0.5;
    
    //Advanced

    nSmoothScale 4;
    errorReduction 0.75;

    relaxed
    {
        maxNonOrtho 75;
     }
}

// Write flags
//writeFlags
//(
//    scalarLevels
//    layerSets
//    layerFields     // write volScalarField for layer coverage
//);


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


// ************************************************************************* //
Attached Images
File Type: jpg Screenshot from 2018-09-28 15-56-49.jpg (87.0 KB, 296 views)
File Type: jpg Screenshot from 2018-09-28 15-58-23.jpg (40.0 KB, 272 views)
Attached Files
File Type: txt log.snappyHexMesh.txt (177.8 KB, 5 views)
File Type: txt log.meshQuality.txt (5.7 KB, 7 views)
y_jiang is offline   Reply With Quote

Old   November 21, 2018, 09:49
Default
  #2
Member
 
Stefanie Wolf
Join Date: Nov 2018
Location: Aachen
Posts: 32
Rep Power: 7
Stefanie.S.W. is on a distinguished road
Dear y_jiang,



i reduced the no of my errors by implementing a finer block mesh in critical areas. I tried to define at least two cells per surface, so that every surface is crossed by at least one cell. Means, if the cells in the area around the needle holes are a tiny bit smaller than the holes, there never is the surface of the hole only in one cell.



I picture it like this: snapping is easier when cells can be broken to the surface of the geometry. But unfortunately I only started working with openFoam about a month ago, so I am not sure if my explanation is true...

But it worked for me, so maybe it will help you.



In addition I changed my ControlDict to write in binary, used "surfaceFeatureExtract" and used the "xxx.eMesh" geometries for the features in the snappyHexMeshDict.
I still have some remaining issues, which I will post in this forum:
ww.cfd-online.com/Forums/openfoam/211620-snappyhexmesh-stl-geometry.html
Stefanie.S.W. is offline   Reply With Quote

Old   November 21, 2018, 15:14
Smile
  #3
Member
 
Yijiu Jiang
Join Date: Jan 2013
Location: Michigan, US
Posts: 49
Rep Power: 13
y_jiang is on a distinguished road
Dear Stefanie,


Thank you for the inputs. Actually my issue was solved by adjusting the cells size in blockMeshDict. I just did not have a chance to update my post here.
With the following blockMeshDict and snappyHexMeshDict I just got 1 failure for concave cells which did not crash my simulation job. The other interesting thing I found is that when you define the bounding box, try to start from all the vertices at min X, and then max X. Otherwise, snappyHexMesh may fail to remove the cells in the region you do not want to keep for some cases. Hopefully these could benefit your foam exploration



Code:
/*---------------------------------------------------------------------------*\
| =========                 |                                                 |
| \      /  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;

    root            "";
    case            "";
    instance        "";
    local           "";

    class           dictionary;
    object          blockMeshDict;
}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


convertToMeters 1;

vertices
(
    (2737.91    -683.83    576.5)
    (4396.17    -683.83    576.5)
    (4396.17    76.89999999999998    576.5)
    (2737.91    76.89999999999998    576.5)
    (2737.91    -683.83    1201.26)
    (4396.17    -683.83    1201.26)
    (4396.17    76.89999999999998    1201.26)
    (2737.91    76.89999999999998    1201.26)
);

blocks
(
    hex (0 1 2 3 4 5 6 7) (138 63 52) simpleGrading (1 1 1)
);

edges
(
);

patches
(
);

// ************************************************************************* //
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.0.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
|    \\/     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
{
    geofull.stl
    {
        type triSurfaceMesh;
        name geofull;
    }
    // Add bounding box
};



// Settings for the castellatedMesh generation.
castellatedMeshControls
{

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

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

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

    // Allow a certain level of imbalance during refining
    // (since balancing is quite expensive)
    // Expressed as fraction of perfect balance (= overall number of cells /
    // nProcs). 0=balance always.
    maxLoadUnbalance 0.10;

    // Number of buffer layers between different levels.
    // 1 means normal 2:1 refinement restriction, larger means slower
    // refinement.
    nCellsBetweenLevels 2;
   
    // 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 "geofull.eMesh";
             level 2; // Refinement level
        }
   );



    // 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
    {
       geofull
       {
            // Surface-wise min and max refinement level
    //        level (9 9);
             level (3 5); // Refinement level
    }
    }

    resolveFeatureAngle 30;


    // 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
    {
        // Add refinement
    }


    // 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.
    // This is an outside point locationInMesh (-0.033 -0.033 0.0033);
    locationInMesh (3366.52201401741 -248.063853989801 1013.5449919431172); // Inside point

    // Whether any faceZones (as specified in the refinementSurfaces)
    // are only on the boundary of corresponding cellZones or also allow
    // free-standing zone faces. Not used if there are no faceZones.
    allowFreeStandingZoneFaces true;
}



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

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

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

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

    //- Highly experimental and wip: number of feature edge snapping
    //  iterations. Leave out altogether to disable.
    nFeatureSnapIter 10;    
}



// Settings for the layer addition.
addLayersControls
{
    // Are the thickness parameters below relative to the undistorted
    // size of the refined cell outside layer (true) or absolute sizes (false).
    relativeSizes true;

    // Per final patch (so not geometry!) the layer information
    layers
    {
        geofull_tank
        {
            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.
    //  See relativeSizes parameter.
    finalLayerThickness 0.3;

    //- Minimum thickness of cell layer. If for any reason layer
    //  cannot be above minThickness do not add layer.
    //  See relativeSizes parameter.
    minThickness 0.25;

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


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

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

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


    // Overall max number of layer addition iterations. The mesher will exit
    // if it reaches this number of iterations; possibly with an illegal
    // mesh.
    nLayerIter 50;

    // Max number of iterations after which relaxed meshQuality controls
    // get used. Up to nRelaxIter it uses the settings in meshQualityControls,
    // after nRelaxIter it uses the values in meshQualityControls::relaxed.
    nRelaxedIter 20;
}



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

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

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

    //- Minimum quality of the tet formed by the face-centre
    //  and variable base point minimum decomposition triangles and
    //  the cell centre.  Set to very negative number (e.g. -1E30) to
    //  disable.
    //     <0 = inside out tet,
    //      0 = flat tet
    //      1 = regular tet
    minTetQuality 1e-30;

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

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

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

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

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

    //- if >0 : preserve single cells with all points on the surface if the
    //  resulting volume after snapping (by approximation) is larger than
    //  minVolCollapseRatio times old volume (i.e. not collapsed to flat cell).
    //  If <0 : delete always.
    //minVolCollapseRatio 0.5;


    // Advanced

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



    // Optional : some meshing phases allow usage of relaxed rules.
    // See e.g. addLayersControls::nRelaxedIter.
    relaxed
    {
        //- Maximum non-orthogonality allowed. Set to 180 to disable.
        maxNonOrtho 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;
Pagoda and Stefanie.S.W. like this.

Last edited by y_jiang; November 26, 2018 at 13:25.
y_jiang is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[snappyHexMesh] Error snappyhexmesh - Multiple outside loops avinashjagdale OpenFOAM Meshing & Mesh Conversion 53 March 8, 2019 09:42
Transient Phase Change Model: Explodes at low vapor quality evcelica CFX 0 August 28, 2018 10:55
[ICEM] Why the quality is very low? anijg05 ANSYS Meshing & Geometry 0 July 26, 2018 05:39
Improve the mesh quality bithnxtlz FLUENT 1 April 30, 2016 12:20
[ICEM] Heart modeling - ICEM Hexa Mesh quality improvement heart_modeller ANSYS Meshing & Geometry 1 April 8, 2016 08:16


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