|
[Sponsors] |
[snappyHexMesh] SnappyHexMesh: Layer on corners |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 13, 2014, 09:53 |
SnappyHexMesh: Layer on corners
|
#1 |
Member
Luca
Join Date: Mar 2013
Posts: 68
Rep Power: 13 |
Hi everybody,
I'm trying to create a mesh for a rectangular shape body on the bottom of a channel. I'm using snappyHex to refine and create the layers, but it fails creating the layers around the corners. The geometry is given as a single stl file. I found this discussion about this topic, but the solution it proposes doesn't work. I tried changing the featureAngle from 0 to 359, but it didn't help. On the contrary: setting it greater than 180, snappyHex doesn't add any layer at all. I post some pictures and the snappyHexMeshDict: Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 1.7.1 | | \\ / 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. 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 { hangar.stl { type triSurfaceMesh; name hangar; } refinementBox { type searchableBox; min (-3500 -2000 0.0); max ( 5000 2000 700); } }; // Settings for the castellatedMesh generation. 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 500000000; // 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 800000000; // 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 1000; // 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 4; // Explicit feature edge refinement // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Specifies a level for any cell intersected by its edges. // This is a featureEdgeMesh, read from constant/triSurface for now. features ( { file "hangar.eMesh"; level 5; } ); // Surface based refinement // ~~~~~~~~~~~~~~~~~~~~~~~~ // Specifies two levels for every surface. The first is the minimum level, // every cell intersecting a surface gets refined up to the minimum level. // The second level is the maximum level. Cells that 'see' multiple // intersections where the intersections make an // angle > resolveFeatureAngle get refined up to the maximum level. refinementSurfaces { hangar { // Surface-wise min and max refinement level level (5 5); } } // Resolve sharp angles resolveFeatureAngle 90; // Region-wise refinement // ~~~~~~~~~~~~~~~~~~~~~~ // Specifies refinement level for cells in relation to a surface. One of // three modes // - distance. 'levels' specifies per distance to the surface the // wanted refinement level. The distances need to be specified in // descending order. // - inside. 'levels' is only one entry and only the level is used. All // cells inside the surface get refined up to the level. The surface // needs to be closed for this to be possible. // - outside. Same but cells outside. refinementRegions { refinementBox { mode inside; levels ((1.0 3)); } } // Mesh selection // ~~~~~~~~~~~~~~ // After refinement patches get added for all refinementSurfaces and // all cells intersecting the surfaces get put into these patches. The // section reachable from the locationInMesh is kept. // NOTE: This point should never be on a face, always inside a cell, even // after refinement. locationInMesh (0 0 500); allowFreeStandingZoneFaces false; } // Settings for the snapping. snapControls { //- Number of patch smoothing iterations before finding correspondence // to surface nSmoothPatch 10; //- Relative distance for points to be attracted by surface feature point // or edge. True distance is this factor times local // maximum edge length. tolerance 4.0; //- Number of mesh displacement relaxation iterations. nSolveIter 200; //- Maximum number of snapping relaxation iterations. Should stop // before upon reaching a correct mesh. nRelaxIter 40; } // Settings for the layer addition. addLayersControls { // Are the thickness parameters below relative to the undistorted // size of the refined cell outside layer (true) or absolute sizes (false). relativeSizes true; // Per final patch (so not geometry!) the layer information layers { hangar_patch0 { nSurfaceLayers 10; } } // Expansion factor for layer mesh expansionRatio 1.2; //- Wanted thickness of final added cell layer. If multiple layers // is the thickness of the layer furthest away from the wall. // See relativeSizes parameter. finalLayerThickness 0.8; //- 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.0000000001; //0.001; //- 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. nGrow 5; // Advanced settings //- When not to extrude surface. 0 is flat surface, 90 is when two faces // make straight angle. featureAngle 310; //- Maximum number of snapping relaxation iterations. Should stop // before upon reaching a correct mesh. nRelaxIter 40; // Number of smoothing iterations of surface normals nSmoothSurfaceNormals 20; // Number of smoothing iterations of interior mesh movement direction nSmoothNormals 30; // Smooth layer thickness over surface patches nSmoothThickness 20; // 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 minMedianAxisAngle 90; // Create buffer region for new layer terminations nBufferCellsNoExtrude 0; // Overall max number of layer addition iterations nLayerIter 300; } // Generic mesh quality settings. At any undoable phase these determine // where to undo. 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 projected area v.s. actual area. Set to -1 to disable. minFlatness 0.5; //- 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; minTetQuality 1e-30; //- 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 //- 1 = hex, <= 0 = folded or flattened illegal cell minDeterminant 0.00001; //- minFaceWeight (0 -> 0.5) minFaceWeight 0.02; //- minVolRatio (0 -> 1) minVolRatio 0.01; //must be >0 for Fluent compatibility minTriangleTwist -1; // Advanced //- Number of error distribution iterations nSmoothScale 30; //- amount to scale back displacement at error points errorReduction 0.75; } // Advanced // Flags for optional output // 0 : only write final meshes // 1 : write intermediate meshes // 2 : write volScalarField with cellLevel for postprocessing // 4 : write current intersections as .obj files 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; Last edited by Pj.; January 15, 2014 at 08:26. |
|
January 14, 2014, 08:29 |
|
#2 |
Senior Member
|
Hi Pj.,
How about the following numbers? castellatedMeshControls resolveFeatureAngle 60; addLayersControls nGrow 0; Using the latest OpenFOAM is recommended. SnappyHexMesh has tremendously improved. Note: nGrow is changed(corrected) w.r.t 17x! (didn't do anything in 17x) |
|
January 14, 2014, 13:22 |
|
#3 |
Member
Luca
Join Date: Mar 2013
Posts: 68
Rep Power: 13 |
Thank you very much for the tip snak.
I did some tests how you suggested and i found some strange behaviours: changing just resolveFeatureAngle to 60 and nGrow to 0 helped a bit, but didn't solved the problem completely (PICTURE 1) I tried fixing the problem changing other parameters, until I decided to reduce the number of layer. Reducing the number of layer up to 8 solved the problem (PICTURE 2). At this point i thought the problem was the space needed to add the layer: if the space is too big snappy fails adding it. Therefore i decided to do another test. Using a bit of math I calculated how much space does the layer take up. With expansionRatio 1.2 and 8 layers, the whole layer should take up 4.6 time the size of the last cell. With expansionRatio 1.3 and 10 layers should take up instead 4.02 time the size of the last cell (feel free to correct me). The problem is that if I try to add 10 layers with expansionRatio 1.3 the problem show up again, even if it's clear from the picture that the layers are a lot thinner. (PICTURE 3) In conclusion: what causes the problem? Is there a way to add more than 8 layers without running into this problem? Thank you very much |
|
January 15, 2014, 06:21 |
|
#4 |
Senior Member
|
Nice try, PJ!
the corner of the rectangular shape body is not sharp. Did you apply the surfaceFeatureExtract utility before snappyHexMesh? You could add the following lines in snapControls section of snappyHexMeshDict. // Feature snapping //- Number of feature edge snapping iterations. // Leave out altogether to disable. nFeatureSnapIter 10; //- Detect (geometric) features by sampling the surface implicitFeatureSnap false; //- Use castellatedMeshControls::features explicitFeatureSnap true; //- Detect features between multiple surfaces // (only for explicitFeatureSnap, default = false) multiRegionFeatureSnap true; Which version of OpenFOAM are you using? |
|
January 15, 2014, 07:39 |
|
#5 |
Member
Luca
Join Date: Mar 2013
Posts: 68
Rep Power: 13 |
Thank you again for the hint.
I tried copying the lines you posted in the dictionary. Snappy took a lot more iteration to reach convergence. The edge is indeed a lot sharper, but the results is not satisfying at all. Moreover there is no-layer, but maybe this is due that was impossible to add it because of the very distorted mesh near the corner. Just to completely answer your question: yes, i ran the surfaceFeatureExtract utility and i'm using Build: 2.2.1-57f3c3617a2d |
|
January 15, 2014, 12:26 |
|
#6 |
Senior Member
|
Hi PJ,
Now you have a sharp edge. I suspect featureAngle 310 in addLayersControls causes some problem. Could you try with featureAngle 60 which is a common number in tutorials? I did quick test with 60 and 310 in iglooWithFridges tutorial. 310 blow out the layer localy. |
|
January 15, 2014, 12:33 |
|
#7 |
Member
Luca
Join Date: Mar 2013
Posts: 68
Rep Power: 13 |
I will double check it, but i'm afraid the last mesh has already been obtained with featureAngle 60.
Here is the snappyHexMeshDict I've used to do it: Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 1.7.1 | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; object snappyHexMeshDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // NOTE: LARGE NUMBER OF ITERATIONS VERSION!!!!!!!!!!!!!!!!!!!!!! // 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 { hangar.stl { type triSurfaceMesh; name hangar; } spiresGialli.stl { type triSurfaceMesh; name spiresGialli; } ostacolo2D.stl //roughS.stl { type triSurfaceMesh; name roughSmall; /*regions { ascii { name patch0; } }*/ } roughM.stl { type triSurfaceMesh; name roughMedium; /*regions { ascii { name patch0; } }*/ } roughL.stl { type triSurfaceMesh; name roughLarge; /*regions { ascii { name patch0; } }*/ } refinementBox { type searchableBox; min (-3500 -2000 0.0); max ( 5000 2000 700); } }; // Settings for the castellatedMesh generation. 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 500000000; // 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 800000000; // 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 1000; // 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 4; // Explicit feature edge refinement // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Specifies a level for any cell intersected by its edges. // This is a featureEdgeMesh, read from constant/triSurface for now. features ( { file "spiresGialli.eMesh"; level 2; } { file "ostacolo2D.eMesh"; //file "roughS.eMesh"; level 3; } { file "roughM.eMesh"; level 2; } { file "roughL.eMesh"; level 2; } { file "hangar.eMesh"; level 5; } ); // Surface based refinement // ~~~~~~~~~~~~~~~~~~~~~~~~ // Specifies two levels for every surface. The first is the minimum level, // every cell intersecting a surface gets refined up to the minimum level. // The second level is the maximum level. Cells that 'see' multiple // intersections where the intersections make an // angle > resolveFeatureAngle get refined up to the maximum level. refinementSurfaces { spiresGialli { // Surface-wise min and max refinement level level (2 2); } roughSmall { // Surface-wise min and max refinement level level (2 2); } roughMedium { // Surface-wise min and max refinement level level (2 2); } roughLarge { // Surface-wise min and max refinement level level (2 2); } hangar { // Surface-wise min and max refinement level level (5 5); } } // Resolve sharp angles resolveFeatureAngle 30; //90; // Region-wise refinement // ~~~~~~~~~~~~~~~~~~~~~~ // Specifies refinement level for cells in relation to a surface. One of // three modes // - distance. 'levels' specifies per distance to the surface the // wanted refinement level. The distances need to be specified in // descending order. // - inside. 'levels' is only one entry and only the level is used. All // cells inside the surface get refined up to the level. The surface // needs to be closed for this to be possible. // - outside. Same but cells outside. refinementRegions { refinementBox { mode inside; levels ((1.0 3)); } } // Mesh selection // ~~~~~~~~~~~~~~ // After refinement patches get added for all refinementSurfaces and // all cells intersecting the surfaces get put into these patches. The // section reachable from the locationInMesh is kept. // NOTE: This point should never be on a face, always inside a cell, even // after refinement. locationInMesh (0 0 500); allowFreeStandingZoneFaces false; } // Settings for the snapping. snapControls { //- Number of patch smoothing iterations before finding correspondence // to surface nSmoothPatch 10; //- Relative distance for points to be attracted by surface feature point // or edge. True distance is this factor times local // maximum edge length. tolerance 4.0; //- Number of mesh displacement relaxation iterations. nSolveIter 200; //- Maximum number of snapping relaxation iterations. Should stop // before upon reaching a correct mesh. nRelaxIter 40; // Feature snapping //- Number of feature edge snapping iterations. // Leave out altogether to disable. nFeatureSnapIter 10; //- Detect (geometric) features by sampling the surface implicitFeatureSnap false; //- Use castellatedMeshControls::features explicitFeatureSnap true; //- Detect features between multiple surfaces // (only for explicitFeatureSnap, default = false) multiRegionFeatureSnap true; } // Settings for the layer addition. addLayersControls { // Are the thickness parameters below relative to the undistorted // size of the refined cell outside layer (true) or absolute sizes (false). relativeSizes true; // Per final patch (so not geometry!) the layer information layers { bottom { nSurfaceLayers 5; } hangar_patch0 { nSurfaceLayers 10; } } // Expansion factor for layer mesh expansionRatio 1.3; //- Wanted thickness of final added cell layer. If multiple layers // is the thickness of the layer furthest away from the wall. // See relativeSizes parameter. finalLayerThickness 0.77; //- 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.0000000001; //0.001; //- 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. nGrow 0; //5; // Advanced settings //- When not to extrude surface. 0 is flat surface, 90 is when two faces // make straight angle. featureAngle 60; //- Maximum number of snapping relaxation iterations. Should stop // before upon reaching a correct mesh. nRelaxIter 40; // Number of smoothing iterations of surface normals nSmoothSurfaceNormals 20; // Number of smoothing iterations of interior mesh movement direction nSmoothNormals 30; // Smooth layer thickness over surface patches nSmoothThickness 20; // 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 minMedianAxisAngle 90; // Create buffer region for new layer terminations nBufferCellsNoExtrude 0; // Overall max number of layer addition iterations nLayerIter 300; } // Generic mesh quality settings. At any undoable phase these determine // where to undo. 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 projected area v.s. actual area. Set to -1 to disable. minFlatness 0.5; //- 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; minTetQuality 1e-30; //- 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 //- 1 = hex, <= 0 = folded or flattened illegal cell minDeterminant 0.00001; //- minFaceWeight (0 -> 0.5) minFaceWeight 0.02; //- minVolRatio (0 -> 1) minVolRatio 0.01; //must be >0 for Fluent compatibility minTriangleTwist -1; // Advanced //- Number of error distribution iterations nSmoothScale 30; //- amount to scale back displacement at error points errorReduction 0.75; } // Advanced // Flags for optional output // 0 : only write final meshes // 1 : write intermediate meshes // 2 : write volScalarField with cellLevel for postprocessing // 4 : write current intersections as .obj files 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; // ************************************************************************* // |
|
July 16, 2014, 05:44 |
|
#8 |
New Member
Join Date: Mar 2014
Posts: 17
Rep Power: 12 |
Hi Pj.
Did you find a solution to your problem. I am experimenting the same kind of issues. I don't understand why the boundary layer thickness decreases in the edges vicinity, while I'm using relativeSizes false. Has anybody any idea? BenJ |
|
July 17, 2014, 04:28 |
|
#9 |
Senior Member
matej forman
Join Date: Mar 2009
Location: Brno, Czech Republic
Posts: 182
Rep Power: 17 |
Few comments:
in refinementSurfaces you set the minimum and maximum size level to the same numbers, so you do not allow solver to reach better convergence by altering the mesh size. It might make it hard for him to converge faster. Bud then you might go for relativeSize false; in layer settings. You may also need to test these parameters: // 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 minMedianAxisAngle 90; // Create buffer region for new layer terminations nBufferCellsNoExtrude 0; // Overall max number of layer addition iterations nLayerIter 300; |
|
July 17, 2014, 05:26 |
|
#10 |
New Member
Join Date: Mar 2014
Posts: 17
Rep Power: 12 |
Hi matejfor,
Thank you for your answer! I tried to play with those parameters, but I could not improve the mesh. I attached a view of what I am working on: a cube on which I'd like to add 5 layers. They are well added on the faces, but at the edges I don't manage to make it the same size as on the faces. I discovered the new feature "slipFeatureAngle" from OF 2.2.x, this seems exactly to be what I need. But it did not work on my case. Any idea? BenJ |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
y+ = 1 boundary layer mesh with snappyHexMesh | Arzed23 | OpenFOAM Running, Solving & CFD | 6 | November 23, 2022 16:15 |
[snappyHexMesh] Error defining boundary layer around cube snappyHexMesh | crizpi21 | OpenFOAM Meshing & Mesh Conversion | 5 | October 16, 2021 11:56 |
[snappyHexMesh] snappyHexMesh Boundary Layer at Corner | panpanzhong | OpenFOAM Meshing & Mesh Conversion | 5 | July 3, 2018 06:53 |
[snappyHexMesh] Problem airfoil snappyhexmesh add layer | bye bye my blue | OpenFOAM Meshing & Mesh Conversion | 1 | May 5, 2017 06:56 |
errors | Fahad | Main CFD Forum | 0 | March 23, 2004 14:20 |