From 35395ea438d00aed567578d379b850b3f85d426c Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Mon, 14 Nov 2011 15:15:06 +0000
Subject: [PATCH] BUG: cyclicAMI: differentiate between coupled geometry and
 coupled fields

---
 .../derived/coupled/coupledFacePointPatch.H   | 12 ----------
 .../polyPatches/polyPatch/polyPatch.H         |  3 ++-
 .../cyclicAMI/cyclicAMIFvPatchField.C         | 23 ++++++++++++++++++-
 .../cyclicAMI/cyclicAMIFvPatchField.H         |  6 ++++-
 .../processor/processorFvPatchField.H         |  2 +-
 .../cyclicAMI/cyclicAMIFvsPatchField.C        | 23 +++++++++++++++++++
 .../cyclicAMI/cyclicAMIFvsPatchField.H        |  8 +++++++
 .../leastSquaresGrad/leastSquaresVectors.C    |  6 ++---
 .../cellToFace/extendedCellToFaceStencil.C    |  2 +-
 .../faceToCell/extendedFaceToCellStencil.C    |  2 +-
 .../schemes/clippedLinear/clippedLinear.H     |  2 +-
 .../schemes/reverseLinear/reverseLinear.H     |  2 +-
 .../FacePostProcessing/FacePostProcessing.C   |  2 +-
 .../cyclicAMIPointPatch/cyclicAMIPointPatch.H | 11 +++++++++
 .../cyclicAMIPolyPatch/cyclicAMIPolyPatch.C   | 17 --------------
 .../cyclicAMIPolyPatch/cyclicAMIPolyPatch.H   | 10 ++++----
 .../sampledSurface/isoSurface/isoSurface.C    |  2 +-
 17 files changed, 87 insertions(+), 46 deletions(-)

diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.H
index 368782d0a37..91db5fc8737 100644
--- a/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.H
+++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.H
@@ -96,18 +96,6 @@ public:
 
     //- Destructor
     virtual ~coupledFacePointPatch();
-
-
-    // Member Functions
-
-        // Access
-
-            //- Return true because this patch is coupled
-            virtual bool coupled() const
-            {
-                return true;
-            }
-
 };
 
 
diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H
index ceb62205852..5601c1e993c 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H
+++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H
@@ -285,7 +285,8 @@ public:
         //- Return boundaryMesh reference
         const polyBoundaryMesh& boundaryMesh() const;
 
-        //- Return true if this patch field is coupled
+        //- Return true if this patch is geometrically coupled (i.e. faces and
+        //  points correspondence)
         virtual bool coupled() const
         {
             return false;
diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C
index 8e358063fa4..31729346e24 100644
--- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C
@@ -106,7 +106,7 @@ Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
             << exit(FatalIOError);
     }
 
-    if (cyclicAMIPatch_.coupled())
+    if (this->coupled())
     {
         this->evaluate(Pstream::blocking);
     }
@@ -140,6 +140,27 @@ Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
+template<class Type>
+bool Foam::cyclicAMIFvPatchField<Type>::coupled() const
+{
+    if
+    (
+        Pstream::parRun()
+     || (
+            this->cyclicAMIPatch_.size()
+         && this->cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().size()
+        )
+    )
+    {
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+
 template<class Type>
 Foam::tmp<Foam::Field<Type> >
 Foam::cyclicAMIFvPatchField<Type>::patchNeighbourField() const
diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H
index 9a4e5f6b4c8..2e05111cb68 100644
--- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H
+++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H
@@ -147,8 +147,12 @@ public:
 
         // Evaluation functions
 
+            //- Return true if coupled. Note that the underlying patch
+            //  is not coupled() - the points don't align.
+            virtual bool coupled() const;
+
             //- Return neighbour coupled internal cell data
-            tmp<Field<Type> > patchNeighbourField() const;
+            virtual tmp<Field<Type> > patchNeighbourField() const;
 
             //- Return reference to neighbour patchField
             const cyclicAMIFvPatchField<Type>& neighbourPatchField() const;
diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H
index 7e3152e1312..0130909d04d 100644
--- a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H
+++ b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H
@@ -154,7 +154,7 @@ public:
             }
 
             //- Return neighbour field given internal field
-            tmp<Field<Type> > patchNeighbourField() const;
+            virtual tmp<Field<Type> > patchNeighbourField() const;
 
 
         // Evaluation functions
diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.C
index a347bc43475..0ffe6b9c95e 100644
--- a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.C
+++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.C
@@ -123,4 +123,27 @@ Foam::cyclicAMIFvsPatchField<Type>::cyclicAMIFvsPatchField
 {}
 
 
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+bool Foam::cyclicAMIFvsPatchField<Type>::coupled() const
+{
+    if
+    (
+        Pstream::parRun()
+     || (
+            this->cyclicAMIPatch_.size()
+         && this->cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().size()
+        )
+    )
+    {
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+
 // ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.H
index fe849831347..d55ff5cd5d1 100644
--- a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.H
+++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.H
@@ -123,6 +123,14 @@ public:
                 new cyclicAMIFvsPatchField<Type>(*this, iF)
             );
         }
+
+    // Member functions
+
+        // Access
+
+            //- Return true if running parallel
+            virtual bool coupled() const;
+
 };
 
 
