CFDComputing - Power of Numerical Simulation

 

 OpenFOAM Tutorial

 Fluent Tutorial

 CFX Tutorial

 STARCD Tutorial

 STARCCM+ Tutorial

 Forums

 

Forces in OpenFOAM How to calculate lift and drag coefficient in OpenFOAM force_foam.com

OpenFOAM to Fluent How to convert OpenFOAM mesh to Fluent Mesh FoamFluent.com

Mass Flow Rate FOAM How to monitor mass flow rate in OpenFOAM massflow_Foam.com

Meshing with SnappyHexMesh How to get the best mesh from SnappyHexMesh snappyHexmesh.com

Underhood CFD OpenFOAM Underhood CFD Simulation for Automotive Truck openfoamTutorial.com

OpenFOAM Meshing Study How to create Porous and Rotating Zone with OpenFOAM foamMeshing.com

 

How to get the best mesh from SnappyHexMesh

The snappyHexMesh utility generates 3-dimensional meshes containing hexahedra (hex) and split-hexahedra (split-hex) automatically from triangulated surface geometries in Stereolithography (STL) format. The mesh approximately conforms to the surface by iteratively refining a starting mesh and morphing the resulting split-hex mesh to the surface. An optional phase will shrink back the resulting mesh and insert cell layers. The specification of mesh refinement level is very flexible and the surface handling is robust with a pre-specified final mesh quality. It runs in parallel with a load balancing step every iteration. Some basic terminology associated with snappy Hex Mesh . I will discuss them as the flow of setting up snappy Hex Mesh parameters for the meshing.

The snappyHexMesh utility supplied with OpenFOAM package generates high quality hex (hexahedra )  dominant meshes straight from triangulated surface geometries in Stereolithography (STL) format.

 

The mesh approximately conforms to the surface by iteratively refining a starting mesh and morphing the resulting split-hex mesh to the surface. An optional phase will shrink back the resulting mesh and insert cell layers. The major steps involved in the meshing process are discussed below. A generic external flow analysis over truck is discussed in this tutorial; a more specific case will require some changes.

 

 

1.                        snappyHexMesh, require  a reference background mesh which can be done by using blockMesh utility.  Input file for blockmesh utilty is blockMeshDict and should be kept  in $CASE_DIR/constant/polyMesh.   This file has domain information by supplying the 8 vertex location for a rectangular or square domain.  Within the blocks location one need to specify the parameters for meshing , the final mesh refinement is depends  to the mesh size specified here in blockMeshDict. Further within patch one specify the domain boundaries faces.

2.                        Once the  blockMeshDict is updated blockmesh utility should be executed. As this would create the background mesh for snappyHexMesh . The background mesh need not be very fine, as snappyHexMesh will refine the final mesh based on the refinement specified on each of the region or boundaries

 

hex (0 1 2 3 4 5 6 7) (48 12 12) simpleGrading (1 1 1)

 

In this place you are specifying 48 cells in x direction, 12 cell in y direction etc.. you can reduce the number of cells here to quickly find out the coarser or finer mesh, without changing anythings else in the setup. the mesh from blockMesh  must consist purely of hexes and the cell aspect ratio should be approximately 1, at least near surfaces at which the subsequent snapping procedure is applied, otherwise the convergence of the snapping procedure is slow and, possibly can fail. there must be at least one intersection of a cell edge with the STL surface, i.e. a mesh of one cell will not work.

 

Execute

blockMesh

Mesh created by blockMesh will have a reactangular block covering the whole domain

 

3.    All the  related STL-file, Preferably ASCII STL must be kept at $CASE_DIR/constant/triSurface. In this tutorial an external aerodynamics model is created for VOLVO truck model. filename is for the geometry is volvo.stl. Make sure you have boundary isolated at the CAD level for using them to create the refinements in the volume mesh later. Boundaries can also be used for specifying boundary conditions by creating patch around them.  Following picture shows the truck model used for generating mesh around it.


 

6.    Next step is to modify/create the snappyHexMesh input file. One can create or copy snappyHexMeshDict input file in $CASE_DIR/system dir    The snappyHexMeshDict dictionary includes parameters at the top level that control the various stages of the meshing process.   Following option should be kept true for generating the volume mesh with extrusion layers.       Later one  need to specify the stl files name  within geometry.  This would be followed with boundary or region name within the model with there custom refinement values.

 

castellatedMesh true;

snap            true;           Do the surface snapping stage

addLayers       true;       Add surface layers

geometry

