From 709fc12c9050201146b5a1a377c96c2b274672a6 Mon Sep 17 00:00:00 2001
From: andy <andy>
Date: Tue, 17 May 2011 15:33:57 +0100
Subject: [PATCH] ENH: Robustness updates to pointMVC interpolation

---
 src/finiteVolume/Make/files                   |  4 +-
 src/finiteVolume/Make/options                 |  1 +
 .../interpolationPointMVC.C}                  |  6 +--
 .../interpolationPointMVC.H}                  | 21 +++++-----
 .../interpolationPointMVCI.H}                 |  6 +--
 .../makeInterpolationPointMVC.C}              |  6 +--
 .../pointMVCWeight.C                          | 41 +++++++++----------
 .../pointMVCWeight.H                          |  2 +-
 .../pointMVCWeightI.H                         |  2 +-
 9 files changed, 45 insertions(+), 44 deletions(-)
 rename src/finiteVolume/interpolation/interpolation/{interpolationPoint/interpolationPoint.C => interpolationPointMVC/interpolationPointMVC.C} (90%)
 rename src/finiteVolume/interpolation/interpolation/{interpolationPoint/interpolationPoint.H => interpolationPointMVC/interpolationPointMVC.H} (88%)
 rename src/finiteVolume/interpolation/interpolation/{interpolationPoint/interpolationPointI.H => interpolationPointMVC/interpolationPointMVCI.H} (89%)
 rename src/finiteVolume/interpolation/interpolation/{interpolationPoint/makeInterpolationPoint.C => interpolationPointMVC/makeInterpolationPointMVC.C} (89%)
 rename src/finiteVolume/interpolation/interpolation/{interpolationPoint => interpolationPointMVC}/pointMVCWeight.C (88%)
 rename src/finiteVolume/interpolation/interpolation/{interpolationPoint => interpolationPointMVC}/pointMVCWeight.H (98%)
 rename src/finiteVolume/interpolation/interpolation/{interpolationPoint => interpolationPointMVC}/pointMVCWeightI.H (96%)

diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files
index 854c89211b4..817381be619 100644
--- a/src/finiteVolume/Make/files
+++ b/src/finiteVolume/Make/files
@@ -204,8 +204,8 @@ $(interpolation)/interpolationCellPoint/makeInterpolationCellPoint.C
 $(interpolation)/interpolationCellPointFace/makeInterpolationCellPointFace.C
 $(interpolation)/interpolationCellPointWallModified/cellPointWeightWallModified/cellPointWeightWallModified.C
 $(interpolation)/interpolationCellPointWallModified/makeInterpolationCellPointWallModified.C
-$(interpolation)/interpolationPoint/pointMVCWeight.C
-$(interpolation)/interpolationPoint/makeInterpolationPoint.C
+$(interpolation)/interpolationPointMVC/pointMVCWeight.C
+$(interpolation)/interpolationPointMVC/makeInterpolationPointMVC.C
 
 volPointInterpolation = interpolation/volPointInterpolation
 $(volPointInterpolation)/volPointInterpolation.C
diff --git a/src/finiteVolume/Make/options b/src/finiteVolume/Make/options
index b91061399ee..d1cbdbad04c 100644
--- a/src/finiteVolume/Make/options
+++ b/src/finiteVolume/Make/options
@@ -1,4 +1,5 @@
 EXE_INC = \
+    -DFULLDEBUG -g -O0 \
     -I$(LIB_SRC)/triSurface/lnInclude \
     -I$(LIB_SRC)/meshTools/lnInclude
 
diff --git a/src/finiteVolume/interpolation/interpolation/interpolationPoint/interpolationPoint.C b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVC.C
similarity index 90%
rename from src/finiteVolume/interpolation/interpolation/interpolationPoint/interpolationPoint.C
rename to src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVC.C
index 516bb142db5..592b9bf47fd 100644
--- a/src/finiteVolume/interpolation/interpolation/interpolationPoint/interpolationPoint.C
+++ b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVC.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2010-2011 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -23,13 +23,13 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#include "interpolationPoint.H"
+#include "interpolationPointMVC.H"
 #include "volPointInterpolation.H"
 
 // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
 
 template<class Type>
-Foam::interpolationPoint<Type>::interpolationPoint
+Foam::interpolationPointMVC<Type>::interpolationPointMVC
 (
     const GeometricField<Type, fvPatchField, volMesh>& psi
 )
diff --git a/src/finiteVolume/interpolation/interpolation/interpolationPoint/interpolationPoint.H b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVC.H
similarity index 88%
rename from src/finiteVolume/interpolation/interpolation/interpolationPoint/interpolationPoint.H
rename to src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVC.H
index 013ca766169..8b7ba07fae1 100644
--- a/src/finiteVolume/interpolation/interpolation/interpolationPoint/interpolationPoint.H
+++ b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVC.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2010-2011 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -22,7 +22,7 @@ License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
 Class
