From 29617783eae61b9208ce21c62b2dd47628efd530 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 19 Sep 2013 09:33:03 +0100 Subject: [PATCH] BUG: meshToMesh: protect neighbours on top of destination --- .../meshToMesh/calculateMeshToMeshWeights.C | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/sampling/meshToMeshInterpolation/meshToMesh/calculateMeshToMeshWeights.C b/src/sampling/meshToMeshInterpolation/meshToMesh/calculateMeshToMeshWeights.C index b967f5a338..e6fbddabe8 100644 --- a/src/sampling/meshToMeshInterpolation/meshToMesh/calculateMeshToMeshWeights.C +++ b/src/sampling/meshToMeshInterpolation/meshToMesh/calculateMeshToMeshWeights.C @@ -65,15 +65,31 @@ void Foam::meshToMesh::calculateInverseDistanceWeights() const // if the nearest cell is a boundary cell or there is a direct hit, // pick up the value - if - ( - m < directHitTol // Direct hit - || neighbours.empty() - ) + label directCelli = -1; + if (m < directHitTol || neighbours.empty()) { - invDistCoeffs[celli].setSize(1); - invDistCoeffs[celli][0] = 1.0; - V_ += fromMesh_.V()[cellAddressing_[celli]]; + directCelli = celli; + } + else + { + forAll(neighbours, ni) + { + scalar nm = mag(target - centreFrom[neighbours[ni]]); + if (nm < directHitTol) + { + directCelli = neighbours[ni]; + break; + } + } + } + + + if (directCelli != -1) + { + // Direct hit + invDistCoeffs[directCelli].setSize(1); + invDistCoeffs[directCelli][0] = 1.0; + V_ += fromMesh_.V()[cellAddressing_[directCelli]]; } else {