From f2397e7f41088f8d11d04f9faf469dc20685d2b2 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Tue, 2 Jul 2013 15:01:32 +0100
Subject: [PATCH] ENH: snappyHexMesh: clean up mesh quality settings

---
 .../generation/snappyHexMesh/meshQualityDict  | 21 +++++
 .../snappyHexMesh/snappyHexMeshDict           | 72 +++--------------
 etc/caseDicts/meshQualityDict                 | 79 +++++++++++++++++++
 .../iglooWithFridges/system/meshQualityDict   | 47 +----------
 .../system/meshQualityDict                    | 21 +++++
 .../system/snappyHexMeshDict                  | 46 +----------
 .../motorBike/system/meshQualityDict          | 48 +----------
 .../flange/system/meshQualityDict             | 22 ++++++
 .../flange/system/snappyHexMeshDict           | 69 ++--------------
 9 files changed, 168 insertions(+), 257 deletions(-)
 create mode 100644 applications/utilities/mesh/generation/snappyHexMesh/meshQualityDict
 create mode 100644 etc/caseDicts/meshQualityDict
 create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/meshQualityDict
 create mode 100644 tutorials/mesh/snappyHexMesh/flange/system/meshQualityDict

diff --git a/applications/utilities/mesh/generation/snappyHexMesh/meshQualityDict b/applications/utilities/mesh/generation/snappyHexMesh/meshQualityDict
new file mode 100644
index 00000000000..fd0701a01c7
--- /dev/null
+++ b/applications/utilities/mesh/generation/snappyHexMesh/meshQualityDict
@@ -0,0 +1,21 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  dev                                   |
+|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    object      meshQualityDict;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+// Include defaults parameters from master dictionary
+#include "$WM_PROJECT_DIR/etc/caseDicts/meshQualityDict"
+
+
+// ************************************************************************* //
diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict
index ba16b1c4aad..4d480b9efcb 100644
--- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict
+++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict
@@ -432,74 +432,26 @@ addLayersControls
 // 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 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-9;
-
-    // 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.05;
-
-    // minimum normalised cell determinant
-    // 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;
-
-    // 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;
+    // Specify mesh quality constraints in separate dictionary so can
+    // be reused (e.g. checkMesh -meshQuality)
+    #include "meshQualityDict"
 
-    // Advanced
-
-    // Number of error distribution iterations
-    nSmoothScale 4;
-    // amount to scale back displacement at error points
-    errorReduction 0.75;
 
     // Optional : some meshing phases allow usage of relaxed rules.
     // See e.g. addLayersControls::nRelaxedIter.
     relaxed
     {
-        //- Maximum non-orthogonality allowed. Set to 180 to disable.
+        // Maximum non-orthogonality allowed. Set to 180 to disable.
         maxNonOrtho 75;
     }
+
+
+    // Advanced
+
+        // Number of error distribution iterations
+        nSmoothScale 4;
+        // amount to scale back displacement at error points
+        errorReduction 0.75;
 }
 
 // Advanced
diff --git a/etc/caseDicts/meshQualityDict b/etc/caseDicts/meshQualityDict
new file mode 100644
index 00000000000..bcb4415797a
--- /dev/null
+++ b/etc/caseDicts/meshQualityDict
@@ -0,0 +1,79 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  dev                                   |
+|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    object      meshQualityDict;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+//- 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;
+
+
+// ************************************************************************* //
diff --git a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/system/meshQualityDict b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/system/meshQualityDict
index 1b5837a15e0..fd0701a01c7 100644
--- a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/system/meshQualityDict
+++ b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/system/meshQualityDict
@@ -14,51 +14,8 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-//- 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.  Set to very negative number (e.g. -1E30) to
-//  disable.
-//     <0 = inside out tet,
-//      0 = flat tet
-//      1 = regular tet
-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.05;
-
-//- minimum normalised cell determinant
-//- 1 = hex, <= 0 = folded or flattened illegal cell
-minDeterminant 0.001;
-
-//- minFaceWeight (0 -> 0.5)
-minFaceWeight 0.05;
-
-//- minVolRatio (0 -> 1)
-minVolRatio 0.01;
-
-//must be >0 for Fluent compatibility
-minTriangleTwist -1;
+// Include defaults parameters from master dictionary
+#include "$WM_PROJECT_DIR/etc/caseDicts/meshQualityDict"
 
 
 // ************************************************************************* //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/meshQualityDict b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/meshQualityDict
