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

[snappyHexMesh] Too many cells in undesired part, very less cells in desirable part

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 7, 2023, 14:51
Unhappy Too many cells in undesired part, very less cells in desirable part
  #1
Member
 
Ash Kotwal
Join Date: Jul 2016
Location: North Dakota, USA
Posts: 92
Blog Entries: 1
Rep Power: 9
Ash Kot is on a distinguished road
Hello All SnappyHexMesh users,

After scratching my head a lot and going over multiple forum threads on this website, finally I gave up and asking help as separate thread. The given below is the snappyHexMeshDict I'm using. Apologies for large section, I decided to keep all the comments as well for easy understanding.

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2212                                 |
|   \\  /    A nd           | Website:  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
{
    inlet_airOnlyM.stl
    {
        type triSurfaceMesh;
        name inlet_airOnlyM;
    }
    inlet_fuelOnlyM.stl
    {
        type triSurfaceMesh;
        name inlet_fuelOnlyM;
    }
    outlet_M.stl
    {
        type triSurfaceMesh;
        name outlet_M;
    }
    wall_burnerM.stl
    {
        type triSurfaceMesh;
        name  wall_burnerM;
    }
    BP_A_05H_mod5_z1_6hols_M.stl
    {
        type triSurfaceMesh;
        name BP_A_05H_mod5_z1_6hols_M;
    }
    wall_furnaceM.stl
    {
        type triSurfaceMesh;
        name wall_furnaceM;
    }
    refinementSphere
    {
        type searchableSphere;
        centre (0 -0.388 0);
        radius 0.388;
    }
}

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

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

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

    // 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 "inlet_airOnlyM.eMesh";
           levels ((3 3));
        }
        
        {
           file "inlet_fuelOnlyM.eMesh";
           levels ((3 3));
        }
        
        {
           file "outlet_M.eMesh";
           levels ((3 3));
        }
        
        {
           file "wall_burnerM.eMesh";
           levels ((3 3));
        }

        {
           file "wall_furnaceM.eMesh";
           levels ((1 1));
        }
    );

    // 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
    {
        wall_burnerM
        {
            level (3 3);
            patchInfo
            {
                type wall;
                inGroups (meshedWalls);
            }
        }
        wall_furnaceM
        {
            level (1 1);
            patchInfo
            {
                type wall;
                inGroups (meshedWalls);
            }
        }
        inlet_airOnlyM
        {
            level (3 3);
            patchInfo
            {
                type inlet;
            }
        }
        inlet_fuelOnlyM
        {
            level (3 3);
            patchInfo
            {
                type inlet;
            }
        }

        outlet_M
        {
            level (3 3);
            patchInfo
            {
                type outlet;
            }
        }
    }

    resolveFeatureAngle 80; // Resolve Sharp angles // Default is 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
    {
/*        BP_A_05H_mod5_z1_6hols_M
        {
            mode distance;
            levels ((0.06 2) (0.4 1) (5 1));
        }*/
    }
    // 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 (0.0526 -0.627 0); // Inside point

    locationsInMesh
    (
        ((0.0 -0.1316 0.0849) location1)
        ((0.0 -0.331 0.0) location2)
        ((0.0 -0.687 0.0505) location3)
        ((0.0 -1.6503 0.5113) location4)
        ((0.0 -0.0491 -0.099) location5)
        ((0.0 -0.751 -0.047) location6)
        ((0.0 -0.926 -1.21) location7)
        ((0.0 -3.0 -0.5325) location8)
        ((0.0 -4.7841 -1.0837) location9)
        ((0.0 -0.187 -0.0492) location10)
        ((0.0 -0.4461 0.0918) location11)
    );

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

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

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

    // Feature snapping

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

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

        //- Use castellatedMeshControls::features
        explicitFeatureSnap true;

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

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

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

        // Wanted thickness of the layer next to the wall.
        // If relativeSizes this is relative to undistorted size of cell
        // outside layer.
        //firstLayerThickness 0.3;

        // Wanted overall thickness of layers.
        // If relativeSizes this is relative to undistorted size of cell
        // outside layer.
        //thickness 0.5

    // 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
    // are perpendicular
    featureAngle 45;

    // At non-patched sides allow mesh to slip if extrusion direction makes
    // angle larger than slipFeatureAngle.
    slipFeatureAngle 30;

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

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

    // 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
{
    #include "meshQualityDict"

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

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

// Advanced

// Write flags
writeFlags
(
    scalarLevels    // write volScalarField with cellLevel for post-processing
    layerSets       // write cellSets, faceSets of faces in layer
    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-5;

// ************************************************************************* //
The snappyHexMeshDict essentially develops mesh around Burner and Ladle furnace. I have attached the results snappyHexMesh after completion and the initial CAD design. The initial CAD design shows the correct grooves and gaps between the domain. However, the snappyHexMesh fails to create mesh around it.

Large portion of cells are filled in Ladle Furnace, which is not a good idea. However I'm not able to understand how to adjust the cells around the domain, so that very few cells are present around ladle furnace domain while concentrated cells are present inside the Burner domain. Along with that I shall create less that 5 million cells around the domain.

Please I would really like to have help to shift the cell density, reduction of overall cell count and reduction of cells in burner ladle furnace domain.

In this post, CAD_Geom1.JPG represents the burner domain cross-section. (also its first image)
CAD_Geom2.JPG represents Ladle furnace (also its second image)
snappyHexMeshed-Body1.JPG represents the domain created by snappyHexMesh utility around Burner domain (also its Third image)
snappyHexMeshed-Body2.JPG represents the domain created by snappyHexMesh utility around Ladle Furnace domain (also its Forth image)

You'll probably need to hover over the images to see the naming of the images.

'wall_burnerM.stl' in above code along with 'outlet_M.stl', 'inlet_airOnlyM.stl', and 'inlet_fuelOnlyM.stl' geometries are present in first and third images. However, the 'wall_furnaceM.stl' in above code is present in Second and Forth Images.

As reply to this message i'll post following dicts as well:
1. surfaceFeatureExtractDict
2. blockMeshDict
Attached Images
File Type: jpg CAD_Geom1.JPG (68.1 KB, 2 views)
File Type: jpg CAD_Geom2.JPG (100.6 KB, 2 views)
File Type: jpg snappyHexMeshed-Body1.JPG (88.9 KB, 3 views)
File Type: jpg snappyHexMeshed-Body2.jpg (141.6 KB, 2 views)
Ash Kot is offline   Reply With Quote

Old   August 7, 2023, 14:52
Arrow Follwing is surfaceFeatureExtractDict
  #2
Member
 
Ash Kotwal
Join Date: Jul 2016
Location: North Dakota, USA
Posts: 92
Blog Entries: 1
Rep Power: 9
Ash Kot is on a distinguished road
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2212                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      surfaceFeatureExtractDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// includedAngle:
// Mark edges whose adjacent surface normals are at an angle less
// than includedAngle as features
// - 0  : selects no edges
// - 180: selects all edges

inlet_airOnlyM.stl
{
    // How to obtain raw features (extractFromFile || extractFromSurface)
    extractionMethod    extractFromSurface;

    includedAngle       150;

    // Write options

    // Write features to obj format for postprocessing
    writeObj            yes;
}

inlet_fuelOnlyM.stl
{
    // How to obtain raw features (extractFromFile || extractFromSurface)
    extractionMethod    extractFromSurface;

    includedAngle       150;

    // Write options

    // Write features to obj format for postprocessing
    writeObj            yes;
}

outlet_M.stl
{
    // How to obtain raw features (extractFromFile || extractFromSurface)
    extractionMethod    extractFromSurface;

    includedAngle       150;

    // Write options

    // Write features to obj format for postprocessing
    writeObj            yes;
}

wall_burnerM.stl
{
    // How to obtain raw features (extractFromFile || extractFromSurface)
    extractionMethod    extractFromSurface;

    includedAngle       150;

    // Write options

    // Write features to obj format for postprocessing
    writeObj            yes;
}

wall_furnaceM.stl
{
    // How to obtain raw features (extractFromFile || extractFromSurface)
    extractionMethod    extractFromSurface;

    includedAngle       150;

    // Write options

    // Write features to obj format for postprocessing
    writeObj            yes;
}

// ************************************************************************* //
Ash Kot is offline   Reply With Quote

Old   August 7, 2023, 14:54
Default Following is BlockMeshDict
  #3
Member
 
Ash Kotwal
Join Date: Jul 2016
Location: North Dakota, USA
Posts: 92
Blog Entries: 1
Rep Power: 9
Ash Kot is on a distinguished road
The attached code in this reply is blockMeshDict.
The script creates cylindrical blockMesh with rectangle at the center:

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

scale 0.0254;

//116.167 inches column diameter
 //195.269 inches length

 //Width of middle square section

 //how many cells in the square section
 //how many cells from square section to perimeter
 // how many cells from top to bottom

vertices
(
( 29.04175 0.0 29.04175) // Vertex fiveoclocksqb = 0 
(-29.04175 0.0 29.04175) // Vertex sevenoclocksqb = 1 
(-29.04175 0.0 -29.04175) // Vertex elevenoclocksqb = 2 
( 29.04175 0.0 -29.04175) // Vertex oneoclocksqb = 3 

( 41.0712367619081 0.0 41.0712366881895) // Vertex fiveoclockcb = 4 
(-41.0712367619081 0.0 41.0712366881895) // Vertex sevenoclockcb = 5 
(-41.0712367619081 0.0 -41.0712366881895) // Vertex elevenoclockcb = 6 
( 41.0712367619081 0.0 -41.0712366881895) // Vertex oneoclockcb = 7 

( 29.04175 -195.269 29.04175) // Vertex fiveoclocksqt = 8 
(-29.04175 -195.269 29.04175) // Vertex sevenoclocksqt = 9 
(-29.04175 -195.269 -29.04175) // Vertex elevenoclocksqt = 10 
( 29.04175 -195.269 -29.04175) // Vertex oneoclocksqt = 11 

( 41.0712367619081 -195.269 41.0712366881895) // Vertex fiveoclockct = 12 
(-41.0712367619081 -195.269 41.0712366881895) // Vertex sevenoclockct = 13 
(-41.0712367619081 -195.269 -41.0712366881895) // Vertex elevenoclockct = 14 
( 41.0712367619081 -195.269 -41.0712366881895) // Vertex oneoclockct = 15 
);

blocks
(
//square block
hex (
0 1 2 3
8 9 10 11
)
(30 30 50)   // Adjusted here
simpleGrading (1 1 1)

//slice1
hex (
0 4 5 1
8 12 13 9
)
(30 30 50)   // And here
simpleGrading (1 1 1)

//slice2
hex (
1 5 6 2
9 13 14 10
)
(30 30 50)
simpleGrading (1 1 1)

//slice3
hex (
3 2 6 7
11 10 14 15
)
(30 30 50)
simpleGrading (1 1 1)

//slice4
hex (
0 3 7 4
8 11 15 12
)
(30 30 50)
simpleGrading (1 1 1)

);

//create the quarter circles
edges
(
arc 4 5 (0.0 0.0 58.0835)
arc 5 6 (-58.0835 0.0 0.0)
arc 6 7 (0.0 0.0 -58.0835)
arc 7 4 (58.0835 0.0 0.0)

arc 12 13 (0.0 -195.269 58.0835)
arc 13 14 (-58.0835 -195.269 0.0)
arc 14 15 (0.0 -195.269 -58.0835)
arc 15 12 (58.0835 -195.269 0.0)
);

boundary
(
inlet_fuelOnlyM
{
type patch;
faces
(
(0 3 2 1)
(0 4 7 3)
(4 0 1 5)
(1 2 6 5)
(3 7 6 2)
);
}

outlet_M
{
type patch;
faces
(
(8 11 10 9)
(8 12 15 11)
(12 8 9 13)
(9 10 14 13)
(11 15 14 10)
);
}

inlet_airOnlyM
{
type patch;
faces
(
(5 4 12 13)
);
}

wall_burnerM
{
type wall;
faces
(
(5 13 14 6)
);
}

wall_furnaceM
{
type wall;
faces
(
(6 14 15 7)
(7 15 12 4)
);
}
);

mergePatchPairs
(
);
Ash Kot is offline   Reply With Quote

Old   August 7, 2023, 14:56
Question
  #4
Member
 
Ash Kotwal
Join Date: Jul 2016
Location: North Dakota, USA
Posts: 92
Blog Entries: 1
Rep Power: 9
Ash Kot is on a distinguished road
please advice anyone what parameters should I change or if I missing any parameters? Or Is there a completely different approach to have a sucessful mesh?
Ash Kot is offline   Reply With Quote

Reply

Tags
snappyhexmesh cells, snappyhexmesh skewedfaces, snappyhexmeshdict

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[snappyHexMesh] snappyHexMesh sticking point natty_king OpenFOAM Meshing & Mesh Conversion 11 February 20, 2024 09:12
PEMFC tutorial case problem Suleyman41 FLUENT 2 July 15, 2023 11:16
Averaging over iterations for steady-state simulation CFD student Fluent UDF and Scheme Programming 8 September 22, 2022 03:39
chtMultiRegionFoam speed up qwertz OpenFOAM Running, Solving & CFD 8 September 18, 2021 06:16
[ICEM] error analysis despaired student ANSYS Meshing & Geometry 7 June 27, 2012 11:57


All times are GMT -4. The time now is 02:11.