{

    volvo.stl

    {

        type            triSurfaceMeshWithGaps;

        gap             0.005;

        regions

        {

            chasis

            {

                name            chasis;

 

7.     specify all the stl filename here but one  can also specify the searchable box for refinements etc.  Now we have to configure the settings for the mesh, generated by snappyHexMesh. This is done in the castellatedMeshControls sub-dictionary. Valid settings and options can be seen in the user-guide (table 5.8) or in the snappyHexMesh tutorials. An example for that sub-dictionary is the following

 castellatedMeshControls

{

    maxLocalCells   100000000;

    maxGlobalCells  200000000;

    minRefinementCells 20;

    nCellsBetweenLevels 2;

    features        ( );

 maxGlobalCells is 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.

 

    refinementSurfaces

    {

        volvo.stl

        {

            level           { 4  5 };

            regions

            {

                chasis

                {

                    level            { 4  5 };

The refinementSurfaces dictionary in castellatedMeshControls requires dictionary entries for each STL surface and a default level specification of the minimum and maximum refinement in the form (<min> <max>). The minimum level is applied generally across the surface; the maximum level is applied to cells that can see intersections that form an angle in excess of that specified by resolveFeatureAngle.

   resolveFeatureAngle 30;

 

8.    The refinementRegions sub-dictionary in castellatedMeshControls contains entries for refinement of the volume regions specified in the geometry sub-dictionary. A refinement mode is applied to each region which can be inside refines inside the volume region, outside refines outside the volume region  and distance refines according to distance to the surface; and can accommodate different levels at multiple distances with the levels keyword.

 

    refinementRegions

    {

        volvo.stl

        {

            mode            distance;

            levels          2 ( ( 0.05 5 ) ( 0.1 8 ) );

        }

mode distance followed by level : is the parameter to sepecify the refinement based ON Proximity..

level ( 0.1 8) means that proximity refinement of level 8 within 100 mm of the body part or any region    The level tag defines minimum and maximum refinement level. The refinementRegions tag sets the levels of refinement in various distances to the body.
It doesn’t matter, how much refinementRegions are defined, but the scheme is always the same. levels((maxDistance refinementLevel)...). you can have multiple refinement levels based on the distance from the region.

 

9.     Once the feature and surface splitting is complete a process of cell removal begins. Cell removal requires one or more regions enclosed entirely by a bounding surface within the domain. The region in which cells are retained are simply identified by a location vector within that region, specified by the locationInMesh keyword in castellatedMeshControls. Cells are retained if, approximately speaking, 50% or more of their volume lies within the region. The remaining cells are removed.  Basically all the mesh point which are connected to locationInMesh point will be retained and everything else will be discarded off from the final mesh.

 

10.                         After the specification of the general meshing and refinement parameters, it is essential to set up controls for the snapping process itself.

snapControls

{

    nSmoothPatch 3; Number of patch smoothing iterations before finding correspondence to surface

    tolerance 4.0; Ratio of distance for points to be attracted by surface feature point or edge, to local maximum edge length

    nSolveIter 30; Number of mesh displacement relaxation iterations

    nRelaxIter 5; Maximum number of snapping relaxation iterations

}

The next stage of the meshing process involves moving cell vertex points onto surface geometry to remove the jagged castellated surface from the mesh. The process is:

1.    displace the vertices in the castellated boundary onto the STL surface;

2.    solve for relaxation of the internal mesh with the latest displaced boundary vertices;

3.    find the vertices that cause mesh quality parameters to be violated;

4.    reduce the displacement of those vertices from their initial value (at 1) and repeat from 2 until mesh quality is satisfied.

 

11.                      The layer addition is controlled by the addLayersControls dictionary. This input decide for how many extrusion layers will be assigned to a surface by snappyHexMesh.

addLayersControls

{

    layers

    {

        chasis

        {

            nSurfaceLayers  0;

            expansionRatio  1.1;

            finalLayerRatio 0.6;

            minThickness    0.5;

for no extrusion layers simply specify nSurfaceLayers to 0. Other option decide distribution of thickness for extrusion layers if any.

12.                         Finally, mesh quality is determined by meshQualityControls directory. All options related to this can be found in table 5.11 in the user guide.

meshQualityControls

{

    maxNonOrtho     65;

    maxBoundarySkewness 20;

    maxInternalSkewness 4;

    maxConcave      80;

    minFlatness     0.5;

    minVol          1e-13;

    minArea         -1;

    minTwist        0.05;

    minDeterminant  0.001;

    minFaceWeight   0.025;

    minVolRatio     0.01;

        minTriangleTwist 0.05;

    nSmoothScale    4;

    errorReduction  0.75;

}

debug           0;

mergeTolerance  1e-06;

 

13.                         Make sure you have files transportProperties turbulenceProperties before running the snappyHexMesh under constant directory.  Meshing can be run in parallel with a load balancing step every iteration is satisfactory scalability. It runs in parallel with a load balancing step every iteration.

       execute   snappyHexMesh

14.                         Once meshing is finished , it would creat three new timestep folders. The naming differs, depending on your deltaT in your system/controlDict, but always reflects the first three timesteps. Opening the case using paraFoam gives a good nice understanding, how snappyHexMeshworks. The first timestep   shows the background mesh, without any refinements. Nest time step  shows the refined mesh as well as no faces, that are “snapped” to the geometry  but. The final result is provided by time step 2.

Stage 1: Refined mesh but no snapped faces 

 

      Stage 2 : Refined mesh with snapped faces                   

     

    Stage 3:   Final Mesh with extrusion layers

 

 
  CFDComputing.com © 2009-2012                      Privacy Policy                  contact us                           sitemap