CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[snappyHexMesh] SHM does not follow STL geometry well

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By chegdan

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 18, 2016, 13:04
Default SHM does not follow STL geometry well
  #1
Member
 
Axel
Join Date: May 2016
Location: Augsburg, Germany
Posts: 46
Rep Power: 10
Illmatic is on a distinguished road
I want to mesh a geometry from STL files with SHM. The resulting mesh looks imo fine at first sight. However it does not follow the STL file properly, which causes problem in the simulation, because I need to use cyclicAMI boundary conditions. Unfortunatly I can not post the geometry or pictures of the whole mesh, because the product is still in development. I am trying to provide as much as possible.

The extracted feature edges are represented in red in the images.

A major problem I see with the created mesh, is that the boundaries Upper_Ducts and Lower_Ducts have a significantly different number of faces, although they should have the same geometry. This is indicated in the 2nd and 3rd image below.

If you have any further questions about the set-up please ask. Thanks for your help in advance!

snappyHexMeshDict:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.2.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     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 // Load in STL files here
{
	Flow_Inlet.stl {type triSurfaceMesh; name Flow_Inlet;}
	Flow_Outlet.stl {type triSurfaceMesh; name Flow_Outlet;}
	Left_Ducts.stl {type triSurfaceMesh; name Left_Ducts;}
	Right_Ducts.stl {type triSurfaceMesh; name Right_Ducts;}
	Lower_Ducts.stl {type triSurfaceMesh; name Lower_Ducts;}	
	Upper_Ducts.stl {type triSurfaceMesh; name Upper_Ducts;}
	Walls.stl {type triSurfaceMesh; name Walls;}
	All_Faces.stl {type triSurfaceMesh; name All_Faces;}
};

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

    // Explicit feature edge refinement
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // taken from STL from each .eMesh file created by "SurfaceFeatureExtract" command
    features 
    (
	{file "Flow_Inlet.eMesh"; level 0;}
	{file "Flow_Outlet.eMesh"; level 0;}
    );

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

    refinementSurfaces // Surface-wise min and max refinement level. Block is needed to define faces.
    {
	Flow_Inlet {level (0 0);}
	Flow_Outlet {level (0 0);}
	Left_Ducts {level (0 0);}
	Right_Ducts {level (0 0);}
	Lower_Ducts {level (0 0);}
	Upper_Ducts {level (0 0);}
	Walls {level (0 0);}
    }  

    refinementRegions        // In descending levels of fine-ness. For finer regions.
    {
    } 

    resolveFeatureAngle 30;  // Resolve sharp angles // Default 30
    locationInMesh (2e-02 0 2e-03);  //to decide which side of mesh to keep **
    allowFreeStandingZoneFaces true;
}


// Settings for the snapping.
snapControls
{
    nSmoothPatch 3;
    tolerance 4.0;
    nSolveIter 30;
    nRelaxIter 5;
    nFeatureSnapIter 3; // default is 10 Highly experimental!
    
// 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 true; // was true
    layers
    {
	Walls
         	{nSurfaceLayers 3;}
    }

    expansionRatio 1.2;
    finalLayerThickness 0.3; 
    minThickness 0.1; 
    nGrow 0;

    // Advanced settings

    featureAngle 110;
    nRelaxIter 3;  //- Max snapping relaxation iter. Should stop before upon reaching a correct mesh.
    nSmoothSurfaceNormals 1;  // Number of smoothing iterations of surface normals
    nSmoothNormals 3; // Number of smoothing iterations of interior mesh movement direction
    nSmoothThickness 10;  // Smooth layer thickness over surface patches
    maxFaceThicknessRatio 0.7;
    maxThicknessToMedialRatio 0.3;
    minMedianAxisAngle 100;
    nBufferCellsNoExtrude 0;   // Create buffer region for new layer terminations
    nLayerIter 50; // Overall max number of layer addition iterations
}



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

    // Advanced

    nSmoothScale 4;
    errorReduction 0.75;
}

// 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;


// ************************************************************************* //
boundary
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  3.0.1                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       polyBoundaryMesh;
    location    "constant/polyMesh";
    object      boundary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

