CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[snappyHexMesh] Creating multiple multiple cell zones with snappyHexMesh - a newbie in deep water!

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

LinkBack Thread Tools Search this Thread Display Modes
Old   January 23, 2019, 04:17
Default Creating multiple multiple cell zones with snappyHexMesh - a newbie in deep water!
Join Date: Mar 2014
Posts: 56
Rep Power: 12
divergence is on a distinguished road
Dear all,

As a OpenFoam newbie, I have been struggling with the concept of creating multiple cell zones in a mesh with snappyHexMesh (later on sHM). I have been searching for guidance in the internet for a while, and it seems that chtMultiRegionFoam from the $FOAM_TUTORIALS should meet my needs. However, after trying over and over again, I have sadly failed to create a mesh with multiple regions. Thus, I would ask for for some guidance from this wonderful forum full of geniouses of OpenFoam.

I'm ultimately trying to create a mesh with multiple cell zones with sHM for Fluent. My example case is simply two cylinders wrapped around each other. If you would check the attached picture, you would see an illustration of the case. The inner cylinder has been used to cut the outer volume so that the outer volume has the shape of a pipe or an extruded ring, if you will. Additionally, I have included walls for the outer surfaces of both of the volumes.

My snappyHexMeshDict is constructed as follows:

    version     2.0;
    format      ascii;
    class       dictionary;
    object      snappyHexMeshDict;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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

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

    wall_bigPipe.stl {type triSurfaceMesh; name wall_bigPipe;}
    wall_smallPipe.stl {type triSurfaceMesh; name wall_smallPipe;}
    wall_wall1.stl {type triSurfaceMesh; name wall_wall1;}
    wall_wall2.stl {type triSurfaceMesh; name wall_wall2;}


// Settings for the castellatedMesh generation.

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

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

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

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

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

    // Specifies a level for any cell intersected by its edges.
    // This is a featureEdgeMesh, read from constant/triSurface for now.

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


            // Surface-wise min and max refinement level
            level (2 3);

            faceZone wall_bigPipe;
            cellZone wall_bigPipe;
            cellZoneInside inside;

            // Surface-wise min and max refinement level
            level (2 3);

            faceZone wall_smallPipe;
            cellZone wall_smallPipe;
            cellZoneInside inside;
       wall_wall1 { level (2 3); }
       wall_wall2 { level (2 3); }

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



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

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

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

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

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

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

    // Feature snapping

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

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

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

        multiRegionFeatureSnap true;

// Settings for the layer addition.
    // 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.
    // is the thickness of the layer furthest away from the wall.
    // 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 10;

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

    // Advanced

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

// Advanced

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

// ************************************************************************* //
After executing runBlock and runSnappy commands, I have tried both "splitMeshRegions -cellzones -overwrite" and "splitMeshRegions -cellzonesOnly -overwrite". With the latter command I received the following text in the terminal:

 splitMeshRegions -cellZonesOnly -overwrite
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:
    \\  /    A nd           | Version:  6
     \\/     M anipulation  |
Build  : 6-6257b17a4cf8
Exec   : splitMeshRegions -cellZonesOnly -overwrite
Date   : Jan 23 2019
Time   : 09:01:59
Host   : "myComputer"
PID    : 17503
I/O    : uncollated
Case   : /home/myName/workFolder/testCase
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 mesh for time = 0

Creating single patch per inter-region interface.

Using current cellZones to split mesh into regions. This requires all cells to be in one and only one cellZone.

Number of regions:2

Writing region per cell file (for manual decomposition) to "/home/myName/workFolder/testCase/constant/cellToRegion"

Writing region per cell as volScalarField to "/home/myName/workFolder/testCase/0/cellToRegion"

Region    Cells
------    -----
0    0
1    23840

Region    Zone    Name
------    ----    ----
0    0    wall_bigPipe
1    1    wall_smallPipe

Sizes of interfaces between regions:

Interface    Region    Region    Faces
---------    ------    ------    -----

Reading volScalarField cellToRegion

Adding patches

Adding patches

Region 0
Creating mesh for region 0 wall_bigPipe
Writing dummy "wall_bigPipe/fvSchemes"
Writing dummy "wall_bigPipe/fvSolution"
Mapping fields
Mapping field cellToRegion
Deleting empty patches
Writing new mesh
Writing addressing to base mesh
Writing map pointRegionAddressing from region0 points back to base mesh.
Writing map faceRegionAddressing from region0 faces back to base mesh.
Writing map cellRegionAddressing from region0 cells back to base mesh.
Writing map boundaryRegionAddressing from region0 boundary back to base mesh.

Region 1
Creating mesh for region 1 wall_smallPipe
Mapping fields
Mapping field cellToRegion
Deleting empty patches
Writing new mesh
Writing addressing to base mesh
Writing map pointRegionAddressing from region1 points back to base mesh.
Writing map faceRegionAddressing from region1 faces back to base mesh.
Writing map cellRegionAddressing from region1 cells back to base mesh.
Writing map boundaryRegionAddressing from region1 boundary back to base mesh.
Accordingly, I have now two regions and no cells in one of them. I also tried to convert the created mesh into Fluent by running foamMeshToFluent and foamMeshToEnsight but these tests did not deliver what I needed.

I realize that similar question have been asked before but I am still eager to ask this question in a new thread, seeing that I could not find suitable solution for my problem elsewhere. If anyone could shed some light into this mess, I would not hesitate to give my highest regards and all the thumbs up symbols CFD Online will provide!


edit: The reason for wanting separate cell zones is to define one region as a solid and the second one as fluid.
Attached Images
File Type: png pipes.PNG (35.7 KB, 113 views)

Last edited by divergence; January 23, 2019 at 05:39.
divergence is offline   Reply With Quote


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
[CAD formats] Creating waterproof STL using snappyHexMesh or salome Tobi OpenFOAM Meshing & Mesh Conversion 58 May 13, 2020 06:01
[mesh manipulation] How to write cellSet for different regions in constant/polyMesh/sets Struggle_Achieve OpenFOAM Meshing & Mesh Conversion 3 June 17, 2019 09:29
Possible Bug in pimpleFoam (or createPatch) (or fluent3DMeshToFoam) cfdonline2mohsen OpenFOAM 3 October 21, 2013 09:28
[Workbench] Creation of Cell Zones for processing in FLUENT kailingkk ANSYS Meshing & Geometry 0 October 5, 2013 05:09
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Meshing & Mesh Conversion 2 July 15, 2005 04:15

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