From 9d453652d6a8bdd38f60127eb64334190c1ad619 Mon Sep 17 00:00:00 2001
From: andy <andy>
Date: Tue, 15 Nov 2011 14:53:27 +0000
Subject: [PATCH] ENH: Updated AMI output to include average weights

---
 .../AMIInterpolation/AMIInterpolation.C        | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C
index 4c6cda063a7..3b7f7a527f4 100644
--- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C
+++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C
@@ -1094,18 +1094,19 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::normaliseWeights
     const bool output
 )
 {
-    scalarList wghtSum(wght.size(), 0.0);
-
     scalar minBound = VGREAT;
     scalar maxBound = -VGREAT;
 
+    scalar tSum = 0.0;
+
     // Normalise the weights
     forAll(wght, faceI)
     {
         scalar s = sum(wght[faceI]);
-        wghtSum[faceI] = s;
-
         scalar t = s/patchAreas[faceI];
+
+        tSum += t;
+
         if (t < minBound)
         {
             minBound = t;
@@ -1122,11 +1123,16 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::normaliseWeights
         }
     }
 
+
     if (output)
     {
-        Info<< "AMI: Patch " << patchName << " weights min/max = "
+        const label nFace = returnReduce(wght.size(), sumOp<scalar>());
+        reduce(tSum, sumOp<scalar>());
+
+        Info<< "AMI: Patch " << patchName << " weights min/max/average = "
             << returnReduce(minBound, minOp<scalar>()) << ", "
-            << returnReduce(maxBound, maxOp<scalar>()) << endl;
+            << returnReduce(maxBound, maxOp<scalar>()) << ", "
+            << tSum/nFace << endl;
     }
 }
 
-- 
GitLab