7
(
    Flow_Inlet
    {
        type            patch;
        nFaces          5354;
        startFace       12356791;
    }
    Flow_Outlet
    {
        type            patch;
        nFaces          5222;
        startFace       12362145;
    }
    Left_Ducts
    {
        type            patch;
        nFaces          14586;
        startFace       12367367;
    }
    Right_Ducts
    {
        type            patch;
        nFaces          15369;
        startFace       12381953;
    }
    Lower_Ducts
    {
        type            patch;
        nFaces          7665;
        startFace       12397322;
    }
    Upper_Ducts
    {
        type            patch;
        nFaces          5200;
        startFace       12404987;
    }
    Walls
    {
        type            wall;
        nFaces          426170;
        startFace       12410187;
    }
)

// ************************************************************************* //
Attached Images
File Type: jpg cfd-online_2.jpg (132.5 KB, 129 views)
File Type: jpg cfd-online_3.jpg (128.3 KB, 117 views)
File Type: jpg cfd-online_4.jpg (126.2 KB, 161 views)
Illmatic is offline   Reply With Quote

Old   July 18, 2016, 13:09
Default
  #2
Senior Member
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0
chegdan will become famous soon enoughchegdan will become famous soon enough
Just taking a quick look at your settings, I see that all of your refinement surfaces are set to a refinement level of 0 0. For example:

Code:
    refinementSurfaces // Surface-wise min and max refinement level. Block is needed to define faces.
    {
	Flow_Inlet {level (0 0);}
	Flow_Outlet {level (0 0);}
	Left_Ducts {level (0 0);}
	Right_Ducts {level (0 0);}
	Lower_Ducts {level (0 0);}
	Upper_Ducts {level (0 0);}
	Walls {level (0 0);}
    }
In order to actually capture the changes in curvature of the STL, you will need to increase the min and max levels above 0 similar to:

Code:
	Right_Ducts {level (1 2);}
This will create a refinement level of 1 on flat portions and a level 2 on curved portions. Also, I would increase the refinement on your emesh files as well to capture the feature line better. Good luck!

Last edited by chegdan; July 18, 2016 at 21:36. Reason: words
chegdan is offline   Reply With Quote

Old   July 19, 2016, 07:44
Default
  #3
Member
 
Axel
Join Date: May 2016
Location: Augsburg, Germany
Posts: 46
Rep Power: 10
Illmatic is on a distinguished road
Hey Dan, thanks for your reply!

As you recommended I changed the following things in my snappyHexMeshDict:

Code:
features 
    (
	{file "Flow_Inlet.eMesh"; level 0;}
	{file "Flow_Outlet.eMesh"; level 0;}
	{file "Walls.eMesh"; level 1;}
    );
which should cover all existing feature edges and

Code:
    refinementSurfaces // Surface-wise min and max refinement level. Block is needed to define faces.
    {
	Flow_Inlet {level (0 0);}
	Flow_Outlet {level (0 0);}
	Left_Ducts {level (0 0);}
	Right_Ducts {level (0 0);}
	Lower_Ducts {level (0 0);}
	Upper_Ducts {level (0 0);}
	Walls {level (1 2);}
    }
The mesh does not look bad however the difference in the amount of faces for the boundaries I want to connect via cyclicAMI did actually increase to

Code:
    Lower_Ducts
    {
        type            patch;
        nFaces          9098;
        startFace       30712726;
    }
    Upper_Ducts
    {
        type            patch;
        nFaces          17952;
        startFace       30721824;
    }
Additionaly the layer adding step failed, so no boundary layer was added.

Do you have any further ideas to enhance my mesh? Thanks in advance for any help!
Attached Images
File Type: jpg cfd-online_inlet_improved.jpg (125.3 KB, 82 views)
File Type: jpg Right_Ducts_improved.jpg (122.5 KB, 68 views)
File Type: jpg Lower_Ducts_improved.jpg (127.0 KB, 59 views)
File Type: jpg Upper_Ducts_improved.jpg (136.0 KB, 43 views)
Illmatic is offline   Reply With Quote

Old   July 19, 2016, 10:24
Default
  #4
Senior Member
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0
chegdan will become famous soon enoughchegdan will become famous soon enough
You're moving in the right direction. Most of the issues with meshing with snappyHexMesh, whether that be resolving features or adding layers, can be fixed with more refinement (edge, surface, and volume refinement). To answer some of your questions:
  • The reason why layers were not added is because adding layers will cause poor quality cells in the large cells you have provided. The mesh quality metrics prevent a poor mesh from being created (i.e. snappyHexMesh is a quality driven mesher). Refine more and leave the mesh quality metrics as they are by default.
  • The number of cells on the boundary changed because we refined the boundaries in order to resolve them. This means that there are now more faces. I fyou do not have a 1 to 1 topological match on your cyclic boundaries then you will need to use cyclicAMI instead of cyclic.
