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] blockMesh/snappyHexMesh for refining a coarse mesh (https://www.cfd-online.com/Forums/openfoam-meshing/231273-blockmesh-snappyhexmesh-refining-coarse-mesh.html)

TomWaits October 29, 2020 05:05

blockMesh/snappyHexMesh for refining a coarse mesh
 
I want to have a mesh that is very coarse (to save on computational costs) except for a cylinder in the middle which I want to be very finely meshed.

I use blockMesh to generate a cube with few grid points
Code:

blocks
(
    hex (0 1 2 3 4 5 6 7) (10 10 10) simpleGrading (1 1 1)
);

and then I use snappyHexMesh with

Code:

geometry
 {
    cylinder
    {
        type    searchableCylinder;
        point1  (0.0 0.0 0.0);
        point2  (0.0 0.0 10);
        radius  1.0;
    }
  }

and
Code:

    refinementRegions
    {

        cylinder
        {
            mode inside;
            levels ((10 10));
        }
    }

in my snappyHexMeshDict. The issue is that because the blockMesh is so coarse, snappyHexMesh can't find the cylinder, and the mesh isn't refined. I can add more grid points in each direction in blockMesh in which case it works but then the mesh far away from the cylinder is too fine.

What is the best workflow for this? How do I create a (very) fine cylinder surrounded by very coarse elements?

Many thanks,

Tom Waits

AtoHM October 29, 2020 10:14

The problem with refinementRegions is, that cells must lay inside to be refined. If your blockMesh is too coarse, nothing happens. What you can do is go and grab a CAD tool like FreeCAD, model your cylinder there and import it as slt file. Then you can specify refinementSurfaces to get to your level no matter what the background mesh looks like. I guess you gonna need a cellZone so snappy doesnt cut away the cells inside the cylinder.



Are you sure you want level 10? This might give you an insanely high number of cells.

Marpole November 1, 2020 23:35

refineMesh
 
First, I would suggest to make the background mesh relative coarse but not too coarse. With a proper background mesh size, the region refinement can work better.



And I might also want to try refineMesh before snappyHexMesh. You can refer to tutorial DTCHullMoving.

ufocfd February 10, 2023 13:57

This is a good reply - I have not used refineMesh before, but in the DTCHull case its used to refine the mesh after blockMesh but before snappyHexMesh. I have a similar issue recently with a coarse blockMesh (1m cells) and then trying to do surface refinement of a sphere STL geometry which is also 1m diameter, and it doesn't get refined (at all) because the background mesh is too coarse.

The issue can be resolved (a workaround) by increasing the size of the sphere to 2m diameter OR reducing the size of the background mesh to 0.5m cells. This seems like a flaw in snappyHexMesh, but the use of refineMesh before snappyHexMesh could also be an good option. Another workaround is to use the feature edges instead to refine the whole surface - this can be done by changing your surfaceFeaturesDict includedAngle from 150 to say 179. This has the effect of selecting all edges of your geometry, as long as you specify the feature edge refinement level needed within SHMDict too.

I wonder how many other people have fallen foul of this quirky behaviour in SHM?


All times are GMT -4. The time now is 14:06.