CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing & Mesh Conversion (https://www.cfd-online.com/Forums/openfoam-meshing/)
-   -   [snappyHexMesh] Bad looking cells with CastelledMesh (https://www.cfd-online.com/Forums/openfoam-meshing/223345-bad-looking-cells-castelledmesh.html)

juvima January 7, 2020 07:17

Bad looking cells with CastelledMesh
 
3 Attachment(s)
Hello everybody, I'm struggling with some bad looking cells generated by the CastellatedMesh step of my snappyHexMeshDict file, cf. pictures. As you can see, some cells are extremely plane/crushed. I tried changing several parameters of my snappyHexMeshDict file, but the output doesn't change. This is my code:
Code:

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

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

#include "include/inputVariables" //definition of input values
offset 1; //offset

x_positive #calc "3*$offset + $n_panel_x_dir*$x_panel";
x_negative #calc "-1*$offset";
y_positive #calc "0.5*$y_panel + $offset";
y_negative #calc "-1*$y_positive";
z_positive #calc "1.5*$offset";

// 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
{
    Panel_0
    {
        type triSurfaceMesh;
        file "Panel_0.stl";
    }
    Panel_1
    {
        type triSurfaceMesh;
        file "Panel_1.stl";
    }
    Panel_2
    {
        type triSurfaceMesh;
        file "Panel_2.stl";
    }
    Panel_3
    {
        type triSurfaceMesh;
        file "Panel_3.stl";
    }

    Panel_4
    {
        type triSurfaceMesh;
        file "Panel_4.stl";
    }
    Panel_5
    {
        type triSurfaceMesh;
        file "Panel_5.stl";
    }
   
 
    refinementBox
    {
        type searchableBox;
        min ($x_negative $y_negative 0);
        max ($x_positive $y_positive $z_positive);
    }
};



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

    // 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 3;
    nCellsBetweenLevels 10;



    // 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 "Panel_0.eMesh" "Panel_1.eMesh" "Panel_2.eMesh" "Panel_3.eMesh" "Panel_4.eMesh" "Panel_5.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
    {
        Panel_0
        {
            // Surface-wise min and max refinement level
            level (2 4);

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

        Panel_1
        {
            level (2 4);

            patchInfo
            {
                type wall;
                inGroups (Panel_PV);
            }
        }
        Panel_2
        {
            level (2 4);

            patchInfo
            {
                type wall;
                inGroups (Panel_PV);
            }
        }
        Panel_3
        {
            level (2 4);

            patchInfo
            {
                type wall;
                inGroups (Panel_PV);
            }
        }
        Panel_4
        {
            level (2 4);

            patchInfo
            {
                type wall;
                inGroups (Panel_PV);
            }
        }
        Panel_5
        {
            level (2 4);

            patchInfo
            {
                type wall;
                inGroups (Panel_PV);
            }
        }

    }

    }

    // Resolve sharp angles
    resolveFeatureAngle 30;
    // resolveFeatureAngle 0;
   

    // 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));
        levels ((1E15 4));
        }
    }


    // 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.1 0.1 0.9);


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

Surprisingly though, snappyHexMesh seems to believe that this mesh is satisfactory, as the log indicates (showing only the last iterations):
Code:

Merging all points on surface that
- are used by only two boundary faces and
- make an angle with a cosine of more than 0.707107.

Removing 2618 straight edge points ...

Edge intersection testing:
    Number of edges            : 22173899
    Number of edges to retest  : 17447
    Number of intersected edges : 1085167

Undo iteration 0
----------------
Checking faces in error :
    non-orthogonality > 65  degrees                        : 0
    faces with face pyramid volume < 1e-13                : 0
    faces with face-decomposition tet quality < 1e-15      : 0
    faces with concavity > 80  degrees                    : 0
    faces with skewness > 4  (internal) or 20  (boundary) : 0
    faces with interpolation weights (0..1)  < 0.02        : 0
    faces with volume ratio of neighbour cells < 0.01      : 0
    faces with face twist < 0.02                          : 0
    faces on cells with determinant < 0.001                : 0
Refined mesh : cells:7083129  faces:22173899  points:8009619
Cells per refinement level:
    0  42210
    1  42270
    2  158288
    3  838978
    4  6001383
Writing mesh to time constant
Wrote mesh in = 245.06 s.
Mesh refined in = 2480.19 s.
Checking final mesh ...
Checking faces in error :
    non-orthogonality > 65  degrees                        : 0
    faces with face pyramid volume < 1e-13                : 0
    faces with face-decomposition tet quality < 1e-15      : 0
    faces with concavity > 80  degrees                    : 0
    faces with skewness > 4  (internal) or 20  (boundary) : 0
    faces with interpolation weights (0..1)  < 0.02        : 0
    faces with volume ratio of neighbour cells < 0.01      : 0
    faces with face twist < 0.02                          : 0
    faces on cells with determinant < 0.001                : 0
Finished meshing without any errors
Finished meshing in = 2530.9 s.
End


Is there anything that I am missing? Which meshing parameters should I modify in order to solver this problem? Or should I change completely my approach?



Thank you a lot in advance!

AndreasPe January 7, 2020 07:53

I think these are visualization issues of paraview. Do not check the checkbox "Decompose polyhedra" in the properties of the foam-file that you load with paraview and check the crinkle slice checkbox in the slice properties in order to properly show a slice that just consists "complete" cells.

juvima January 7, 2020 09:40

1 Attachment(s)
Thank you very much! You were right, checking "Use VTK Polyhedron" (in Paraview 5.4.0) in the properties of the foam-file and checking "Crinkle Slice" in the slice properties I have a nice visualization.


Have a nice day and thank you again for your kind help.


All times are GMT -4. The time now is 08:59.