I can suggest the most recent training (2016) (from the OpenFOAM workshop) on snappyHexMesh that will go through how to mesh and provide an overview of snappyHexMesh. For a bit more detail on the entries in the snappyHexMeshDict, try an older version of that training from the 7th OpenFOAM workshop. The most important component of the recent slides, is that it will guide you through how to mesh simple cases and provide reasons why things did not work as expected. In the end, you will need to explore what the controls provided in snappyHexMesh do and try to resolve your geometry and simulate physics. Good luck.

Last edited by wyldckat; October 18, 2023 at 08:02. Reason: Updated the link to the AndrewJackson shared folder
chegdan is offline   Reply With Quote

Old   July 20, 2016, 07:07
Default
  #5
Member
 
Axel
Join Date: May 2016
Location: Augsburg, Germany
Posts: 46
Rep Power: 10
Illmatic is on a distinguished road
Hi Dan, thanks for your reply again!
So I took a few steps back and oriented myself at the snappyHexMeshDict of the motorBike tutorial. The first huge difference I noticed was, that the inital block mesh in the motorBike example was much coarser than in my case. I now changed it to

Code:
blocks
(
    hex (0 1 2 3 4 5 6 7) (50 6 4) simpleGrading (1 1 1)
);
Then I changed my snappyHexMeshDict according to the motorBike example:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.2.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     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. Definition of all surfaces. All surfaces are of class
// searchableSurface.
// Surfaces are used
// - to specify refinement for any mesh cell intersecting it
// - to specify refinement for any mesh cell inside/outside/near
// - to 'snap' the mesh boundary to the surface
geometry // Load in STL files here
{
	Flow_Inlet.stl {type triSurfaceMesh; name Flow_Inlet;}
	Flow_Outlet.stl {type triSurfaceMesh; name Flow_Outlet;}
	Left_Ducts.stl {type triSurfaceMesh; name Left_Ducts;}
	Right_Ducts.stl {type triSurfaceMesh; name Right_Ducts;}
	Lower_Ducts.stl {type triSurfaceMesh; name Lower_Ducts;}	
	Upper_Ducts.stl {type triSurfaceMesh; name Upper_Ducts;}
	Walls.stl {type triSurfaceMesh; name Walls;}
	All_Faces.stl {type triSurfaceMesh; name All_Faces;}
};

castellatedMeshControls
{
    // Refinement parameters
    // ~~~~~~~~~~~~~~~~~~~~~

    // If local number of cells is >= maxLocalCells on any processor
    // switches from from refinement followed by balancing
    // (current method) to (weighted) balancing before refinement.
    maxLocalCells 100000;

    // 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.
    maxGlobalCells 2000000;

    // The surface refinement loop might spend lots of iterations refining just a
    // few cells. This setting will cause refinement to stop if <= minimumRefine
    // are selected for refinement. Note: it will at least do one iteration
    // (unless the number of cells to refine is 0)
    minRefinementCells 10;

    // Allow a certain level of imbalance during refining
    // (since balancing is quite expensive)
    // Expressed as fraction of perfect balance (= overall number of cells /
    // nProcs). 0=balance always.
    maxLoadUnbalance 0.10;


    // Number of buffer layers between different levels.
    // 1 means normal 2:1 refinement restriction, larger means slower
    // refinement.
    nCellsBetweenLevels 3;

    // Explicit feature edge refinement
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // taken from STL from each .eMesh file created by "SurfaceFeatureExtract" command
    features 
    (
	{file "Flow_Inlet.eMesh"; level 6;}
	{file "Flow_Outlet.eMesh"; level 6;}
	{file "Walls.eMesh"; level 6;}
    );

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

    refinementSurfaces // Surface-wise min and max refinement level. Block is needed to define faces.
    {
	Flow_Inlet {level (5 6);}
	Flow_Outlet {level (5 6);}
	Left_Ducts {level (5 6);}
	Right_Ducts {level (5 6);}
	Lower_Ducts {level (5 6);}
	Upper_Ducts {level (5 6);}
	Walls {level (5 6);}
    }  

    refinementRegions
    {
    }

    resolveFeatureAngle 30;  // Resolve sharp angles // Default 30
    locationInMesh (2e-02 0 2e-03);  //to decide which side of mesh to keep **
    allowFreeStandingZoneFaces true;
}