-    Foam::interpolationPoint
+    Foam::interpolationPointMVC
 
 Description
     Given cell centre values interpolates to vertices and uses these to
@@ -30,8 +30,8 @@ Description
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef interpolationPoint_H
-#define interpolationPoint_H
+#ifndef interpolationPointMVC_H
+#define interpolationPointMVC_H
 
 #include "interpolation.H"
 #include "pointMVCWeight.H"
@@ -42,11 +42,11 @@ namespace Foam
 {
 
 /*---------------------------------------------------------------------------*\
-                   Class interpolationPoint Declaration
+                   Class interpolationPointMVC Declaration
 \*---------------------------------------------------------------------------*/
 
 template<class Type>
-class interpolationPoint
+class interpolationPointMVC
 :
     public interpolation<Type>
 {
@@ -57,16 +57,17 @@ protected:
         //- Interpolated volfield
         const GeometricField<Type, pointPatchField, pointMesh> psip_;
 
+
 public:
 
     //- Runtime type information
-    TypeName("point");
+    TypeName("pointMVC");
 
 
     // Constructors
 
         //- Construct from components
-        interpolationPoint
+        interpolationPointMVC
         (
             const GeometricField<Type, fvPatchField, volMesh>& psi
         );
@@ -93,12 +94,12 @@ public:
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-#include "interpolationPointI.H"
+#include "interpolationPointMVCI.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 #ifdef NoRepository
-#   include "interpolationPoint.C"
+#   include "interpolationPointMVC.C"
 #endif
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/finiteVolume/interpolation/interpolation/interpolationPoint/interpolationPointI.H b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVCI.H
similarity index 89%
rename from src/finiteVolume/interpolation/interpolation/interpolationPoint/interpolationPointI.H
rename to src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVCI.H
index a3f47c3a0ae..7d2a79f86fd 100644
--- a/src/finiteVolume/interpolation/interpolation/interpolationPoint/interpolationPointI.H
+++ b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVCI.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2010-2011 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -26,7 +26,7 @@ License
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class Type>
-inline Type Foam::interpolationPoint<Type>::interpolate
+inline Type Foam::interpolationPointMVC<Type>::interpolate
 (
     const pointMVCWeight& cpw
 ) const
@@ -36,7 +36,7 @@ inline Type Foam::interpolationPoint<Type>::interpolate
 
 
 template<class Type>
-inline Type Foam::interpolationPoint<Type>::interpolate
+inline Type Foam::interpolationPointMVC<Type>::interpolate
 (
     const vector& position,
     const label cellI,
diff --git a/src/finiteVolume/interpolation/interpolation/interpolationPoint/makeInterpolationPoint.C b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/makeInterpolationPointMVC.C
similarity index 89%
rename from src/finiteVolume/interpolation/interpolation/interpolationPoint/makeInterpolationPoint.C
rename to src/finiteVolume/interpolation/interpolation/interpolationPointMVC/makeInterpolationPointMVC.C
index b27f807019f..a5882e17e72 100644
--- a/src/finiteVolume/interpolation/interpolation/interpolationPoint/makeInterpolationPoint.C
+++ b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/makeInterpolationPointMVC.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2010-2011 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -23,13 +23,13 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#include "interpolationPoint.H"
+#include "interpolationPointMVC.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
 {
-    makeInterpolation(interpolationPoint);
+    makeInterpolation(interpolationPointMVC);
 }
 
 // ************************************************************************* //
diff --git a/src/finiteVolume/interpolation/interpolation/interpolationPoint/pointMVCWeight.C b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.C
similarity index 88%
rename from src/finiteVolume/interpolation/interpolation/interpolationPoint/pointMVCWeight.C
rename to src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.C
index f011d5e6fb2..3ff902c3970 100644
--- a/src/finiteVolume/interpolation/interpolation/interpolationPoint/pointMVCWeight.C
+++ b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2010-2011 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -56,7 +56,7 @@ void Foam::pointMVCWeight::calcWeights
     forAll(f, j)
     {
         label jPlus1 = f.fcIndex(j);
-        scalar l = mag(u[j]-u[jPlus1]);
+        scalar l = mag(u[j] - u[jPlus1]);
         theta[j] = 2.0*Foam::asin(l/2.0);
     }
 
@@ -68,7 +68,7 @@ void Foam::pointMVCWeight::calcWeights
         weights[pid] =
             1.0
           / dist[pid]
-          * (Foam::tan(theta[jMin1]/2.0)+Foam::tan(theta[j]/2.0));
+          * (Foam::tan(theta[jMin1]/2.0) + Foam::tan(theta[j]/2.0));
         sumWeight += weights[pid];
     }
 
@@ -132,11 +132,10 @@ void Foam::pointMVCWeight::calcWeights
             //Pout<< "    uj:" << u[j] << " ujPlus1:" << u[jPlus1]
             //    << " temp:" << temp << endl;
 
-            scalar l = mag(u[j]-u[jPlus1]);
+            scalar l = min(mag(u[j] - u[jPlus1]), 2.0);
             scalar angle = 2.0*Foam::asin(l/2.0);
 
-            //Pout<< "    j:" << j << " l:" << l
-            //    << " angle:" << angle << endl;
+            //Pout<< "    j:" << j << " l:" << l << " angle:" << angle << endl;
 
             v += 0.5*angle*temp;
         }
@@ -145,14 +144,14 @@ void Foam::pointMVCWeight::calcWeights
         v /= vNorm;
 
         // Make sure v points towards the polygon
-//if (((v&u[0]) < 0) != (mesh.faceOwner()[faceI] != cellIndex_))
-//{
-//    FatalErrorIn("pointMVCWeight::calcWeights(..)")
-//        << "v:" << v << " u[0]:" << u[0]
-//        << exit(FatalError);
-//}
-
-        if ((v&u[0]) < 0)
+        //if (((v&u[0]) < 0) != (mesh.faceOwner()[faceI] != cellIndex_))
+        //{
+        //    FatalErrorIn("pointMVCWeight::calcWeights(..)")
+        //        << "v:" << v << " u[0]:" << u[0]
+        //        << exit(FatalError);
+        //}
+
+        if ((v & u[0]) < 0)
         {
             v = -v;
         }
@@ -165,22 +164,22 @@ void Foam::pointMVCWeight::calcWeights
             label jPlus1 = f.fcIndex(j);
             //Pout<< "    uj:" << u[j] << " ujPlus1:" << u[jPlus1] << endl;
 
-            vector n0 = u[j] ^ v;
+            vector n0 = u[j]^v;
             n0 /= mag(n0);
-            vector n1 = u[jPlus1] ^ v;
+            vector n1 = u[jPlus1]^v;
             n1 /= mag(n1);
 
-            scalar l = mag(n0-n1);
+            scalar l = min(mag(n0 - n1), 2.0);
             //Pout<< "    l:" << l << endl;
             alpha(j) = 2.0*Foam::asin(l/2.0);
 
-            vector temp = n0 ^ n1;
+            vector temp = n0^n1;
             if ((temp&v) < 0.0)
             {
                 alpha[j] = -alpha[j];
             }
 
-            l = mag(u[j]-v);
+            l = min(mag(u[j] - v), 2.0);
             //Pout<< "    l:" << l << endl;
             theta(j) = 2.0*Foam::asin(l/2.0);
         }
