diff --git a/src/OpenFOAM/interpolations/GGIInterpolation/GGIInterpolate.C b/src/OpenFOAM/interpolations/GGIInterpolation/GGIInterpolate.C index 3dcf3968e..3b18c0694 100644 --- a/src/OpenFOAM/interpolations/GGIInterpolation/GGIInterpolate.C +++ b/src/OpenFOAM/interpolations/GGIInterpolation/GGIInterpolate.C @@ -115,7 +115,7 @@ void GGIInterpolation::maskedBridge const Field& bridgeField, Field& ff, const labelList& mask, - const labelList& addr + const labelList& uncoveredFaces ) { // Note: tricky algorithm @@ -124,23 +124,32 @@ void GGIInterpolation::maskedBridge // This implies an n-squared search, but we can use the fact that // both lists are ordered. - label curAddrI = 0; + label maskAddrI = 0; - forAll (mask, maskI) + forAll (uncoveredFaces, uncoI) { - // Pick the masked face - const label faceI = mask[maskI]; + // Pick the uncovered face + const label faceI = uncoveredFaces[uncoI]; - for (; curAddrI < addr.size(); curAddrI++) + // Search through the mask + for (; maskAddrI < mask.size(); maskAddrI++) { - if (faceI == addr[curAddrI]) + if (faceI == mask[maskAddrI]) { // Found masked bridged face // Put the result into condensed list: masked faces only - ff[maskI] = bridgeField[faceI]; + ff[maskAddrI] = bridgeField[maskAddrI]; break; } + else if (mask[maskAddrI] > faceI) + { + // Gone beyond my index: my face is not present in the mask + // Go one back and check for next uncovered face + + maskAddrI--; + break; + } } } } diff --git a/src/OpenFOAM/interpolations/GGIInterpolation/GGIInterpolation.H b/src/OpenFOAM/interpolations/GGIInterpolation/GGIInterpolation.H index 4bfc06cd6..3412e3ebb 100644 --- a/src/OpenFOAM/interpolations/GGIInterpolation/GGIInterpolation.H +++ b/src/OpenFOAM/interpolations/GGIInterpolation/GGIInterpolation.H @@ -393,7 +393,7 @@ class GGIInterpolation const Field& bridgeField, Field& ff, const labelList& mask, - const labelList& addr + const labelList& uncoveredFaces ); //- Is a transform required?