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

[snappyHexMesh] Surface triangulation using snappyHexMesh

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 20, 2018, 10:05
Default Surface triangulation using snappyHexMesh
  #1
Member
 
Shailesh BG
Join Date: Aug 2017
Location: Bangalore
Posts: 39
Rep Power: 8
shaileshbg is on a distinguished road
Hello,

My geometry is very similar to the iglooWithFridges tutorial, I have a hemispherical dome of 5mm thickness (inner_radius = 0.067m and outer_radius = 0.072m)
In snappyHexMeshDict I have used "searchableSphere", to define my hemispheres as in the tutorial. But the surface temperature pattern of the converged solution (h tolerance 1*e-8) has a lot of concentric circles and irregular patterns on it.

When I see the surface mesh structure it is very bad and the temperature pattern seems to be mimicking the underlying mesh arrangement. Please find below:

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

convertToMeters 1;

vertices
(
    (-0.072 0  -0.072)
    ( 0.072 0  -0.072)
    ( 0.072  0.072  -0.072)
    (-0.072  0.072  -0.072)
    (-0.072 0   0.072)
    ( 0.072 0   0.072)
    ( 0.072  0.072   0.072)
    (-0.072  0.072   0.072)
);

blocks
(
    hex (0 1 2 3 4 5 6 7) (35 35 35) simpleGrading (1 1 1)
);

edges
(
);

boundary
(
    top
    {
        type wall;
        faces
        (
            (3 7 6 2)
        );
    }
    left
    {
        type patch;
        faces
        (
            (0 4 7 3)
        );
    }
    right
    {
        type patch;
        faces
        (
            (2 6 5 1)
        );
    }
    adiabatic_wall
    {
        type wall;
        faces
        (
            (1 5 4 0)
        );
    }
    back
    {
        type wall;
        faces
        (
            (0 3 2 1)
        );
    }
    front
    {
        type wall;
        faces
        (
            (4 5 6 7)
        );
    }
);

mergePatchPairs
(
);

// ************************************************************************* //
2) snappyHexMeshDict
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  5                                     |
|   \\  /    A nd           | Web:      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
{
    skin
    {
        type searchableSphere;
        centre (0 0 0);
        radius 0.072;
    }
    gland_int
    {
        type searchableSphere;
        centre (0 0 0);
        radius 0.067;
    }
};



// Settings for the castellatedMesh generation.
castellatedMeshControls
{

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

    // If local number of cells is >= maxLocalCells on any processor
    // switches from from refinement followed by balancing
    // (current method) to (weighted) balancing before refinement.
    maxLocalCells 100000;

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

    // 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 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 "tissue.eMesh";
            level 3;
        }
    );



    // 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
    {
                "skin.*"
        {
            // Surface-wise min and max refinement level
            level (1 3);

            // Optional specification of patch type (default is wall). No
            // constraint types (cyclic, symmetry) etc. are allowed.
            patchInfo
            {
                type        wall;
            }
        }
                      
                  "gland_int.*"
        {
            // Surface-wise min and max refinement level
            level (1 3);

            // Optional specification of patch type (default is wall). No
            // constraint types (cyclic, symmetry) etc. are allowed.
            patchInfo
            {
                type        wall;
            }
        }
             
     }

    // Resolve sharp angles 
    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
    {
    }


    // 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 (0 0.07 0);


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

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


    // Feature snapping

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

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

        //- Use castellatedMeshControls::features (default = true)
        explicitFeatureSnap false;
}




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

    // 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.
    // See relativeSizes parameter.
    finalLayerThickness 0.5;

    // 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.
    // 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.
    // Note: changed(corrected) w.r.t 17x! (didn't do anything in 17x)
    nGrow 0;


    // Advanced settings

    // When not to extrude surface. 0 is flat surface, 90 is when two faces
    // are perpendicular
    featureAngle 60;

    // 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
    // Note: changed(corrected) w.r.t 16x! 90 degrees corresponds to 130 in 16x.
    minMedianAxisAngle 90;

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


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

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

    //- 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. This has to be a positive number for tracking
    //  to work. Set to very negative number (e.g. -1E30) to
    //  disable.
    //     <0 = inside out tet,
    //      0 = flat tet
    //      1 = regular tet
    minTetQuality -1e30;

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

