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] conformal multi-region meshing and feature capturing (https://www.cfd-online.com/Forums/openfoam-meshing/232324-conformal-multi-region-meshing-feature-capturing.html)

dasbrot December 9, 2020 10:20

conformal multi-region meshing and feature capturing
 
5 Attachment(s)
Hi there,

I have a multi-region case which consists of three regions, two solid and one fluid part. In the first picture attached, the top solid part is green, the fluid part red and the bottom part is grey.

The meshing process itself works fine, I pre-processed the surface files with Salome where they match exactly. I created the background mesh with salome, too.

As you can see in pictures 2, the top solid part has a fin, which is cooled by the fluid. Now I have multiple problems regarding SHM:

1. especially around the fin I would like to get a conformal mesh between the solid and the fluid. Both surface triangulations match exactly (as I can see in Salome), both refinement levels match and the background mesh is the same, so what could be the reason for this? Moreover, if you take a closer look at the mesh the surface looks really strange (red circles in picture 3). I guess it is just a display error by paraview (those lines are the edges of the cells of the other region, picture 4) but still I would like to have a conformal mesh or at least nearly-conformal.

2. The cells are sometimes quite 'wobbly'. By that I mean SHM sometimes doesn't use a perfect hex cell even though it could and should (you can see that e.g. in the second picture)

3. Last but not least I would like to use an even coarser grid to test grid convergence etc. And this fin is only one of 100, so the total domain is much bigger. But if I use a coarser background mesh at some points the feature edges aren't snapped to at all. Any help would be appreciated (picture 5)

Thank you all!

snappyHexMeshDict (only part of it)
Code:

geometry
{
        fluid.stl
        {
                type        triSurfaceMesh;
                name        fluid;
       
                regions
                {
                        inlet        { name inlet; }
                        outlet        { name outlet; }
            transferWall        { name transferWall; }
            finWall                        { name finWall; }
                }
        }
        topSolid.stl
        {
                type        triSurfaceMesh;
                name        topSolid;
       
                regions
                {
                        ambientWall        { name ambientWall; }
                        solidWall        { name solidWall; }
                        fluidWall        { name fluidWall; }
            heatsourceWall        { name heatsourceWall; }
            finWall { name finWall; }
                }
        }       
        bottomSolid.stl
        {
                type        triSurfaceMesh;
                name        bottomSolid;
       
                regions
                {
                        ambientWall        { name ambientWall; }
                        solidWall        { name solidWall; }
                        fluidWall        { name fluidWall; }
                }
        }       

};


// Settings for the castellatedMesh generation.
castellatedMeshControls
{

    maxLocalCells 1000000;
    maxGlobalCells 20000000;
    minRefinementCells 0;
    maxLoadUnbalance 0.10;
    nCellsBetweenLevels 2;

    features
    (       
        {
                        file "fluid.eMesh";
                        level 1;
                }                       
                {
                        file "topSolid.eMesh";
                        level 1;
                }
                {
                        file "bottomSolid.eMesh";
                        level 1;
                }                                       
    );


    // Surface based refinement
    // ~~~~~~~~~~~~~~~~~~~~~~~~
    refinementSurfaces
    {
        fluid
                {
                        // default level (first entry is minimum, second is maximum refinement,
                        // depending on resolveFeatureAngle
                        level (0 0);
                       
                        // define cell set to be able to split afterwards
                        cellZone fluid;
                        faceZone fluid;
            cellZoneInside inside;
            // cellZoneInside insidePoint;
            // insidePoint (0.001 0.004 0.006);
           
                        regions
                        {
                                inlet        { level (0 0); patchInfo { type patch; }}
                                outlet        { level (0 0); patchInfo { type patch; }}
                transferWall        { level (0 0); patchInfo { type wall; }}
                finWall        { level (3 3); patchInfo { type wall; }}
                        }
                       
                }
                topSolid
                {
                        // default level (first entry is minimum, second is maximum refinement,
                        // depending on resolveFeatureAngle
                        level (0 0);
                                                                               
                        // define cell set to be able to split afterwards
                        cellZone topSolid;
                        faceZone topSolid;
            cellZoneInside inside;
            // cellZoneInside insidePoint;
            // insidePoint (0.001 0.001 -0.001);
                       
                        regions
                        {
                                ambientWall        { level (0 0); patchInfo { type wall; }}
                                solidWall        { level (0 0); patchInfo { type wall; }}
                                fluidWall        { level (0 0); patchInfo { type wall; }}
                heatsourceWall        { level (0 0); patchInfo { type wall; }}
                finWall { level (3 3); patchInfo { type wall; }}
                        }       
                }
                bottomSolid
                {
                        // default level (first entry is minimum, second is maximum refinement,
                        // depending on resolveFeatureAngle
                        level (0 0);
                       
                        // define cell set to be able to split afterwards
                        cellZone bottomSolid;
                        faceZone bottomSolid;
            cellZoneInside inside;
            // cellZoneInside insidePoint;
            // insidePoint (0.001 0.001 0.01);
                       
                        regions
                        {
                                ambientWall        { level (0 0); patchInfo { type wall; }}
                                solidWall        { level (0 0); patchInfo { type wall; }}
                                fluidWall        { level (0 0); patchInfo { type wall; }}
                        }
                }
    }

    resolveFeatureAngle 30;
    planarAngle 180;


    // Region-wise refinement
    // ~~~~~~~~~~~~~~~~~~~~~~

    refinementRegions
    {
    }

   
    limitRegions
    {
    }

    // Mesh selection
    // ~~~~~~~~~~~~~~

   
        // Ad 1. Specify a single location and how to treat faces inbetween
        //      cellZones
        locationInMesh (0.005 0.006 0.005);
        allowFreeStandingZoneFaces true;
       
}

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

    // Optional: number of smoothing iterations for internal points on
    // refinement interfaces. This will reduce non-orthogonality on
    // refinement interfaces.
    nSmoothInternal $nSmoothPatch;

    // Maximum relative distance for points to be attracted by surface.
    // True distance is this factor times local maximum edge length.
    tolerance 5;  // 1.0

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

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

    // Feature snapping

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

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

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

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


        // When to run face splitting (never at first iteration, always
        // at last iteration). Is interval. Default -1 (disabled)
        // Recommendation: set to half the number of feature snap iterations
        // used to better capture 90°-edges
                // https://www.openfoam.com/releases/openfoam-v3.0+/meshing.php
        nFaceSplitInterval 5;

}

// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
meshQualityControls
{
    // Specify mesh quality constraints in separate dictionary so can
    // be reused (e.g. checkMesh -meshQuality)
    #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 85;
    }
    // Advanced

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

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

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


dasbrot December 9, 2020 11:23

1 Attachment(s)
Just to add another picture .. In white are the feature edges

Ship Designer December 18, 2020 00:14

Hello Henning,

For the feature snapping problem, I suggest you try a tolerance set to 1. What you have circled in red in picture 3 could very well still be a hexahedron but with a point moved in such a way that two edges are collinear. That's what snappyHexMesh does, it moves points of cells to be on the snapping surface and changes cells into wedges, polyhedra etc. if needed.

I'm not quite sure what you need snappyHexMesh for, if the input geometry is already the way you want. If you just need to refine the fin (diamond shaped object?) and add the patches, you could do the same with refineMesh and createPatch but with less mesh distortion I believe. The way I see it, the geometry is so simple that it could be created with blockMesh alone, without need for snapping. With cell grading you could refine the mesh where needed or even add very precise boundary layers.

Cheers, Claudio

dasbrot December 18, 2020 07:00

4 Attachment(s)
Hey Claudio,

thank you for replying! In the meantime I played a little bit with snappyHexMesh parameter and I came with a mediocre solution, but better than before.

The most important parameter I changed were
- tolerance to 1.0 (as you also suggested, thanks!)
- raised nSolveIter back to 300
- set nSmoothPatch to 0 because there is nothing to smooth in this example
- raised featureSnapIterations to 20, though a larger number made things worse again

With these settings the geometry was captured okay, but the mesh looks a little strange in the corners (picture 1). That's what I don't understand about snappyHexMesh.. Why doesn't it leave the background mesh 'as is' where there either isn't anything to snap to or where it should just keep the straight line to capture things accurately?

With implicit feature edge capturing the mesh looks a lot worse (picture 2).

What helped was the parameter stringFeatures set to false. With that the mesh looks actually quite good, except for those "edges" at the diamond shape. It's really starting to get on my nerves.

The problem is, that the geometry is actually larger and more complex, especially at the in- and outlet. This was just a testcase to figure out the best settings and use them to mesh the overall geometry later. So blockMesh is not a suitable way. But since I set nSmoothPatch to zero, I don't know whether those shapes will be captured okay. With smoothing iterations set to 5 the feature edges aren't fully captured and mesh looks strange (picture 4, same settings as in picture 1 otherwise). Why? :mad::confused:


By the way, I have to use snappyHexMesh

jurich December 18, 2020 14:37

Hello Henning,

I had a similar issue once and, if I remember correctly, the solution was to set implicitFeatureSnap to true. That setting is used in the shellAndTubeHeatExchanger and pimpleFoam/propeller tutorials.

I hope that helps.


All times are GMT -4. The time now is 21:46.