// Settings for the snapping.
snapControls
{
    //- Number of patch smoothing iterations before finding correspondence
    //  to surface
    nSmoothPatch 3;

    //- Relative distance for points to be attracted by surface feature point
    //  or edge. True distance is this factor times local
    //  maximum edge length.
    tolerance 2.0;

    //- Number of mesh displacement relaxation iterations.
    nSolveIter 30;

    //- Maximum number of snapping relaxation iterations. Should stop
    //  before upon reaching a correct mesh.
    nRelaxIter 5;

    // Feature snapping

        //- Number of feature edge snapping iterations.
        //  Leave out altogether to disable.
        nFeatureSnapIter 10;

        //- Detect (geometric only) features by sampling the surface
        //  (default=false).
        implicitFeatureSnap false;

        //- Use castellatedMeshControls::features (default = true)
        explicitFeatureSnap true;

        //- Detect points on multiple surfaces (only for explicitFeatureSnap)
        multiRegionFeatureSnap false;
}



// Settings for the layer addition.
addLayersControls //add the PATCH names from inside the STL file so STLpatchName_insideSTLName 
{
    relativeSizes true; // was true
    layers
    {
	Walls
         	{
			nSurfaceLayers 3;
		}
    }

    // Expansion factor for layer mesh
    expansionRatio 1.0;

    // Wanted thickness of final added cell layer. If multiple layers
    // is the thickness of the layer furthest away from the wall.
    // Relative to undistorted size of cell outside layer.
    // See relativeSizes parameter.
    finalLayerThickness 0.3;

    // Minimum thickness of cell layer. If for any reason layer
    // cannot be above minThickness do not add layer.
    // Relative to undistorted size of cell outside layer.
    minThickness 0.1;

    // If points get not extruded do nGrow layers of connected faces that are
    // also not grown. This helps convergence of the layer addition process
    // close to features.
    // Note: changed(corrected) w.r.t 17x! (didn't do anything in 17x)
    nGrow 0;

    // Advanced settings

    // When not to extrude surface. 0 is flat surface, 90 is when two faces
    // are perpendicular
    featureAngle 60;

    // At non-patched sides allow mesh to slip if extrusion direction makes
    // angle larger than slipFeatureAngle.
    slipFeatureAngle 30;

    // Maximum number of snapping relaxation iterations. Should stop
    // before upon reaching a correct mesh.
    nRelaxIter 3;

    // Number of smoothing iterations of surface normals
    nSmoothSurfaceNormals 1;

    // Number of smoothing iterations of interior mesh movement direction
    nSmoothNormals 3;

    // Smooth layer thickness over surface patches
    nSmoothThickness 10;

    // Stop layer growth on highly warped cells
    maxFaceThicknessRatio 0.5;

    // Reduce layer growth where ratio thickness to medial
    // distance is large
    maxThicknessToMedialRatio 0.3;

    // Angle used to pick up medial axis points
    // Note: changed(corrected) w.r.t 17x! 90 degrees corresponds to 130 in 17x.
    minMedianAxisAngle 90;


    // Create buffer region for new layer terminations
    nBufferCellsNoExtrude 0;


    // Overall max number of layer addition iterations. The mesher will exit
    // if it reaches this number of iterations; possibly with an illegal
    // mesh.
    nLayerIter 50;
}





// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
			// disabled // enabled