// ************************************************************************* //
3) chechMesh with -constant -allGeometry and -allTopology enabled:
Code:
/*---------------------------------------------------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  5.x                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
Build  : 5.x-197d9d3bf20a
Exec   : checkMesh -constant -allGeometry -allTopology
Date   : Apr 20 2018
Time   : 18:38:43
Host   : "shailesh-office"
PID    : 15016
I/O    : uncollated
Case   : /home/shailesh/Niramai/Niramai_cases/with_subprocess/tissue
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create polyMesh for time = constant

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

Enabling all geometry checks.

Time = constant

Mesh stats
    points:           45828
    faces:            114686
    internal faces:   92036
    cells:            36766
    faces per cell:   5.62264
    boundary patches: 3
    point zones:      0
    face zones:       0
    cell zones:       0

Overall number of cells of each type:
    hexahedra:     25550
    prisms:        3462
    wedges:        0
    pyramids:      0
    tet wedges:    49
    tetrahedra:    0
    polyhedra:     7705
    Breakdown of polyhedra by number of faces:
        faces   number of cells
            4   4413
            5   2750
            6   184
            7   9
            8   4
            9   289
           12   47
           15   4
           18   5

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.
    Face-face connectivity OK.
    Number of regions: 1 (OK).

Checking patch topology for multiply connected surfaces...
                   Patch    Faces   Points                  Surface topology Bounding box
          adiabatic_wall      972     1202  ok (non-closed singly connected) (-0.07200057 0 -0.07200057) (0.07200922 0 0.0720023)
                    skin    11774    14388  ok (non-closed singly connected) (-0.07200057 0 -0.07200057) (0.07200922 0.072 0.0720023)
               gland_int     9904    12103  ok (non-closed singly connected) (-0.0670025 0 -0.0670025) (0.06700874 0.067 0.06700874)

Checking geometry...
    Overall domain bounding box (-0.07200057 0 -0.07200057) (0.07200922 0.072 0.0720023)
    Mesh has 3 geometric (non-empty/wedge) directions (1 1 1)
    Mesh has 3 solution (non-empty) directions (1 1 1)
    Boundary openness (-3.212073e-16 1.233535e-15 -1.489339e-16) OK.
    Max cell openness = 2.991617e-16 OK.
    Max aspect ratio = 6.68332 OK.
    Minimum face area = 4.107907e-08. Maximum face area = 8.233134e-06.  Face area magnitudes OK.
    Min volume = 1.066943e-11. Max volume = 8.01391e-09.  Total volume = 0.0001517856.  Cell volumes OK.
    Mesh non-orthogonality Max: 59.97431 average: 13.79679
    Non-orthogonality check OK.
    Face pyramids OK.
    Max skewness = 2.044807 OK.
    Coupled point location match (average 0) OK.
    Face tets OK.
    Min/max edge length = 0.0001321193 0.003578196 OK.
   *There are 95 faces with concave angles between consecutive edges. Max concave angle = 36.95977 degrees.
  <<Writing 95 faces with concave angles to set concaveFaces
    Face flatness (1 = flat, 0 = butterfly) : min = 0.8505382  average = 0.9918693
    All face flatness OK.
    Cell determinant (wellposedness) : minimum: 0.1125888 average: 3.694367
    Cell determinant check OK.
 ***Concave cells (using face planes) found, number of cells: 240
  <<Writing 240 concave cells to set concaveCells
    Face interpolation weight : minimum: 0.1119196 average: 0.4449788
    Face interpolation weight check OK.
    Face volume ratio : minimum: 0.0262782 average: 0.7161729
    Face volume ratio check OK.

Failed 1 mesh checks.

End
I read on the forum that concave cells error is more of a warning message and can be safely ignored.


This is a simplified version of my problem wherein which I am considering the internal field to be of a uniform temperature of 30c.
The surface is exposed to air with a constant temperature of 22c and h = 13.5W/mK and the 5mm thickness ring is adiabatic.
I have two heat sources defined in my fvOptions file.

One of the alternatives that I learned was to draw my own stl file in blender/salome and mesh it in salome keeping in mind surface triangulation, then import into snappyHexMesh and define different cellzones there. But I am working on parametric analysis and would want to vary my geometry, for that I am using pyFoamFromTemplate to parse the parameter files
Code:
$$ gland_radius = gr
$$ skin_radius = sr

geometry
{
    skin
    {
        type searchableSphere;
        centre (0 0 0);
        radius $skin_radius$;
    }
    gland_int
    {
        type searchableSphere;
        centre (0 0 0);
        radius $gland_radius$;
    }
};
As you can see this method is ideally suited for me. Since my surface mesh is so bad what I want maybe is surface triangulation equivalent in SHM.
Any help and suggestion would be very helpful to me as I am struggling and have no clue on how to move forward.


Please find attached:
1) Image of surface temperature distribution.
2) Surface temperature distribution mapped on a wireframe model.
3) C/S view of the mesh.
Attached Images
File Type: png surface_temperature.png (126.6 KB, 80 views)
File Type: jpg surface_temp_on_wireframe.jpg (50.8 KB, 72 views)
File Type: png Cross_section_wireframe.png (35.0 KB, 51 views)
__________________
Regards,
Shailesh
shaileshbg is offline   Reply With Quote

Old   April 21, 2018, 14:14
Default
  #2
Member
 
Shailesh BG
Join Date: Aug 2017
Location: Bangalore
Posts: 39
Rep Power: 8
shaileshbg is on a distinguished road
Please help
__________________
Regards,
Shailesh
shaileshbg is offline   Reply With Quote

Old   April 23, 2018, 08:10
Default Wireframe
  #3
Member
 
Shailesh BG
Join Date: Aug 2017
Location: Bangalore
Posts: 39
Rep Power: 8
shaileshbg is on a distinguished road
Hello,

This is basically the problem that I am facing. As you can see in the attached wireframe image of the surface, there are patches that are meshed as a flat surface area, surrounding which are concentric rings of unstructured mesh.

I have basically copied the snappyHexMesh settings from the igloo tutorial. My geometry is 5mm thick, maybe that is the reason. Please, any help would be highly appreciated.
Attached Images
File Type: png wireframe.png (105.3 KB, 59 views)
__________________
Regards,
Shailesh
shaileshbg is offline   Reply With Quote

Old   October 10, 2019, 04:50
Default
  #4
Member
 
Andrew
Join Date: Mar 2018
Posts: 82
Rep Power: 8
Astan is on a distinguished road
Hi shaileshbg, i am facing with the same problem but on a different geometry.


In the end do you managed to solve the problem?

Astan
Astan is offline   Reply With Quote

Old   October 17, 2019, 04:42
Default TopoSet to define different regions
  #5
Member
 
Shailesh BG
Join Date: Aug 2017
Location: Bangalore
Posts: 39
Rep Power: 8
shaileshbg is on a distinguished road
Hi Andrew,

We needed multiple regions to be created, generating an unstructured mesh inside a small region of 5mm was creating the problem. The workaround we found was to use topoSet to define different regions inside a bigger mesh.
__________________
Regards,
Shailesh
shaileshbg is offline   Reply With Quote

Reply

Tags
bad boundary mesh, snappyhexmesh 3d, temperature distribution


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] snappyHexMesh surface refinement bugs wc34071209 OpenFOAM Meshing & Mesh Conversion 9 October 7, 2018 06:53
[snappyHexMesh] snappyHexMesh inclinced surface snapping problem Swift OpenFOAM Meshing & Mesh Conversion 19 January 18, 2017 04:42
[Gmsh] Problem with Gmsh nishant_hull OpenFOAM Meshing & Mesh Conversion 23 August 5, 2015 02:09
[snappyHexMesh] How to create internal boundaries using snappyHexMesh robyTKD OpenFOAM Meshing & Mesh Conversion 2 October 19, 2014 09:57
Cluster ID's not contiguous in compute-nodes domain. ??? Shogan FLUENT 1 May 28, 2014 15:03


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