From 47fa9bc620ea79e11b5023fd33c0bfcff6cb58fa Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Thu, 9 May 2024 12:26:09 +0100 Subject: [PATCH] snappyHexMesh: Corrected use of layer featureAngle The 'featureAngle' control defines the included angle between faces above which layer extrusion is prevented. Its use within snappyHexMesh was incorrect in that the cosine was not being taken before being compared to dot products of face normals. This has now been corrected. Existing 'featureAngle' settings may need changing to recover equivalent behaviour. Any angle previously set to 58 degrees or above previously resulted in no reduction of layer coverage. A large angle between 90 and 180 degrees is likely to be an appropriate replacement for cases such as this. Angles previously set to 57 degrees and below can be equivalently replaced by a value of (180/pi)*arccos(*(pi/180)). Note that changing the feature angle also affects the slip feature angle. The slip feature angle is taken to be half the feature angle if a 'slipFeatureAngle' is not specified. --- etc/caseDicts/annotated/snappyHexMeshDict | 2 +- .../snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C | 5 ++--- .../fluid/annularThermalMixer/system/snappyHexMeshDict | 3 ++- tutorials/fluid/iglooWithFridges/system/snappyHexMeshDict | 7 +++++-- .../cyclone/system/snappyHexMeshDict | 4 ++-- .../motorBike/motorBike/system/snappyHexMeshDict | 6 +++++- .../motorBikeSteady/system/snappyHexMeshDict | 4 ++-- .../incompressibleFluid/propeller/system/snappyHexMeshDict | 6 +++++- .../turbineSiting/system/snappyHexMeshDict | 6 +++++- .../wingMotion_snappyHexMesh/system/snappyHexMeshDict | 6 +++++- .../incompressibleVoF/DTCHull/system/snappyHexMeshDict | 6 +++++- .../DTCHullMoving/system/snappyHexMeshDict | 6 +++++- .../incompressibleVoF/DTCHullWave/system/snappyHexMeshDict | 6 +++++- .../cavitatingBullet/system/snappyHexMeshDict | 6 +++++- .../planingHullW3/system/snappyHexMeshDict.1 | 6 +++++- .../planingHullW3/system/snappyHexMeshDict.2 | 6 +++++- .../incompressibleVoF/propeller/system/snappyHexMeshDict | 6 +++++- .../mesh/snappyHexMesh/flange/system/snappyHexMeshDict | 6 +++++- 18 files changed, 74 insertions(+), 23 deletions(-) diff --git a/etc/caseDicts/annotated/snappyHexMeshDict b/etc/caseDicts/annotated/snappyHexMeshDict index cb98025b5c..b32904329e 100644 --- a/etc/caseDicts/annotated/snappyHexMeshDict +++ b/etc/caseDicts/annotated/snappyHexMeshDict @@ -412,7 +412,7 @@ addLayersControls // When not to extrude surface. 0 is flat surface, 90 is when two faces // are perpendicular - featureAngle 130; + featureAngle 100; // Stop layer growth on highly warped cells maxFaceThicknessRatio 0.5; diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C index 5d90f43e82..91d073a0d6 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C @@ -2793,9 +2793,8 @@ void Foam::snappyLayerDriver::mergePatchFacesUndo const dictionary& motionDict ) { - // Clip to 30 degrees. Not helpful! - // scalar planarAngle = min(30.0, layerParams.featureAngle()); scalar planarAngle = layerParams.featureAngle(); + scalar minCos = Foam::cos(degToRad(planarAngle)); scalar concaveCos = Foam::cos(degToRad(layerParams.concaveAngle())); @@ -2990,7 +2989,7 @@ void Foam::snappyLayerDriver::addLayers ( pp, meshEdges, - degToRad(layerParams.featureAngle()), + Foam::cos(degToRad(layerParams.featureAngle())), patchDisp, patchNLayers, diff --git a/tutorials/fluid/annularThermalMixer/system/snappyHexMeshDict b/tutorials/fluid/annularThermalMixer/system/snappyHexMeshDict index 67f2d3f374..8a07235393 100644 --- a/tutorials/fluid/annularThermalMixer/system/snappyHexMeshDict +++ b/tutorials/fluid/annularThermalMixer/system/snappyHexMeshDict @@ -227,7 +227,8 @@ addLayersControls finalLayerThickness 0.3; minThickness 0.1; nGrow 0; - featureAngle 30; + featureAngle 60; + slipFeatureAngle 15; nRelaxIter 3; nSmoothSurfaceNormals 1; nSmoothNormals 3; diff --git a/tutorials/fluid/iglooWithFridges/system/snappyHexMeshDict b/tutorials/fluid/iglooWithFridges/system/snappyHexMeshDict index e34f029152..5aa3ad351b 100644 --- a/tutorials/fluid/iglooWithFridges/system/snappyHexMeshDict +++ b/tutorials/fluid/iglooWithFridges/system/snappyHexMeshDict @@ -288,7 +288,11 @@ addLayersControls // When not to extrude surface. 0 is flat surface, 90 is when two faces // are perpendicular - featureAngle 60; + featureAngle 100; + + // At non-patched sides allow mesh to slip if extrusion direction makes + // angle larger than slipFeatureAngle. Default is 0.5*featureAngle. + slipFeatureAngle 30; // Maximum number of snapping relaxation iterations. Should stop // before upon reaching a correct mesh. @@ -317,7 +321,6 @@ addLayersControls // 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. diff --git a/tutorials/incompressibleDenseParticleFluid/cyclone/system/snappyHexMeshDict b/tutorials/incompressibleDenseParticleFluid/cyclone/system/snappyHexMeshDict index 4176d620fe..c3fc17af4e 100644 --- a/tutorials/incompressibleDenseParticleFluid/cyclone/system/snappyHexMeshDict +++ b/tutorials/incompressibleDenseParticleFluid/cyclone/system/snappyHexMeshDict @@ -200,10 +200,10 @@ addLayersControls // When not to extrude surface. 0 is flat surface, 90 is when two faces // are perpendicular - featureAngle 60; + featureAngle 100; // At non-patched sides allow mesh to slip if extrusion direction makes - // angle larger than slipFeatureAngle. + // angle larger than slipFeatureAngle. Default is 0.5*featureAngle. slipFeatureAngle 30; // Maximum number of snapping relaxation iterations. Should stop diff --git a/tutorials/incompressibleFluid/motorBike/motorBike/system/snappyHexMeshDict b/tutorials/incompressibleFluid/motorBike/motorBike/system/snappyHexMeshDict index fec07f1567..a389b2caca 100644 --- a/tutorials/incompressibleFluid/motorBike/motorBike/system/snappyHexMeshDict +++ b/tutorials/incompressibleFluid/motorBike/motorBike/system/snappyHexMeshDict @@ -223,7 +223,11 @@ addLayersControls // When not to extrude surface. 0 is flat surface, 90 is when two faces // are perpendicular - featureAngle 60; + featureAngle 100; + + // At non-patched sides allow mesh to slip if extrusion direction makes + // angle larger than slipFeatureAngle. Default is 0.5*featureAngle. + slipFeatureAngle 30; // Maximum number of snapping relaxation iterations. Should stop // before upon reaching a correct mesh. diff --git a/tutorials/incompressibleFluid/motorBikeSteady/system/snappyHexMeshDict b/tutorials/incompressibleFluid/motorBikeSteady/system/snappyHexMeshDict index bb91516ad2..2ca067fd12 100644 --- a/tutorials/incompressibleFluid/motorBikeSteady/system/snappyHexMeshDict +++ b/tutorials/incompressibleFluid/motorBikeSteady/system/snappyHexMeshDict @@ -247,10 +247,10 @@ addLayersControls // When not to extrude surface. 0 is flat surface, 90 is when two faces // are perpendicular - featureAngle 60; + featureAngle 100; // At non-patched sides allow mesh to slip if extrusion direction makes - // angle larger than slipFeatureAngle. + // angle larger than slipFeatureAngle. Default is 0.5*featureAngle. slipFeatureAngle 30; // Maximum number of snapping relaxation iterations. Should stop diff --git a/tutorials/incompressibleFluid/propeller/system/snappyHexMeshDict b/tutorials/incompressibleFluid/propeller/system/snappyHexMeshDict index bad6b9f6c0..a8bd9951af 100644 --- a/tutorials/incompressibleFluid/propeller/system/snappyHexMeshDict +++ b/tutorials/incompressibleFluid/propeller/system/snappyHexMeshDict @@ -333,7 +333,11 @@ addLayersControls // When not to extrude surface. 0 is flat surface, 90 is when two faces // are perpendicular - featureAngle 30; + featureAngle 60; + + // At non-patched sides allow mesh to slip if extrusion direction makes + // angle larger than slipFeatureAngle. Default is 0.5*featureAngle. + slipFeatureAngle 15; // Maximum number of snapping relaxation iterations. Should stop // before upon reaching a correct mesh. diff --git a/tutorials/incompressibleFluid/turbineSiting/system/snappyHexMeshDict b/tutorials/incompressibleFluid/turbineSiting/system/snappyHexMeshDict index 5f75b4f18c..d51591bfc2 100644 --- a/tutorials/incompressibleFluid/turbineSiting/system/snappyHexMeshDict +++ b/tutorials/incompressibleFluid/turbineSiting/system/snappyHexMeshDict @@ -265,7 +265,11 @@ addLayersControls // When not to extrude surface. 0 is flat surface, 90 is when two faces // are perpendicular - featureAngle 60; + featureAngle 100; + + // At non-patched sides allow mesh to slip if extrusion direction makes + // angle larger than slipFeatureAngle. Default is 0.5*featureAngle. + slipFeatureAngle 30; // Maximum number of snapping relaxation iterations. Should stop // before upon reaching a correct mesh. diff --git a/tutorials/incompressibleFluid/wingMotion/wingMotion_snappyHexMesh/system/snappyHexMeshDict b/tutorials/incompressibleFluid/wingMotion/wingMotion_snappyHexMesh/system/snappyHexMeshDict index 8f0f40e260..d75659f661 100644 --- a/tutorials/incompressibleFluid/wingMotion/wingMotion_snappyHexMesh/system/snappyHexMeshDict +++ b/tutorials/incompressibleFluid/wingMotion/wingMotion_snappyHexMesh/system/snappyHexMeshDict @@ -211,7 +211,11 @@ addLayersControls // When not to extrude surface. 0 is flat surface, 90 is when two faces // are perpendicular - featureAngle 60; + featureAngle 100; + + // At non-patched sides allow mesh to slip if extrusion direction makes + // angle larger than slipFeatureAngle. Default is 0.5*featureAngle. + slipFeatureAngle 30; // Maximum number of snapping relaxation iterations. Should stop // before upon reaching a correct mesh. diff --git a/tutorials/incompressibleVoF/DTCHull/system/snappyHexMeshDict b/tutorials/incompressibleVoF/DTCHull/system/snappyHexMeshDict index 7a285738fd..c70ef3137c 100644 --- a/tutorials/incompressibleVoF/DTCHull/system/snappyHexMeshDict +++ b/tutorials/incompressibleVoF/DTCHull/system/snappyHexMeshDict @@ -197,7 +197,11 @@ addLayersControls // When not to extrude surface. 0 is flat surface, 90 is when two faces // are perpendicular - featureAngle 60; + featureAngle 100; + + // At non-patched sides allow mesh to slip if extrusion direction makes + // angle larger than slipFeatureAngle. Default is 0.5*featureAngle. + slipFeatureAngle 30; // Maximum number of snapping relaxation iterations. Should stop // before upon reaching a correct mesh. diff --git a/tutorials/incompressibleVoF/DTCHullMoving/system/snappyHexMeshDict b/tutorials/incompressibleVoF/DTCHullMoving/system/snappyHexMeshDict index 7a285738fd..c70ef3137c 100644 --- a/tutorials/incompressibleVoF/DTCHullMoving/system/snappyHexMeshDict +++ b/tutorials/incompressibleVoF/DTCHullMoving/system/snappyHexMeshDict @@ -197,7 +197,11 @@ addLayersControls // When not to extrude surface. 0 is flat surface, 90 is when two faces // are perpendicular - featureAngle 60; + featureAngle 100; + + // At non-patched sides allow mesh to slip if extrusion direction makes + // angle larger than slipFeatureAngle. Default is 0.5*featureAngle. + slipFeatureAngle 30; // Maximum number of snapping relaxation iterations. Should stop // before upon reaching a correct mesh. diff --git a/tutorials/incompressibleVoF/DTCHullWave/system/snappyHexMeshDict b/tutorials/incompressibleVoF/DTCHullWave/system/snappyHexMeshDict index 7a285738fd..c70ef3137c 100644 --- a/tutorials/incompressibleVoF/DTCHullWave/system/snappyHexMeshDict +++ b/tutorials/incompressibleVoF/DTCHullWave/system/snappyHexMeshDict @@ -197,7 +197,11 @@ addLayersControls // When not to extrude surface. 0 is flat surface, 90 is when two faces // are perpendicular - featureAngle 60; + featureAngle 100; + + // At non-patched sides allow mesh to slip if extrusion direction makes + // angle larger than slipFeatureAngle. Default is 0.5*featureAngle. + slipFeatureAngle 30; // Maximum number of snapping relaxation iterations. Should stop // before upon reaching a correct mesh. diff --git a/tutorials/incompressibleVoF/cavitatingBullet/system/snappyHexMeshDict b/tutorials/incompressibleVoF/cavitatingBullet/system/snappyHexMeshDict index 58d7a1b749..2b1df65713 100644 --- a/tutorials/incompressibleVoF/cavitatingBullet/system/snappyHexMeshDict +++ b/tutorials/incompressibleVoF/cavitatingBullet/system/snappyHexMeshDict @@ -231,7 +231,11 @@ addLayersControls // When not to extrude surface. 0 is flat surface, 90 is when two faces // are perpendicular - featureAngle 30; + featureAngle 60; + + // At non-patched sides allow mesh to slip if extrusion direction makes + // angle larger than slipFeatureAngle. Default is 0.5*featureAngle. + slipFeatureAngle 15; // Maximum number of snapping relaxation iterations. Should stop // before upon reaching a correct mesh. diff --git a/tutorials/incompressibleVoF/planingHullW3/system/snappyHexMeshDict.1 b/tutorials/incompressibleVoF/planingHullW3/system/snappyHexMeshDict.1 index 66dc76a90f..5aa07ca812 100644 --- a/tutorials/incompressibleVoF/planingHullW3/system/snappyHexMeshDict.1 +++ b/tutorials/incompressibleVoF/planingHullW3/system/snappyHexMeshDict.1 @@ -196,7 +196,11 @@ addLayersControls // When not to extrude surface. 0 is flat surface, 90 is when two faces // are perpendicular - featureAngle 60; + featureAngle 100; + + // At non-patched sides allow mesh to slip if extrusion direction makes + // angle larger than slipFeatureAngle. Default is 0.5*featureAngle. + slipFeatureAngle 30; // Maximum number of snapping relaxation iterations. Should stop // before upon reaching a correct mesh. diff --git a/tutorials/incompressibleVoF/planingHullW3/system/snappyHexMeshDict.2 b/tutorials/incompressibleVoF/planingHullW3/system/snappyHexMeshDict.2 index 331e95bf8c..08b5a65c8f 100644 --- a/tutorials/incompressibleVoF/planingHullW3/system/snappyHexMeshDict.2 +++ b/tutorials/incompressibleVoF/planingHullW3/system/snappyHexMeshDict.2 @@ -231,7 +231,11 @@ addLayersControls // When not to extrude surface. 0 is flat surface, 90 is when two faces // are perpendicular - featureAngle 60; + featureAngle 100; + + // At non-patched sides allow mesh to slip if extrusion direction makes + // angle larger than slipFeatureAngle. Default is 0.5*featureAngle. + slipFeatureAngle 30; // Maximum number of snapping relaxation iterations. Should stop // before upon reaching a correct mesh. diff --git a/tutorials/incompressibleVoF/propeller/system/snappyHexMeshDict b/tutorials/incompressibleVoF/propeller/system/snappyHexMeshDict index bad6b9f6c0..a8bd9951af 100644 --- a/tutorials/incompressibleVoF/propeller/system/snappyHexMeshDict +++ b/tutorials/incompressibleVoF/propeller/system/snappyHexMeshDict @@ -333,7 +333,11 @@ addLayersControls // When not to extrude surface. 0 is flat surface, 90 is when two faces // are perpendicular - featureAngle 30; + featureAngle 60; + + // At non-patched sides allow mesh to slip if extrusion direction makes + // angle larger than slipFeatureAngle. Default is 0.5*featureAngle. + slipFeatureAngle 15; // Maximum number of snapping relaxation iterations. Should stop // before upon reaching a correct mesh. diff --git a/tutorials/mesh/snappyHexMesh/flange/system/snappyHexMeshDict b/tutorials/mesh/snappyHexMesh/flange/system/snappyHexMeshDict index fa519ef954..44a804aeb5 100644 --- a/tutorials/mesh/snappyHexMesh/flange/system/snappyHexMeshDict +++ b/tutorials/mesh/snappyHexMesh/flange/system/snappyHexMeshDict @@ -234,7 +234,11 @@ addLayersControls // When not to extrude surface. 0 is flat surface, 90 is when two faces // are perpendicular - featureAngle 30; + featureAngle 60; + + // At non-patched sides allow mesh to slip if extrusion direction makes + // angle larger than slipFeatureAngle. Default is 0.5*featureAngle. + slipFeatureAngle 15; // Maximum number of snapping relaxation iterations. Should stop // before upon reaching a correct mesh.