CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Native Meshers: snappyHexMesh and Others (https://www.cfd-online.com/Forums/openfoam-meshing-snappyhexmesh/)
-   -   simple sphere with snappyhexmesh (https://www.cfd-online.com/Forums/openfoam-meshing-snappyhexmesh/88973-simple-sphere-snappyhexmesh.html)

Duncan_vdH May 31, 2011 11:18

simple sphere with snappyhexmesh
 
3 Attachment(s)
I tried to use SHM, but I hope I am doing something wrong, because the result is a bit disappointing. The snapping does not make a good approximation of the actual surface. I played around with the four snapping parameters but their influence is not so great.
Am I missing something, or is this the best SHM can do?

The STL file I am using is a very high resolution description of a sphere using triangles.
The pictures show the inner surface of the mesh in paraFoam: the castellated case, the snapped case (next time level) and the snapped case together with the geometry.

Any ideas would be appreciated!

Kind regards.
Duncan

Erik June 22, 2011 03:31

sphere with snappyHexMesh
 
3 Attachment(s)
Hi Duncan,

It seems that the snapping is not working in your case. I am also trying to mesh a sphere. I get a smooth surface with the snapp function. However I can't manage to add layers.

You can have a look at my snappyHexMeshDict and blockMeshDict for this.

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.0.0                                |
|  \\  /    A nd          | Web:      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      true;


geometry
{

    sphere
    {
        type searchableSphere;
        centre  (0 0 0);
        radius  0.1;
    }
};

castellatedMeshControls
{
    maxLocalCells 1000000;
    maxGlobalCells 2000000;
    minRefinementCells 0;
    maxLoadUnbalance 0.10;
    nCellsBetweenLevels 1;
    features
    (
    );
    refinementSurfaces
    { 
        sphere
        {
            level (2 2);
        /*    regions
            {
                secondSolid
                {
                    level (5 5);
                }
            }
        */
            patchInfo
            {
                type wall;
            }
        }
       
    }

    resolveFeatureAngle 30;
    refinementRegions
    {
    }
    locationInMesh (0.11 0 0);
    allowFreeStandingZoneFaces true;
}


snapControls
{
    nSmoothPatch 3;
    tolerance 1.0;
    nSolveIter 30;
    nRelaxIter 3;
}

addLayersControls
{
    relativeSizes true;
    layers
    {
        sphere_region0
        {
            nSurfaceLayers 2;

        }

    }

    expansionRatio 1.0;
//    finalLayerThickness 1e-9;
finalLayerThickness 0.01;
    finalLayerRatio 0.01;
    minThickness 0;
    nGrow 1;
    featureAngle 60;
    nRelaxIter 5;
    nSmoothSurfaceNormals 1;
    nSmoothNormals 3;
    nSmoothThickness 10;
    maxFaceThicknessRatio 0.5;
    maxThicknessToMedialRatio 0.3;
    minMedianAxisAngle 90;
    nBufferCellsNoExtrude 0;
    nLayerIter 50;
    nRelaxedIter 20;
}

meshQualityControls
{
    maxNonOrtho 65;
    maxBoundarySkewness 20;
    maxInternalSkewness 4;
    maxConcave 80;
    minVol 1e-200;
    minTetQuality 1e-9;
    minArea -1;
    minTwist 0.05;
    minDeterminant 0.001;
    minFaceWeight 0.05;
    minVolRatio 0.00001;
    minTriangleTwist -1;

    nSmoothScale 4;
    errorReduction 0.75;

    relaxed
    {
        maxNonOrtho 75;
    }
}

debug 0;
mergeTolerance 1e-6;

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

If you or anyone else know how to get the layers of mesh around the sphere please let me know.

ps. here the sphere is in unit order of length scale but once I get the layers right, I will want to mesh a micro sized sphere.

Best regards,
Erik Arlemark

Duncan_vdH June 22, 2011 07:45

Hi Erik,

Thanks for responding.

I found an error in my Blockmeshdict and now have a smooth sphere and layers. And a different opinion on Snappyhexmesh :-).

I basically went back to the Iglo tutorial and started from that. Remove all the internal stuff and use the Iglo geometry as the basis.
I would recommend starting with all the settings for layer control from that tutorial. I think many of your grid quality parameters are quite different form that testcase.

Now I have layers too!

If you redirect output to file, is layer generation mentioned in the output?

I can send you the files I am using, just email me.

Erik June 22, 2011 11:12

sphere with snappyHexMesh
 
1 Attachment(s)
Hi Duncan,

Thanks for your reply. I now managed to get layers to the sphere as well. I will also have a look at the Igloo case as you suggested. Maybe I can optimize the mesh for my purpose.

picure of mesh and snappyHexMeshDict is attached in case anyone else is interested.

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.0.0                                |
|  \\  /    A nd          | Web:      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      true;


geometry
{

    sphere
    {
        type searchableSphere;
        centre  (0 0 0);
        radius  0.1;
    }
};

castellatedMeshControls
{
    maxLocalCells 1000000;
    maxGlobalCells 2000000;
    minRefinementCells 0;
    maxLoadUnbalance 0.10;
    nCellsBetweenLevels 1;
    features
    (
    );
    refinementSurfaces
    { 
        sphere
        {
            level (2 1);
        /*    regions
            {
                secondSolid
                {
                    level (5 5);
                }
            }
        */
            patchInfo
            {
                type wall;
            }
        }
       
    }

    resolveFeatureAngle 30;
    refinementRegions
    {
    /*        sphere
            {
                    mode outside;
                    levels ((1.0 1));
            }
    */
    }
    locationInMesh (0.11 0 0);
    allowFreeStandingZoneFaces true;
}


snapControls
{
    nSmoothPatch 3;
    tolerance 1.0;
    nSolveIter 30;
    nRelaxIter 5;
}

addLayersControls
{
    relativeSizes false;
    layers
    {
        sphere_region0
        {
            nSurfaceLayers 2;

        }

    }

    expansionRatio 1.0;
//    finalLayerThickness 1e-9;
finalLayerThickness 0.1;
    finalLayerRatio 0.01;
    minThickness 0.002;
    nGrow 0;
    featureAngle 30;
    nRelaxIter 10;
    nSmoothSurfaceNormals 1;
    nSmoothNormals 3;
    nSmoothThickness 10;
    maxFaceThicknessRatio 0.5;
    maxThicknessToMedialRatio 0.3;
    minMedianAxisAngle 40;
    nBufferCellsNoExtrude 0;
    nLayerIter 100;
    nRelaxedIter 20;
}

meshQualityControls
{
    maxNonOrtho 65;
    maxBoundarySkewness 20;
    maxInternalSkewness 4;
    maxConcave 80;
    minVol 1e-200;
    minTetQuality 1e-9;
    minArea -1;
    minTwist 0.05;
    minDeterminant 0.001;
    minFaceWeight 0.05;
    minVolRatio 0.01;
    minTriangleTwist -1;

    nSmoothScale 4;
    errorReduction 0.75;

    relaxed
    {
        maxNonOrtho 75;
    }
}

debug 0;
mergeTolerance 1e-6;

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

Many thanks,
Erik

Duncan_vdH June 22, 2011 11:18

Hi Erik,

I also have these small, very slender elements in my mesh like I see in your case, away from the sphere.
Do you or anybody else know how to suppress these or make them disappear? I played around with the minimum volume setting, but this had little effect.

Cheers,
Duncan

Erik June 24, 2011 03:36

Hi Duncan and all,

Yes indeed, I also would like to get rid of the very small cells and I can not seem to get the minVolRatio entry to control this. Thanks for the advise of looking at the igloo case. I will give this a try.

Cheers,
Erik

Erik June 29, 2011 07:32

sphere with snappyHexMesh
 
5 Attachment(s)
Hi Duncan and all,

It seems a nice mesh of the sphere (see figure here) can be made for specific configurations of number of cells in x-,y- and z-direction, being set in the blockMeshDict file. If an ill-favored number or background mesh is chosen the small cells appear (as I have posted above). Attached is also a spherical cavity, created by setting the locationInMesh entry to a point inside the created sphere.

ps. For the figure attached, I prefer to have only one relatively thick layer next to the sphere but this is not necessary for producing a clean mesh of the sphere with layers.

Cheers,
Erik

lindstroem July 6, 2011 07:11

Hi Erik,

would it be possible that you also post your stl file? it looks quite promising what you did and i would like to give it a try too.

Thanks in advance!

norman1981 July 7, 2011 02:42

Quote:

Originally Posted by lindstroem (Post 314908)
Hi Erik,

would it be possible that you also post your stl file? it looks quite promising what you did and i would like to give it a try too.

Thanks in advance!

You don't need it because Erik used a searchableSphere object to generate the sphere, look at the snappyHexMeshDict and you'll find these lines:

geometry
{

sphere
{
type searchableSphere;
centre (0 0 0);
radius 0.1e-7;
}
};

Regards

Norman

lindstroem July 7, 2011 05:13

oh - thanks for the information.. didn't know, that shm has this function too!

lindstroem March 20, 2012 12:47

2 Attachment(s)
Hi again,

I was trying to add a boundary layer to my sphere. To compute the flow around a sphere i meshed a quarter of a sphere and wanted to refine the boundary layer. I am not so sure, how to deal with the "addLayersControls" which should do that if I understood everything correct.

I added my blockmesh and snappyHexMeshDict.

--
Edit: the
layers
{
sphere
{
nSurfaceLayers 5;
}
}
in the provided SHMDict needs to be sphere_region0 (or?) but it does not change anything...
---

Thanks in advance!

Duncan_vdH March 20, 2012 17:13

Hi,
I completely switched over to using SALOME for meshing and have no regrets!
You should check it out, it works like a charm.
Regards,
Duncan

Ivooo March 30, 2012 10:14

Sphere using blockMeshing
 
3 Attachment(s)
I think this would be the best place to share my .m4 file of a sphere or spheroid created using several blocks and arc-edges, as opposed to using a utility such as snappyHexMesh. The advantage is that it creates a body-conformal mesh around the spher(e/oid).

Why?
I have seen that a droplet on a cylindrical surface created using SHM has an unphysical contact line (see image attached), and if I create a cylinder using blockmeshing only (see tutorial of the chargedWire), the contactline is nice and smooth. In addition, the SHM method did not allow me to use parallel+interDyMFoam, and the blockmesh version does. Hence, I felt that creating a sphere using blockMesh only will also improve results and since it took me a day or so I thought I'd share.

amitmangtani May 17, 2012 05:04

Unable to see Sphere in ParaFoam
 
Hi Erik,
I am new to OpenFoam and i've been told to do CFD of the cylinder in which a sphere is placed inside the cylinder as an obstacle... I have been able to make the structured grid for cylinder but still not able to figure out the unstructured grid around the sphere...
I have looked your both Dict files and after using them i am not able to see the unstructured grid around sphere in ParaFoam..

Can you please me suggest me the mistake?? No error has been showing in terminal but when i open the ParaFoam i can only see the block domain which is created by blockmesh and nothing else.. So i'm little confused now that what snappyHexMesh does??

Regards,
Amit Mangtani

Quote:

Originally Posted by Erik (Post 314042)
Hi Duncan and all,

It seems a nice mesh of the sphere (see figure here) can be made for specific configurations of number of cells in x-,y- and z-direction, being set in the blockMeshDict file. If an ill-favored number or background mesh is chosen the small cells appear (as I have posted above). Attached is also a spherical cavity, created by setting the locationInMesh entry to a point inside the created sphere.

ps. For the figure attached, I prefer to have only one relatively thick layer next to the sphere but this is not necessary for producing a clean mesh of the sphere with layers.

Cheers,
Erik


Nico A. August 9, 2012 09:54

1 Attachment(s)
Hello Ivo,

I am also doing simulations of a flow around a sphere. I also generated some structured grids, but they did not have a sufficient quality at the sphere surface. But your grids looks really, really good, thanks for the dict at this point. I also tried to understand what you have done and i wanted to add some new blocks for my case. But unfortunately I just got errors during blockMeshing.

As you can see in the attached file, I would like to create a wake area behind the sphere in z-direction (about 7*Lenght of the current domain). So can you help me with it, or give me some hints, how do realize this? Thanks in advance.

Best regards, Nico

lindstroem August 9, 2012 09:59

you need to make sure, that your cells fit the cells of the neighboring block. Maybe that can help you:
http://www.cfd-online.com/Forums/ope...hes-p-t-u.html
or you use the same discretization in x and y direction as in the "master"block
greetings

Ivooo August 9, 2012 10:06

Dear Nico,

As lindstroem mentions, you'd have to connect your other mesh blocks to the same grid. You might want to use pyFoamDisplayBlockMesh to distinguish the different blocks. Once that's fixed and you still get errors, please post the errors so people can have a clue what's going on.

Cheers
I

Nico A. August 9, 2012 11:43

Thank you both for the very quick answers. I now decided to use the extrudeMesh utility, which works fine so far, I hope the results will show that.


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