meshQualityControls
{
//- Maximum non-orthogonality allowed. Set to 180 to disable.
maxNonOrtho 65;

//- Max skewness allowed. Set to <0 to disable.
maxBoundarySkewness 20;
maxInternalSkewness 4;

//- Max concaveness allowed. Is angle (in degrees) below which concavity
//  is allowed. 0 is straight face, <0 would be convex face.
//  Set to 180 to disable.
maxConcave 80;

//- Minimum pyramid volume. Is absolute volume of cell pyramid.
//  Set to a sensible fraction of the smallest cell volume expected.
//  Set to very negative number (e.g. -1E30) to disable.
minVol 1e-13;

//- Minimum quality of the tet formed by the face-centre
//  and variable base point minimum decomposition triangles and
//  the cell centre. This has to be a positive number for tracking
//  to work. Set to very negative number (e.g. -1E30) to
//  disable.
//     <0 = inside out tet,
//      0 = flat tet
//      1 = regular tet
minTetQuality 1e-15;

//- Minimum face area. Set to <0 to disable.
minArea -1;

//- Minimum face twist. Set to <-1 to disable. dot product of face normal
// and face centre triangles normal
minTwist 0.02;

//- Minimum normalised cell determinant. This is the determinant of all
//  the areas of internal faces. It is a measure of how much of the
//  outside area of the cell is to other cells. The idea is that if all
//  outside faces of the cell are 'floating' (zeroGradient) the
//  'fixedness' of the cell is determined by the area of the internal faces.
//  1 = hex, <= 0 = folded or flattened illegal cell
minDeterminant 0.001;

//- Relative position of face in relation to cell centres (0.5 for orthogonal
//  mesh) (0 -> 0.5)
minFaceWeight 0.05;

//- Volume ratio of neighbouring cells (0 -> 1)
minVolRatio 0.01;

//- Per triangle normal compared to average normal. Like face twist
//  but now per (face-centre decomposition) triangle. Must be >0 for Fluent
//  compatibility
minTriangleTwist -1;


//- If >0 : preserve cells with all points on the surface if the
//  resulting volume after snapping (by approximation) is larger than
//  minVolCollapseRatio times old volume (i.e. not collapsed to flat cell).
//  If <0 : delete always.
//minVolCollapseRatio 0.1;

}

// 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;


// ************************************************************************* //
Unfortunatly now the snapping of the mesh doesn't work anymore as you can see in the images below. What is your general procedure if you run in a situation like this?
Attached Images
File Type: jpg blockMesh.jpg (55.9 KB, 52 views)
File Type: jpg snappy_didnt_snap.jpg (193.7 KB, 96 views)
Illmatic is offline   Reply With Quote

Old   July 20, 2016, 12:37
Default
  #6
Senior Member
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0
chegdan will become famous soon enoughchegdan will become famous soon enough
I would get out a pen, a piece of paper, and a calculator and determine the size of all the levels that you are using in your mesh.
  • Are these cell sizes sufficient to resolve the spaces between your surfaces (no)? You need at least 2 cells between an STL to capture (in axis aligned surfaces), preferable to have more than 2 cells in that space.
  • Are these sizes currently small enough for the snapping algorithm to snap to the surfaces (no)?

I would turn off layer addition for now until you have good snapping and then go back and turn that back on. I woudl also make sure that all your mesh quality settings are their default and work on decreasing the base mesh sizing or refinement until you get snapping. Once you have a mesh resolved, simulate and then adjust your mesh accordingly.
chegdan is offline   Reply With Quote

Old   July 22, 2016, 12:18
Default
  #7
Member
 
Axel
Join Date: May 2016
Location: Augsburg, Germany
Posts: 46
Rep Power: 10
Illmatic is on a distinguished road
Hi Dan,
I was able to get a very nice looking snapped mesh w/o layers. What confuses me is that the snapping quality somehow decreases when I'm increasing the refinement level.

The image I attached belongs to the following sHMDict:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.2.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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


geometry // Load in STL files here
{
	Flow_Inlet.stl {type triSurfaceMesh; name Flow_Inlet;}
	Flow_Outlet.stl {type triSurfaceMesh; name Flow_Outlet;}
	Left_Ducts.stl {type triSurfaceMesh; name Left_Ducts;}
	Right_Ducts.stl {type triSurfaceMesh; name Right_Ducts;}
	Lower_Ducts.stl {type triSurfaceMesh; name Lower_Ducts;}	
	Upper_Ducts.stl {type triSurfaceMesh; name Upper_Ducts;}
	Walls.stl {type triSurfaceMesh; name Walls;}
	All_Faces.stl {type triSurfaceMesh; name All_Faces;}
};

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

    // Explicit feature edge refinement
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // taken from STL from each .eMesh file created by "SurfaceFeatureExtract" command
    features 
    (
	{file "Flow_Inlet.eMesh"; level 0;}
	{file "Flow_Outlet.eMesh"; level 0;}
    );

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

    refinementSurfaces // Surface-wise min and max refinement level. Block is needed to define faces.
    {
	Flow_Inlet {level (0 0);}
	Flow_Outlet {level (0 0);}
	Left_Ducts {level (0 0);}
	Right_Ducts {level (0 0);}
	Lower_Ducts {level (0 0);}
	Upper_Ducts {level (0 0);}
	Walls {level (0 0);}
    }  

    refinementRegions        // In descending levels of fine-ness. For finer regions.
    {
//	Lower_Ducts
//	{
//		mode distance;
//		levels ((0.0005 2));
//	}
    } 

    resolveFeatureAngle 30;  // Resolve sharp angles // Default 30
    locationInMesh (2e-02 0 2e-03);  //to decide which side of mesh to keep **
    allowFreeStandingZoneFaces true;
}


