From a77aaa758208a1998736c85d0bfb47f5e7228010 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 17 Mar 2025 13:59:44 +0000 Subject: [PATCH] BUG: AMIInterpolation: reset cached data. Fixes #3334 --- .../AMIInterpolation/AMIInterpolation.C | 49 +++++++++++++++---- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C index e09bd86ffc..547112dda0 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2024 OpenCFD Ltd. + Copyright (C) 2015-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -923,6 +923,36 @@ bool Foam::AMIInterpolation::calculate addProfiling(ami, "AMIInterpolation::calculate"); + + // Clear storage (only needed if src/tgt become zero size) + { + if (srcMagSf_.size()) + { + srcMagSf_.resize_nocopy(srcPatch.size()); + } + srcAddress_.resize_nocopy(srcPatch.size()); + srcWeights_.resize_nocopy(srcPatch.size()); + srcWeightsSum_.resize_nocopy(srcPatch.size()); + if (srcCentroids_.size()) + { + srcCentroids_.resize_nocopy(srcPatch.size()); + } + + if (tgtPatch.size()) + { + tgtMagSf_.resize_nocopy(tgtPatch.size()); + } + tgtAddress_.resize_nocopy(tgtPatch.size()); + tgtWeights_.resize_nocopy(tgtPatch.size()); + tgtWeightsSum_.resize_nocopy(tgtPatch.size()); + + if (tgtCentroids_.size()) + { + tgtCentroids_.resize_nocopy(tgtPatch.size()); + } + } + + if (surfPtr) { srcPatchPts_ = srcPatch.points(); @@ -948,20 +978,13 @@ bool Foam::AMIInterpolation::calculate } // Note: use original communicator for statistics - label srcTotalSize = returnReduce + const label srcTotalSize = returnReduce ( srcPatch.size(), sumOp