From 438f38bb616fec154c9e3e4c8fb31cdba874368a Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Wed, 6 May 2020 18:57:13 +0100
Subject: [PATCH] ENH: surfaceInterpolation: extended patch override of
 geometry calculation.

---
 .../fvMesh/fvPatches/fvPatch/fvPatch.C           | 12 ++++++++++++
 .../fvMesh/fvPatches/fvPatch/fvPatch.H           |  9 +++++++++
 .../surfaceInterpolation/surfaceInterpolation.C  | 16 +++++++++++++---
 3 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.C b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.C
index 2b0b8ee5cba..b100323976d 100644
--- a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.C
+++ b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.C
@@ -167,6 +167,18 @@ void Foam::fvPatch::makeWeights(scalarField& w) const
 }
 
 
+void Foam::fvPatch::makeDeltaCoeffs(scalarField& w) const
+{}
+
+
+void Foam::fvPatch::makeNonOrthoDeltaCoeffs(scalarField& w) const
+{}
+
+
+void Foam::fvPatch::makeNonOrthoCorrVectors(vectorField& w) const
+{}
+
+
 void Foam::fvPatch::initMovePoints()
 {}
 
diff --git a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H
index 7f1e99775f9..3a04adfb38f 100644
--- a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H
+++ b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H
@@ -81,6 +81,15 @@ protected:
         //- Make patch weighting factors
         virtual void makeWeights(scalarField&) const;
 
+        //- Correct patch deltaCoeffs
+        virtual void makeDeltaCoeffs(scalarField&) const;
+
+        //- Correct patch non-ortho deltaCoeffs
+        virtual void makeNonOrthoDeltaCoeffs(scalarField&) const;
+
+        //- Correct patch non-ortho correction vectors
+        virtual void makeNonOrthoCorrVectors(vectorField&) const;
+
         //- Initialise the patches for moving points
         virtual void initMovePoints();
 
diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolation.C b/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolation.C
index c716e1456a0..76429339718 100644
--- a/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolation.C
+++ b/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolation.C
@@ -246,7 +246,11 @@ void Foam::surfaceInterpolation::makeDeltaCoeffs() const
 
     forAll(deltaCoeffsBf, patchi)
     {
-        deltaCoeffsBf[patchi] = 1.0/mag(mesh_.boundary()[patchi].delta());
+        const fvPatch& p = mesh_.boundary()[patchi];
+        deltaCoeffsBf[patchi] = 1.0/mag(p.delta());
+
+        // Optionally correct
+        p.makeDeltaCoeffs(deltaCoeffsBf[patchi]);
     }
 }
 
@@ -329,6 +333,9 @@ void Foam::surfaceInterpolation::makeNonOrthDeltaCoeffs() const
             patchDeltaCoeffs[patchFacei] =
                 1.0/max(unitArea & delta, 0.05*mag(delta));
         }
+
+        // Optionally correct
+        p.makeNonOrthoDeltaCoeffs(patchDeltaCoeffs);
     }
 }
 
@@ -385,6 +392,8 @@ void Foam::surfaceInterpolation::makeNonOrthCorrectionVectors() const
     {
         fvsPatchVectorField& patchCorrVecs = corrVecsBf[patchi];
 
+        const fvPatch& p = patchCorrVecs.patch();
+
         if (!patchCorrVecs.coupled())
         {
             patchCorrVecs = Zero;
@@ -394,8 +403,6 @@ void Foam::surfaceInterpolation::makeNonOrthCorrectionVectors() const
             const fvsPatchScalarField& patchNonOrthDeltaCoeffs =
                 NonOrthDeltaCoeffs.boundaryField()[patchi];
 
-            const fvPatch& p = patchCorrVecs.patch();
-
             const vectorField patchDeltas(mesh_.boundary()[patchi].delta());
 
             forAll(p, patchFacei)
@@ -410,6 +417,9 @@ void Foam::surfaceInterpolation::makeNonOrthCorrectionVectors() const
                     unitArea - delta*patchNonOrthDeltaCoeffs[patchFacei];
             }
         }
+
+        // Optionally correct
+        p.makeNonOrthoCorrVectors(patchCorrVecs);
     }
 
     if (debug)
-- 
GitLab