// Settings for the snapping.
snapControls
{
    //- Number of patch smoothing iterations before finding correspondence
    //  to surface
    nSmoothPatch 3;

    //- Relative distance for points to be attracted by surface feature point
    //  or edge. True distance is this factor times local
    //  maximum edge length.
    tolerance 2.0;

    //- Number of mesh displacement relaxation iterations.
    nSolveIter 30;

    //- Maximum number of snapping relaxation iterations. Should stop
    //  before upon reaching a correct mesh.
    nRelaxIter 5;

    // Feature snapping

        //- Number of feature edge snapping iterations.
        //  Leave out altogether to disable.
        nFeatureSnapIter 10;

        //- Detect (geometric only) features by sampling the surface
        //  (default=false).
        implicitFeatureSnap false;

        //- Use castellatedMeshControls::features (default = true)
        explicitFeatureSnap true;

        //- Detect points on multiple surfaces (only for explicitFeatureSnap)
        multiRegionFeatureSnap false;

}



// Settings for the layer addition.
addLayersControls //add the PATCH names from inside the STL file so STLpatchName_insideSTLName 
{
    relativeSizes true; // was true
    layers
    {
	Walls
         	{nSurfaceLayers 3;}
    }

    // Expansion factor for layer mesh
    expansionRatio 1.0;

    // Wanted thickness of final added cell layer. If multiple layers
    // is the thickness of the layer furthest away from the wall.
    // Relative to undistorted size of cell outside layer.
    // See relativeSizes parameter.
    finalLayerThickness 0.15;

    // Minimum thickness of cell layer. If for any reason layer
    // cannot be above minThickness do not add layer.
    // Relative to undistorted size of cell outside layer.
    minThickness 0.05;

    // If points get not extruded do nGrow layers of connected faces that are
    // also not grown. This helps convergence of the layer addition process
    // close to features.
    // Note: changed(corrected) w.r.t 17x! (didn't do anything in 17x)
    nGrow 0;

    // Advanced settings

    // When not to extrude surface. 0 is flat surface, 90 is when two faces
    // are perpendicular
    featureAngle 60;

    // At non-patched sides allow mesh to slip if extrusion direction makes
    // angle larger than slipFeatureAngle.
    slipFeatureAngle 30;

    // Maximum number of snapping relaxation iterations. Should stop
    // before upon reaching a correct mesh.
    nRelaxIter 3;

    // Number of smoothing iterations of surface normals
    nSmoothSurfaceNormals 1;

    // Number of smoothing iterations of interior mesh movement direction
    nSmoothNormals 3;

    // Smooth layer thickness over surface patches
    nSmoothThickness 10;

    // Stop layer growth on highly warped cells
    maxFaceThicknessRatio 0.5;

    // Reduce layer growth where ratio thickness to medial
    // distance is large
    maxThicknessToMedialRatio 0.3;

    // Angle used to pick up medial axis points
    // Note: changed(corrected) w.r.t 17x! 90 degrees corresponds to 130 in 17x.
    minMedianAxisAngle 90;


    // Create buffer region for new layer terminations
    nBufferCellsNoExtrude 0;


    // Overall max number of layer addition iterations. The mesher will exit
    // if it reaches this number of iterations; possibly with an illegal
    // mesh.
    nLayerIter 50;
}



