From 9d4e09bbd15ef77e1ced51dbabec305f8c8842c7 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Mon, 30 Nov 2015 14:48:50 +0000
Subject: [PATCH] BUG: pressurePIDControlInletVelocity: incorporate faceZones
 on processor boundaries It was not correctly interpolating faceZones which
 are on processor boundaries. This caused difference between serial and
 parallel running. Fixes #16.

---
 ...IDControlInletVelocityFvPatchVectorField.C | 24 +++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressurePIDControlInletVelocity/pressurePIDControlInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressurePIDControlInletVelocity/pressurePIDControlInletVelocityFvPatchVectorField.C
index b7d36f1a6da..f4098267d84 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/pressurePIDControlInletVelocity/pressurePIDControlInletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/pressurePIDControlInletVelocity/pressurePIDControlInletVelocityFvPatchVectorField.C
@@ -30,6 +30,7 @@ License
 #include "surfaceFields.H"
 #include "linear.H"
 #include "steadyStateDdtScheme.H"
+#include "syncTools.H"
 
 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
 
@@ -78,6 +79,8 @@ void Foam::pressurePIDControlInletVelocityFvPatchVectorField::faceZoneAverage
 {
     const fvMesh& mesh(patch().boundaryMesh().mesh());
 
+    PackedBoolList isMasterFace(syncTools::getInternalOrMasterFaces(mesh));
+
     const faceZone& zone = mesh.faceZones()[name];
 
     area = 0;
@@ -87,10 +90,23 @@ void Foam::pressurePIDControlInletVelocityFvPatchVectorField::faceZoneAverage
     {
         const label f(zone[faceI]);
 
-        const scalar da(mesh.magSf()[f]);
-
-        area += da;
-        average += da*field[f];
+        if (mesh.isInternalFace(f))
+        {
+            const scalar da(mesh.magSf()[f]);
+
+            area += da;
+            average += da*field[f];
+        }
+        else if (isMasterFace[f])
+        {
+            const label bf(f-mesh.nInternalFaces());
+            const label patchID = mesh.boundaryMesh().patchID()[bf];
+            const label lf(mesh.boundaryMesh()[patchID].whichFace(f));
+            const scalar da(mesh.magSf().boundaryField()[patchID][lf]);
+
+            area += da;
+            average += da*field.boundaryField()[patchID][lf];
+        }
     }
 
     reduce(area, sumOp<scalar>());
-- 
GitLab