diff --git a/src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresVectors.C b/src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresVectors.C
index 6002a07e1c1..27f5b72fcfd 100644
--- a/src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresVectors.C
+++ b/src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresVectors.C
@@ -132,7 +132,7 @@ void Foam::leastSquaresVectors::makeLeastSquaresVectors() const
         // Build the d-vectors
         vectorField pd = p.delta();
 
-        if (p.coupled())
+        if (pw.coupled())
         {
             forAll(pd, patchFacei)
             {
@@ -185,7 +185,7 @@ void Foam::leastSquaresVectors::makeLeastSquaresVectors() const
         // Build the d-vectors
         vectorField pd = p.delta();
 
-        if (p.coupled())
+        if (pw.coupled())
         {
             forAll(pd, patchFacei)
             {
@@ -256,7 +256,7 @@ void Foam::leastSquaresVectors::makeLeastSquaresVectors() const
                             label patchFacei =
                                 facei - mesh.boundaryMesh()[patchi].start();
 
-                            if (mesh.boundary()[patchi].coupled())
+                            if (w.boundaryField()[patchi].coupled())
                             {
                                 scalar wf = max
                                 (
diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCellToFaceStencil.C b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCellToFaceStencil.C
index 85c6f3f61f3..021241fa270 100644
--- a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCellToFaceStencil.C
+++ b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCellToFaceStencil.C
@@ -103,7 +103,7 @@ Foam::extendedCellToFaceStencil::extendedCellToFaceStencil(const polyMesh& mesh)
 
     forAll(patches, patchI)
     {
-        if (isA<coupledPolyPatch>(patches[patchI]))
+        if (patches[patchI].coupled())
         {
             const coupledPolyPatch& cpp =
                 refCast<const coupledPolyPatch>(patches[patchI]);
diff --git a/src/finiteVolume/fvMesh/extendedStencil/faceToCell/extendedFaceToCellStencil.C b/src/finiteVolume/fvMesh/extendedStencil/faceToCell/extendedFaceToCellStencil.C
index 0943d86685e..4f364dc2887 100644
--- a/src/finiteVolume/fvMesh/extendedStencil/faceToCell/extendedFaceToCellStencil.C
+++ b/src/finiteVolume/fvMesh/extendedStencil/faceToCell/extendedFaceToCellStencil.C
@@ -38,7 +38,7 @@ Foam::extendedFaceToCellStencil::extendedFaceToCellStencil(const polyMesh& mesh)
 
     forAll(patches, patchI)
     {
-        if (isA<coupledPolyPatch>(patches[patchI]))
+        if (patches[patchI].coupled())
         {
             const coupledPolyPatch& cpp =
                 refCast<const coupledPolyPatch>(patches[patchI]);
diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/clippedLinear/clippedLinear.H b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/clippedLinear/clippedLinear.H
index 312a453c44d..b69b2a05dc3 100644
--- a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/clippedLinear/clippedLinear.H
+++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/clippedLinear/clippedLinear.H
@@ -157,7 +157,7 @@ public:
 
             forAll(mesh.boundary(), patchi)
             {
-                if (mesh.boundary()[patchi].coupled())
+                if (clippedLinearWeights.boundaryField()[patchi].coupled())
                 {
                     clippedLinearWeights.boundaryField()[patchi] =
                         max
diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/reverseLinear/reverseLinear.H b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/reverseLinear/reverseLinear.H
index 5dd8ee104a0..3f3cae05fed 100644
--- a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/reverseLinear/reverseLinear.H
+++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/reverseLinear/reverseLinear.H
@@ -129,7 +129,7 @@ public:
 
             forAll(mesh.boundary(), patchI)
             {
-                if (mesh.boundary()[patchI].coupled())
+                if (reverseLinearWeights.boundaryField()[patchI].coupled())
                 {
                     reverseLinearWeights.boundaryField()[patchI] =
                         1.0 - cdWeights.boundaryField()[patchI];
diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C
index 0f2a765ea89..36fb2aa0359 100644
--- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C
+++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C
@@ -316,7 +316,7 @@ Foam::FacePostProcessing<CloudType>::FacePostProcessing
 
                     if
                     (
-                        !pp.coupled()
+                        !magSf.boundaryField()[patchI].coupled()
                      || refCast<const coupledPolyPatch>(pp).owner()
                     )
                     {
diff --git a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPointPatch/cyclicAMIPointPatch.H b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPointPatch/cyclicAMIPointPatch.H
index 3ade3aeaefa..78c69e0ad02 100644
--- a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPointPatch/cyclicAMIPointPatch.H
+++ b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPointPatch/cyclicAMIPointPatch.H
@@ -107,6 +107,17 @@ public:
 
     //- Destructor
     virtual ~cyclicAMIPointPatch();
+
+
+    // Member Functions
+
+        //- Is patch 'coupled'. Note that on AMI the geometry is not
+        //  coupled but the fields are!
+        virtual bool coupled() const
+        {
+            return false;
+        }
+
 };
 
 
diff --git a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C
index b6769849f7d..d281afc21f8 100644
--- a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C
+++ b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C
@@ -548,23 +548,6 @@ Foam::cyclicAMIPolyPatch::~cyclicAMIPolyPatch()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool Foam::cyclicAMIPolyPatch::coupled() const
-{
-    if
-    (
-        Pstream::parRun()
-     || (size() && neighbPatch().size())
-    )
-    {
-        return true;
-    }
-    else
-    {
-        return false;
-    }
-}
-
-
 Foam::label Foam::cyclicAMIPolyPatch::neighbPatchID() const
 {
     if (nbrPatchID_ == -1)
diff --git a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H
index ced7968171c..9ced39571a2 100644
--- a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H
+++ b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H
@@ -254,10 +254,12 @@ public:
 
         // Access
 
-            //- Return true only if is coupled. Note that for non-parallel
-            //  operation of a decomposed case this can return the wrong
-            //  result
-            virtual bool coupled() const;
+            //- Is patch 'coupled'. Note that on AMI the geometry is not
+            //  coupled but the fields are!
+            virtual bool coupled() const
+            {
+                return false;
+            }
 
             //- Neighbour patch name
             inline const word& neighbPatchName() const;
diff --git a/src/sampling/sampledSurface/isoSurface/isoSurface.C b/src/sampling/sampledSurface/isoSurface/isoSurface.C
index 81497e47a01..f96983d27ac 100644
--- a/src/sampling/sampledSurface/isoSurface/isoSurface.C
+++ b/src/sampling/sampledSurface/isoSurface/isoSurface.C
@@ -1769,7 +1769,7 @@ Foam::isoSurface::isoSurface
         const polyPatch& pp = patches[patchI];
 
         // Adapt separated coupled (proc and cyclic) patches
-        if (isA<coupledPolyPatch>(pp))
+        if (pp.coupled())
         {
             fvPatchVectorField& pfld = const_cast<fvPatchVectorField&>
             (
-- 
GitLab