From 26bb05d6f0ee23e57cff82d3ce2dd58ae02456ed Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Thu, 24 May 2018 13:29:43 +0100
Subject: [PATCH] BUG: cyclicPeriodic: wrong indexing. Fixes #838.

---
 .../cyclicPeriodicAMIPolyPatch.C                         | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C
index 0433f1a405f..6e4206e650c 100644
--- a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C
+++ b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2015 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2015-2018 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -548,10 +548,13 @@ void Foam::cyclicPeriodicAMIPolyPatch::resetAMI
         if (nFace)
         {
             scalarField srcWghtSum(size(), 0);
-            scalarField tgtWghtSum(size(), 0);
-            forAll(*this, faceI)
+            forAll(srcWghtSum, faceI)
             {
                 srcWghtSum[faceI] = sum(AMIPtr_->srcWeights()[faceI]);
+            }
+            scalarField tgtWghtSum(neighbPatch().size(), 0);
+            forAll(tgtWghtSum, faceI)
+            {
                 tgtWghtSum[faceI] = sum(AMIPtr_->tgtWeights()[faceI]);
             }
 
-- 
GitLab