meshQualityControls
{
//- Maximum non-orthogonality allowed. Set to 180 to disable.
maxNonOrtho 65;

//- Max skewness allowed. Set to <0 to disable.
maxBoundarySkewness 20;
maxInternalSkewness 4;

//- Max concaveness allowed. Is angle (in degrees) below which concavity
//  is allowed. 0 is straight face, <0 would be convex face.
//  Set to 180 to disable.
maxConcave 80;

//- Minimum pyramid volume. Is absolute volume of cell pyramid.
//  Set to a sensible fraction of the smallest cell volume expected.
//  Set to very negative number (e.g. -1E30) to disable.
minVol 1e-13;

//- Minimum quality of the tet formed by the face-centre
//  and variable base point minimum decomposition triangles and
//  the cell centre. This has to be a positive number for tracking
//  to work. Set to very negative number (e.g. -1E30) to
//  disable.
//     <0 = inside out tet,
//      0 = flat tet
//      1 = regular tet
minTetQuality 1e-15;

//- Minimum face area. Set to <0 to disable.
minArea -1;

//- Minimum face twist. Set to <-1 to disable. dot product of face normal
// and face centre triangles normal
minTwist 0.02;

//- Minimum normalised cell determinant. This is the determinant of all
//  the areas of internal faces. It is a measure of how much of the
//  outside area of the cell is to other cells. The idea is that if all
//  outside faces of the cell are 'floating' (zeroGradient) the
//  'fixedness' of the cell is determined by the area of the internal faces.
//  1 = hex, <= 0 = folded or flattened illegal cell
minDeterminant 0.001;

//- Relative position of face in relation to cell centres (0.5 for orthogonal
//  mesh) (0 -> 0.5)
minFaceWeight 0.05;

//- Volume ratio of neighbouring cells (0 -> 1)
minVolRatio 0.01;

//- Per triangle normal compared to average normal. Like face twist
//  but now per (face-centre decomposition) triangle. Must be >0 for Fluent
//  compatibility
minTriangleTwist -1;

    // Optional
    minFlatness 0.5;

    // Advanced
    nSmoothScale 4;
    errorReduction 0.75;
}

// 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;


// ************************************************************************* //
In the second image I increased the refinement for the feature edges to
Code:
    features 
    (
	{file "Flow_Inlet.eMesh"; level 1;}
	{file "Flow_Outlet.eMesh"; level 1;}
	{file "Left_Ducts.eMesh"; level 1;}
	{file "Right_Ducts.eMesh"; level 1;}
	{file "Upper_Ducts.eMesh"; level 1;}
	{file "Lower_Ducts.eMesh"; level 1;}
    );
If I increase the refinement on the surfaces I already get a enormous number of cells and layer addition is still not working. Is it not possible to mesh my geometry in good quality with 1e6 to 2e6 cells? Or do I need to start with a much coarser blockMesh and then use refinement on surfaces and edges?
Attached Images
File Type: jpg cfd-online_no_refinement.jpg (195.8 KB, 81 views)
File Type: jpg cfd-online_w_refinement.jpg (121.9 KB, 61 views)
Illmatic is offline   Reply With Quote

Old   July 23, 2016, 12:07
Default
  #8
Senior Member
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0
chegdan will become famous soon enoughchegdan will become famous soon enough
Depending on your application, 1e6 or 2e6 is still a small mesh where the cell count ultimately depends on a balance between desired accuracy and computational resources. Meaning, you will mesh, simulation, check your solution,assess, and remesh. Continue this cycle until your solltuion does not "significantly" change or you run out of computational resources. I regularly run simulations on meshes anywhere from 1e6 to 1e9 cells in order to get the results i need. lastly, the sole reason layers where not added is becasue when added, the mesh quality criteria were not met so it was scaled back. Refine more to get small enough cells or try adding a single layer to start.
derekm likes this.

Last edited by chegdan; July 23, 2016 at 14:17.
chegdan is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[CAD formats] Creating waterproof STL using snappyHexMesh or salome Tobi OpenFOAM Meshing & Mesh Conversion 58 May 13, 2020 07:01
[snappyHexMesh] different sHM results on same geometry when everythin is in one or several stl-files. Laika OpenFOAM Meshing & Mesh Conversion 1 September 8, 2016 05:09
[snappyHexMesh] Using STL Geometry vegaonline OpenFOAM Meshing & Mesh Conversion 5 February 25, 2014 10:43
[ICEM] Mesh unable to follow curved geometry Ananthakrishnan ANSYS Meshing & Geometry 27 July 7, 2012 04:15
fan with geometry stl Hitomi OpenFOAM 1 August 18, 2011 12:27


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