From 63b95cec3630544d19fabf6ba7a9e54ff50c2cbc Mon Sep 17 00:00:00 2001
From: sergio <s.ferraris@opencfd.co.uk>
Date: Wed, 23 Mar 2011 15:57:04 +0000
Subject: [PATCH] ENH: Adition of shear to points to avoid Delaunry2D
 degeneration

---
 .../timeVaryingMappedFixedValueFvPatchField.C | 38 ++++++++++++++++---
 1 file changed, 32 insertions(+), 6 deletions(-)

diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C
index 6d3db6936f1..67b3513c312 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C
@@ -332,7 +332,19 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::readSamplePoints()
     (
         referenceCS().localPosition(samplePoints)
     );
-    const vectorField& localVertices = tlocalVertices();
+    vectorField& localVertices = tlocalVertices();
+
+    // Shear to avoid degenerate cases
+    forAll(localVertices, i)
+    {
+        point& pt = localVertices[i];
+        const scalar magPt = mag(pt);
+        const point nptDir = pt/magPt;
+        if (magPt > ROOTVSMALL)
+        {
+            pt += pow(magPt, 1.1 + Foam::sqrt(SMALL))*nptDir;
+        }
+    }
 
     // Determine triangulation
     List<vector2D> localVertices2D(localVertices.size());
@@ -342,7 +354,7 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::readSamplePoints()
         localVertices2D[i][1] = localVertices[i][1];
     }
 
-    tmp<pointField> localFaceCentres
+    tmp<pointField> tlocalFaceCentres
     (
         referenceCS().localPosition
         (
@@ -350,6 +362,20 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::readSamplePoints()
         )
     );
 
+    pointField& localFaceCentres = tlocalFaceCentres();
+
+    // Shear to avoid degenerate cases
+    forAll(localFaceCentres, i)
+    {
+        point& pt = localFaceCentres[i];
+        const scalar magPt = mag(pt);
+        const point nptDir = pt/magPt;
+        if (magPt > ROOTVSMALL)
+        {
+            pt += pow(magPt, 1.1 + Foam::sqrt(SMALL))*nptDir;
+        }
+    }
+
     if (debug)
     {
         OFstream str
@@ -360,9 +386,9 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::readSamplePoints()
         Pout<< "readSamplePoints :"
             << " Dumping face centres to " << str.name() << endl;
 
-        forAll(localFaceCentres(), i)
+        forAll(localFaceCentres, i)
         {
-            const point& p = localFaceCentres()[i];
+            const point& p = localFaceCentres[i];
             str<< "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl;
         }
     }
@@ -380,9 +406,9 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::readSamplePoints()
         Pout<< "readSamplePoints :"
             << " Dumping face centres to " << str.name() << endl;
 
-        forAll(localFaceCentres(), i)
+        forAll(localFaceCentres, i)
         {
-            const point& p = localFaceCentres()[i];
+            const point& p = localFaceCentres[i];
             str<< "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl;
         }
     }
-- 
GitLab