@@ -211,7 +210,7 @@ void Foam::pointMVCWeight::calcWeights
             sum +=
                 1.0
               / Foam::tan(theta[j])
-              * (Foam::tan(alpha[j]/2.0)+Foam::tan(alpha[jMin1]/2.0));
+              * (Foam::tan(alpha[j]/2.0) + Foam::tan(alpha[jMin1]/2.0));
         }
 
         // The special case when x lies on the polygon, handle it using 2D mvc.
@@ -234,7 +233,7 @@ void Foam::pointMVCWeight::calcWeights
               / sum
               / dist[pid]
               / Foam::sin(theta[j])
-              * (Foam::tan(alpha[j]/2.0)+Foam::tan(alpha[jMin1]/2.0));
+              * (Foam::tan(alpha[j]/2.0) + Foam::tan(alpha[jMin1]/2.0));
         }
     }
 
diff --git a/src/finiteVolume/interpolation/interpolation/interpolationPoint/pointMVCWeight.H b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.H
similarity index 98%
rename from src/finiteVolume/interpolation/interpolation/interpolationPoint/pointMVCWeight.H
rename to src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.H
index 285114de4b4..cc16c1dfbb1 100644
--- a/src/finiteVolume/interpolation/interpolation/interpolationPoint/pointMVCWeight.H
+++ b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2010-2011 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
diff --git a/src/finiteVolume/interpolation/interpolation/interpolationPoint/pointMVCWeightI.H b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeightI.H
similarity index 96%
rename from src/finiteVolume/interpolation/interpolation/interpolationPoint/pointMVCWeightI.H
rename to src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeightI.H
index b2f1fc55458..329b6fb3418 100644
--- a/src/finiteVolume/interpolation/interpolation/interpolationPoint/pointMVCWeightI.H
+++ b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeightI.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2010-2011 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
-- 
GitLab