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 mesh in small channel (https://www.cfd-online.com/Forums/openfoam-meshing/249986-bad-mesh-small-channel.html)

Vinzmann May 19, 2023 11:06

Bad mesh in small channel
 
1 Attachment(s)
Hello everybody,

I have a small channel in my geometry which is a kind of nozzle. My problem is that my mesh in this channel always looks horrible.

I'd be very thankful if you could take a look at my snappyHexMeshDict and my meshQualityDict.

The small geometry is called duese and the inlet sits at the face of this channel.

Code:

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

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


geometry
{
          rohr.stl
            {
                type triSurfaceMesh;
                name rohr;
                inGroups (walls);
            }

            inlet.stl
            {
                type triSurfaceMesh;
                name inlet;
            }
       
            cOut.stl
            {
                type triSurfaceMesh;
                name cOutlet;
                inGroups (outlets);
            }
       
        wOut.stl
            {
                type triSurfaceMesh;
                name wOutlet;
                    inGroups (outlets);
        }
       
        drossel.stl
        {
                type triSurfaceMesh;
                name drossel;
                inGroups (walls);
        }
       
        duese.stl
        {
                type triSurfaceMesh;
                name duese;
                inGroups (dueseGroup);
        }
       
        kammer.stl
            {
                type triSurfaceMesh;
                name kammer;
                inGroups (walls);
            }

        globalRefinement
        {
                type        searchableCylinder;
                point1        (0 0 0.1);
                point2        (0 0 0.2);
                radius        0.02;
        }

               
};




castellatedMeshControls
{


    maxLocalCells 10000000;

    maxGlobalCells 200000000;


    minRefinementCells 5;

 


    nCellsBetweenLevels 5;




    features
    (
        {
                    file "rohr.eMesh";
                    level 4;
        }
               
        {
                    file "drossel.eMesh";
                    level 1;
        }
               
        {
                file "duese.eMesh";
                level 3;
        }
               
        {
                file "inlet.eMesh";
                level 3;
        }
               
        {
                file "wOut.eMesh";
                level 1;
        }
               
        {
                file "cOut.eMesh";
                level 1;
        }
               
        {
                file "kammer.eMesh";
                level 1;
        }

    );





    refinementSurfaces
    {


        "(rohr)"
        {
            level (3 3);
            patchInfo
            {
                type wall;
                inGroups (walls);
            }
        }
       
        "(kammer)"
        {
                    level (1 3);
                    patchInfo
            {
                type wall;
                inGroups (walls);
            }
        }
               
        "(drossel)"
        {
            level (1 1);
                        gapLevelIncrement 2;
            patchInfo
            {
                type wall;
                inGroups (walls);
            }
        }
               
        "(duese)"
        {
            level (5 5);
            patchInfo
            {
                type wall;
                inGroups (dueseGroup);
            }
        }

        "(inlet)"
        {
            level (5 5);
            patchInfo
            {
               
                type mappedPatch;
                offset          (0 0.1 0);
                sampleRegion    region0;
                sampleMode      nearestCell;
                samplePatch    none;
            }
        }
               
        "(cOutlet)"
        {
            level (1 1);
            patchInfo
            {
                type patch;
                inGroups (outlets);
            }
        }
               
        "(wOutlet)"
        {
            level (1 1);
            patchInfo
            {
                type patch;
                    inGroups (outlets);
            }
        }
    }

    resolveFeatureAngle 30;



    refinementRegions
    {

                globalRefinement
                {
                        mode        inside;
                        levels        ((1e15 1));
                        gapMode        mixed;
                        gapLevel (4 0 4);
                }
               
                rohr
                {
                        mode distance;
                        levels ((0.001 2));
                }
               
                inlet
                {
                        mode distance;
                        levels ((0.002 2));
                }
                               
                kammer
                {
                        mode distance;
                        levels ((0.001 2));
                }
               
                drossel
                {
                        mode distance;
                        levels ((0.0004 4) (0.0008 3));
                }

    }


 
    locationInMesh (0.001 0.001 0.1);


 
    allowFreeStandingZoneFaces true;
       
       
       
}



snapControls
{
    nSmoothPatch 1;

 
    nSmoothInternal 1;

    tolerance 0.7;

    nSolveIter 100;

    nRelaxIter 8;



        nFeatureSnapIter 80;

        implicitFeatureSnap false;

        explicitFeatureSnap true;

        multiRegionFeatureSnap false;
}



addLayersControls
{

    relativeSizes true;
            layers
            {

                walls
                {
                        nSurfaceLayers        7;
                       
                }
               
                duese
                {
                        nSurfaceLayers        10;
                }

                inlet
                {
                        nSurfaceLayers        6;
                        thickness        2;
                        expansionRatio        1;
                }


        }

    expansionRatio 1.2;

            //finalLayerThickness 2;
        thickness 2;

    minThickness 0.0001;

 
    nGrow 0;


    featureAngle 230;

    slipFeatureAngle 90;

    nRelaxIter 1;

    nSmoothSurfaceNormals 2;

    nSmoothNormals 3;

    nSmoothThickness 10;

    maxFaceThicknessRatio 0.3;

    maxThicknessToMedialRatio 0.3;

    minMedialAxisAngle 90;

    nBufferCellsNoExtrude 0;

    nLayerIter 50;

    nRelaxedIter 1;

        additionalReporting true;
}




meshQualityControls
{
    #include "meshQualityDict"
    relaxed
    {
        maxNonOrtho 35;
    }

        maxNonOrtho 35;
    nSmoothScale 8;
    errorReduction 1.5;
}



writeFlags
(
    scalarLevels
    layerSets
    layerFields   
);



mergeTolerance 1e-6;


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

My meshQualityDict looks like this:

Code:

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

minFaceWeight 0.02;
maxBoundarySkewness    3;//20
maxInternalSkewness    2;//4
maxConcave              30;//40
minVol                  1e-13;
minTetQuality          1e-3;//1e-15
minArea                -1;
minTwist                0.02;
minDeterminant          0.01;//0.001
minFaceWeight          0.05;//0.05
minFaceFlatness        -1;
minVolRatio            0.01;//0.01
minTriangleTwist        -1;
nSmoothScale            8;//8
errorReduction          1.5;//.75


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


I've attached a picture of the mesh.

Best regards,
Vinz

Elia38 May 21, 2023 03:45

Hi, i comment based on my experience. do you use surfaceFeatureExtract? if so, you have to check its result before doing snappyHexMesh. sometimes, your .stl file does not have enough points to capture all curves correctly.
if you don't use surfaceFeatueExtract, i recommend you to rise "level" of duese.eMesh in features section.

Vinzmann May 22, 2023 01:29

Dear Elia,

thank you for your reply.

I will try your suggestion, thank you very much.

Best regards,
Vinz

Elia38 May 22, 2023 01:40

Quote:

Originally Posted by Vinzmann (Post 850574)
Dear Elia,

thank you for your reply.

I will try your suggestion, thank you very much.

Best regards,
Vinz

You're welcome Vinz

Vinzmann May 22, 2023 01:55

Hi Elia,

the edges do indeed look better, thank you very much for that.

Still some cells in the sharp corners are bad still.

Best regards,
Vinz

Elia38 May 22, 2023 05:21

Hi Vinz,
try 180 degrees in resolveFeatureAngle in castellatedMeshControls section.

Vinzmann May 22, 2023 07:06

1 Attachment(s)
Hello Elia,

this made the edges look worse sadly.

I am currently trying to tweak the resolveFeatureAngle to a point where the edges are sharp but the angle is not too high.

Attached you will find a picture.

Thank you again for your help.

Best regards,
Vinz

AtoHM May 22, 2023 07:36

Can you run without the layer generation step and show how that part looks? I assume this happens when introducing the layers, it can happen with high featureAngles.
In the ESI OpenFOAM distribution you can use
Code:

mergePatchFacesAngle 45;
to improve, please check yourself if this is available in the foundation version you seem to be working with (judging from your file header).


Furthermore, it might help to run with default mesh quality settings, not sure if you changed things there.

Elia38 May 22, 2023 09:58

Quote:

Originally Posted by Vinzmann (Post 850602)
Hello Elia,

this made the edges look worse sadly.

I am currently trying to tweak the resolveFeatureAngle to a point where the edges are sharp but the angle is not too high.

Attached you will find a picture.

Thank you again for your help.

Best regards,
Vinz

Hi Vinz,
Ok, reduce the resolveFeatureAngle to about 15 degrees. And use explicitFeatureSnap. So turn this feature on and turn off the implicitFeatureSnap. And increase the nFeatureSnapIter and nSolverIter.
Hope this help.
Elia


All times are GMT -4. The time now is 01:38.