From 93b0a57791c87a1fd6e9efb00d935f2a81febbba Mon Sep 17 00:00:00 2001
From: sergio <s.ferraris@opencfd.co.uk>
Date: Fri, 6 Aug 2021 11:07:48 -0700
Subject: [PATCH] BUG: Fixes #2175 and #2176

---
 .../constraint/cyclicAMI/cyclicAMIFvPatchField.C    |  6 +++---
 src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C     | 13 ++++++++++++-
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C
index 95bccb0e3f9..502e7101370 100644
--- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C
@@ -210,12 +210,14 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
 
     solveScalarField pnf(psiInternal, nbrFaceCells);
 
+    const labelUList& faceCells = lduAddr.patchAddr(patchId);
+
     // Transform according to the transformation tensors
     transformCoupleField(pnf, cmpt);
 
     if (cyclicAMIPatch_.applyLowWeightCorrection())
     {
-        solveScalarField pif(psiInternal, cyclicAMIPatch_.faceCells());
+        solveScalarField pif(psiInternal, faceCells);
         pnf = cyclicAMIPatch_.interpolate(pnf, pif);
     }
     else
@@ -223,8 +225,6 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
         pnf = cyclicAMIPatch_.interpolate(pnf);
     }
 
-    const labelUList& faceCells = lduAddr.patchAddr(patchId);
-
     // Multiply the field by coefficients and add into the result
     this->addToInternalField(result, !add, faceCells, coeffs, pnf);
 }
diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C
index 6ad6ee6abcf..1aa4aa9ffb6 100644
--- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C
+++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C
@@ -313,10 +313,21 @@ Foam::label Foam::fvMatrix<Type>::checkImplicit(const label fieldI)
     {
         if (bpsi[patchI].useImplicit())
         {
+            if (debug)
+            {
+                Pout<< "fvMatrix<Type>::checkImplicit "
+                    << " fieldi:" << fieldI
+                    << " field:" << this->psi(fieldI).name()
+                    << " on mesh:"
+                    << this->psi(fieldI).mesh().name()
+                    << " patch:" << bpsi[patchI].patch().name()
+                    << endl;
+            }
+
             id += (label(2) << patchI);
         }
     }
-    if (id > 0)
+    if (id >= 0)
     {
         lduAssemblyName_ = word("lduAssembly") + name(id);
         useImplicit_ = true;
-- 
GitLab