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] variables in snappyHexMeshDict (https://www.cfd-online.com/Forums/openfoam-meshing/158567-variables-snappyhexmeshdict.html)

smog August 28, 2015 11:00

variables in snappyHexMeshDict
 
Hello all,

I am creating the mesh and having some trouble getting the layers added to a wall patch (base cell size = 2 mm, level of refinement = 4). The funny thing is, the layers were added correctly on a refinement level of 3, but not when the refinement level = 4. I am wondering what the problem is. If you can let me know the significance of a few variables in the sHMD, that would be great. Here is the snippet of the concerned section of sHMD:




addLayersControls
{
relativeSizes true; //false means thickness values are absolute.True means values are relative to surface mesh dimension.

//list patch names inside "layers" to add cell layers to those patches
layers
{
wall_imported
{
nSurfaceLayers 3;
}
}

expansionRatio 1;
finalLayerThickness 0.33;
minThickness 0.05;
nGrow 0; //WHAT DOES THIS VARIABLE DO??

// Advanced settings

featureAngle 180; //WHAT DOES THIS VARIABLE DO??
nRelaxIter 20;
nSmoothSurfaceNormals 1;
nSmoothNormals 3;
nSmoothThickness 10;
maxFaceThicknessRatio 0.5; //WHAT DOES THIS VARIABLE DO??
maxThicknessToMedialRatio 0.3; //WHAT DOES THIS VARIABLE DO??
minMedianAxisAngle 80; //WHAT DOES THIS VARIABLE DO??
nBufferCellsNoExtrude 0;
nLayerIter 50;
}

student666 August 29, 2015 08:22

Some help:

Quote:

featureAngle 180; when not to extrude surface. 0 is flat, 90 is right angle.

maxThicknessToMedialRatio 0.3; Reduce layer growth where ratio thickness to medial distance is large
minMedianAxisAngle 80; Angle used to pick up medial axis points

As for names, you may see that these are parameters in order to make the algorithm choose if a cell can be extruded or not.

https://openfoamwiki.net/images/f/f0...SlidesOFW7.pdf
http://noc.ac.uk/f/content/science-t..._2_meshing.pdf

anyway, if you look to default dictionary you can find more variables.
By now I haven't clearly undestarnd what all they do; the only way to figure it out is to read the code, but for that, you have to master C++.

Bye

smog August 31, 2015 09:33

I have read the presentation. It is amazing indeed, although, when I actually try out the code, something bizarre keeps happening (like what I mentioned in my initial post).

student666 September 1, 2015 07:31

layer addition is one of the most painful task in snappy Hex Mesh; I think you already firgured it out by googling "layer addition".

Anyway; here's a link to a pdf about a conversation I had on the OpenFOAM group in Linkedin.

https://www.dropbox.com/s/u4ct0lau94...kedin.pdf?dl=0

Maybe it could help.

One more hint is to check the quality of the stl surfaces.

http://www.cfd-online.com/Forums/ope...pyhexmesh.html

By posting a picture of your geometry and mesh, you could get more help from the rest of the cfd-online community.

Regards

smog September 1, 2015 09:32

Thank you so much, but my office connection in blocking the dropbox link. Can you provide the link to the Linked-In conversation or PM me the PDF please? Thank you again.

student666 September 1, 2015 12:20

https://www.linkedin.com/grp/post/19...s-post-b-title

you're welcome. here it follows a template of mine I generally use to prepare the mesh. As posted before, I'm not mastering all variables.

Code:

FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// Which of the steps to run
castellatedMesh false;  // make basic mesh ?
snap            false;  // decide to snap back to surface ?
addLayers      true;  // decide to add viscous layers ?


geometry // Load in STL files here
{
    amiRot1.stl {type triSurfaceMesh; name amiRot1;}
    amiRot2.stl {type triSurfaceMesh; name amiRot2;}
    amiRot3.stl {type triSurfaceMesh; name amiRot3;}
    wallStat.stl {type triSurfaceMesh; name wallStat;}   
    blade.stl {type triSurfaceMesh; name blade;}
    bladeInf.stl {type triSurfaceMesh; name bladeInf;}
    bladeTop.stl {type triSurfaceMesh; name bladeTop;}
    boccInf.stl {type triSurfaceMesh; name boccInf;}
    boccSup.stl {type triSurfaceMesh; name boccSup;}
    fanHub.stl {type triSurfaceMesh; name fanHub;}

   

};

castellatedMeshControls
{
    maxLocalCells 2000000;  //max cells per CPU core
    maxGlobalCells 4000000; //max cells to use before mesh deletion step
    minRefinementCells 10;  //was 0 - zero means no bad cells are allowed during refinement stages
    maxLoadUnbalance 0.05;  //0.1 default
    nCellsBetweenLevels 1;  // expansion factor between each high & low refinement zone

    // Explicit feature edge refinement
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    features // taken from STL from each .eMesh file created by "SurfaceFeatureExtract" command
    (
        {file "amiRot1.eMesh"; level 1;}
        {file "amiRot2.eMesh"; level 1;}
        {file "amiRot3.eMesh"; level 1;}
        {file "wallStat.eMesh"; level 1;}
        {file "blade.eMesh"; level 2;}
        {file "bladeInf.eMesh"; level 2;}
        {file "bladeTop.eMesh"; level 2;}
        {file "boccInf.eMesh"; level 2;}
        {file "boccSup.eMesh"; level 2;}
        {file "fanHub.eMesh"; level 1;}
   
                       
    );

    // Surface based refinement
    // ~~~~~~~~~~~~~~~~~~~~~~~~

    refinementSurfaces // Surface-wise min and max refinement level
    {
    amiRot1 {level (2 2);}
        amiRot2 {level (2 2);}
    amiRot3 {level (2 2);}
    wallStat {level (1 2);} //(2 2 )
    blade {level (2 2 );}
    bladeInf {level (3 3);}
    bladeTop {level (2 2);}
    boccInf {level (1 1 );}
    boccSup {level (3 3);}
    fanHub {level (2 2);}
   
   
    } 


    resolveFeatureAngle 80;  //was80 Resolve sharp angles // Default 30
    refinementRegions      // In descending levels of fine-ness
    {
    //refine1 {mode inside; levels ((3 4));}

    }

    locationInMesh (0 0 0.167);  //to decide which side of mesh to keep **
    allowFreeStandingZoneFaces false; //true;
}


// Settings for the snapping.
snapControls
{
    nSmoothPatch 0;// era 3;
    tolerance 2.0; //era 3.0 default is 2
    nSolveIter 250; //era30
    nRelaxIter 5; // efault 5
    nFeatureSnapIter 30; // default is 10
   
// New settings from openfoam 2.2 onwards for SHMesh

implicitFeatureSnap false; // default is false - detects without doing surfaceFeatureExtract
explicitFeatureSnap true; // default is true
multiRegionFeatureSnap false; // deafault is false - detects features between multiple surfaces

}



// Settings for the layer addition.
addLayersControls //add the PATCH names from inside the STL file so STLpatchName_insideSTLName
{
    relativeSizes false; // was true con false hanno la stessa grandezza
    layers
    {

    blade  {nSurfaceLayers 1;expansionRatio 1.12;firstLayerThickness 0.002;minThickness 0.00005;}
    bladeTop  {nSurfaceLayers 1;expansionRatio 1.12;firstLayerThickness 0.001;minThickness 0.00005;}
    bladeInf  {nSurfaceLayers 1;expansionRatio 1.12;firstLayerThickness 0.001;minThickness 0.00005;}
    fanHub {nSurfaceLayers 1;expansionRatio 1.12;firstLayerThickness 0.0022;minThickness 0.0001;}
    boccInf  {nSurfaceLayers 1;expansionRatio 1.12;firstLayerThickness 0.002;minThickness 0.00005;}
   
       
    }

    expansionRatio 1.12;
    //thickness 0.002;
    firstLayerThickness 0.002; //was 0.00018
    minThickness 0.00001;
    nGrow 0; // was 1


    // Advanced settings

    // Static analysis of starting mesh

    featureAngle 310; //- When not to extrude surface. 0 is flat, 90 is right angle.
    nRelaxIter 5; //era 13 //- Max# of snapping relaxation iter. Should stop before upon reaching a correct mesh.
    maxFaceThicknessRatio 0.8; // Stop layer growth on highly warped cells

    // Patch displacement

    nSmoothSurfaceNormals 150;  //100 Number of smoothing iterations of surface normals
    nSmoothThickness 50;  //100 Smooth layer thickness over surface patches

    // Medial axis analysis   

    minMedianAxisAngle 135;  //135 Angle used to pick up medial axis points
    maxThicknessToMedialRatio 0.9; // Reduce layer growth where ratio thickness to medial distance is large
    nSmoothNormals 50; // Number of smoothing iterations of interior mesh movement direction
   
        // Optional:
    //nMedialAxisIter 10;  //limit the number of steps walking away from the surface. Default is unlimited.
    //nSmoothDisplacement 90; //smooth displacement after medial axis determination. default is 0.
        // (wip)Optional:
    //detectExtrusionIsland true;  // do not extrude a point if none of the surrounding points is not extruded. Default is false.

    // Mesh shrinking
    slipFeatureAngle 30; //at non-patched sides allow mesh to slip if extrusion direction makes angle larger than slipFeatureAngle. Default
            //is 0.5*featureAngle.
    nBufferCellsNoExtrude 0;  // Create buffer region for new layer terminations
    nLayerIter 50; //Overall max number of layer addition iterations. The mesher will exit if it reaches this number of iterations;
          //possiblywith an illegal mesh.
    nRelaxedIter 0; // Max number of iterations after which relaxed meshQuality controls get used. Up to nRelaxedIter it uses the settings
            // in meshQualityControls, after nRelaxedIter it uses the values in meshQualityControls::relaxed.
            //IMPOSTANDOLO A 0 SHM UTILIZZA IMMEDIATAMENTE I VALORI RELAXED
 
        // Additional reporting: if there are just a few faces where there
        // are mesh errors (after adding the layers) print their face centres.
        // This helps in tracking down problematic mesh areas.
        //additionalReporting true;
}



// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
meshQualityControls
{
  /* disabling mesh quality
 
  MaxNonOrtho 180;
  maxBoundarySkewness -1;
  maxInternalSkewness -1;
  maxConcave 180;
  minVol -1e33;
  minTetQuality -1e30;
  minTwist -1e30;
  minDeterminant -1;
  minFaceWeight -1;
  minVolRatio -1;
  minArea -1;
  minTriangleTwist -1;
  */
   
    maxNonOrtho 55; //default 65
    maxBoundarySkewness 20; 
    maxInternalSkewness 4; 
    maxConcave 60; //default 80;
    minVol 1e-13;
    minTetQuality -1e30;
    minFlatness 0.5;
    minTetQuality 1e-9;
    minArea -1;
    minTwist 0.05;
    minDeterminant 0.001;
    minVolRatio 0.01;
    minFaceWeight 0.05;
    minTriangleTwist -1;
    nSmoothScale 4;
    errorReduction 0.75;

    // Advanced
    relaxed // mesh Quality Controls for layer addiction phase
    {
    maxNonOrtho 69;
    //maxBoundarySkewness 25;
    //maxInternalSkewness 5;
    maxConcave 100;
    minTwist 0.02;
    minFaceWeight 0.02;
    minDeterminant 0.0001;
    }
}

// Advanced

debug 0;


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


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


smog September 1, 2015 16:45

student666, thank you for posting the sHMD. It is extremely helpful looking at the settings of another user. I am now playing around with my sHMD values as well.

WernerW September 24, 2015 17:34

Layers in Complex geometry
 
Hi !

I'm having problems as well with the Add Layers function in snappyHexMesh. I'm trying to put just 1 layer around a complex geometry in 3d and as the addlayers application iterates the layers that I had at the beginning get all removed, aparently because they didn't comply with the meshquality controls.. I tried changing several parameters imitating M.C.'s setting but I got no improvement. Is this a problem of my geometry or could I change a parameter to improve the layer addition? I'm ataching a pic of my layers around a slice of my geometry and both sHMD and log.sHM.

thanks in advance,
Werner


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