new file mode 100644
index 00000000000..fd0701a01c7
--- /dev/null
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/meshQualityDict
@@ -0,0 +1,21 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  dev                                   |
+|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    object      meshQualityDict;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+// Include defaults parameters from master dictionary
+#include "$WM_PROJECT_DIR/etc/caseDicts/meshQualityDict"
+
+
+// ************************************************************************* //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/snappyHexMeshDict b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/snappyHexMeshDict
index 072870efc37..8a0767ebafd 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/snappyHexMeshDict
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/snappyHexMeshDict
@@ -346,51 +346,7 @@ addLayersControls
 // 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 pyramid volume. Is absolute volume of cell pyramid.
-    //  Set to very negative number (e.g. -1E30) to disable.
-    minVol 0;
-
-    //- Minimum quality of the tet formed by the face-centre
-    //  and variable base point minimum decomposition triangles and
-    //  the cell centre.  Set to very negative number (e.g. -1E30) to
-    //  disable.
-    //     <0 = inside out tet,
-    //      0 = flat tet
-    //      1 = regular tet
-    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.001;
-
-    //- minFaceWeight (0 -> 0.5)
-    minFaceWeight 0.02;
-
-    //- minVolRatio (0 -> 1)
-    minVolRatio 0.01;
-
-    //must be >0 for Fluent compatibility
-    minTriangleTwist -1;
-
+    #include "meshQualityDict"
 
     // Advanced
 
diff --git a/tutorials/incompressible/simpleFoam/motorBike/system/meshQualityDict b/tutorials/incompressible/simpleFoam/motorBike/system/meshQualityDict
index e1a0539abae..fd0701a01c7 100644
--- a/tutorials/incompressible/simpleFoam/motorBike/system/meshQualityDict
+++ b/tutorials/incompressible/simpleFoam/motorBike/system/meshQualityDict
@@ -14,52 +14,8 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-//- 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-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.001;
-
-//- minFaceWeight (0 -> 0.5)
-minFaceWeight 0.02;
-
-//- minVolRatio (0 -> 1)
-minVolRatio 0.01;
-
-//must be >0 for Fluent compatibility
-minTriangleTwist -1;
+// Include defaults parameters from master dictionary
+#include "$WM_PROJECT_DIR/etc/caseDicts/meshQualityDict"
 
 
 // ************************************************************************* //
diff --git a/tutorials/mesh/snappyHexMesh/flange/system/meshQualityDict b/tutorials/mesh/snappyHexMesh/flange/system/meshQualityDict
new file mode 100644
index 00000000000..8351b3f3746
--- /dev/null
+++ b/tutorials/mesh/snappyHexMesh/flange/system/meshQualityDict
@@ -0,0 +1,22 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  dev                                   |
+|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    object      meshQualityDict;
+}
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+// Include defaults parameters from master dictionary
+#include "$WM_PROJECT_DIR/etc/caseDicts/meshQualityDict"
+
+
+// ************************************************************************* //
diff --git a/tutorials/mesh/snappyHexMesh/flange/system/snappyHexMeshDict b/tutorials/mesh/snappyHexMesh/flange/system/snappyHexMeshDict
index 0e686729062..e290f4ff9c5 100644
--- a/tutorials/mesh/snappyHexMesh/flange/system/snappyHexMeshDict
+++ b/tutorials/mesh/snappyHexMesh/flange/system/snappyHexMeshDict
@@ -280,67 +280,7 @@ addLayersControls
 // 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 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.  Set to very negative number (e.g. -1E30) to
-    //  disable.
-    //     <0 = inside out tet,
-    //      0 = flat tet
-    //      1 = regular tet
-    minTetQuality 1e-9;
-
-    //- 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.05;
-
-    //- minimum normalised cell determinant
-    //- 1 = hex, <= 0 = folded or flattened illegal cell
-    minDeterminant 0.001;
-
-    //- minFaceWeight (0 -> 0.5)
-    minFaceWeight 0.05;
-
-    //- minVolRatio (0 -> 1)
-    minVolRatio 0.01;
-
-    //must be >0 for Fluent compatibility
-    minTriangleTwist -1;
-
-    //- if >0 : preserve single 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.5;
-
-
-    // Advanced
-
-    //- Number of error distribution iterations
-    nSmoothScale 4;
-    //- amount to scale back displacement at error points
-    errorReduction 0.75;
-
-
+    #include "meshQualityDict"
 
     // Optional : some meshing phases allow usage of relaxed rules.
     // See e.g. addLayersControls::nRelaxedIter.
@@ -349,6 +289,13 @@ meshQualityControls
         //- Maximum non-orthogonality allowed. Set to 180 to disable.
         maxNonOrtho 75;
     }
+
+    // Advanced
+
+    //- Number of error distribution iterations
+    nSmoothScale 4;
+    //- amount to scale back displacement at error points
+    errorReduction 0.75;
 }
 
 
-- 
GitLab