From dec0a99a2476ee3fb02fb83ed7a15b8af4117c0a Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 26 Mar 2013 15:13:32 +0000 Subject: [PATCH] ENH: Updated mesh-to-mesh nearest mapping --- .../meshToMeshNew/calcMapNearest.C | 46 +++++++++++++++---- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/sampling/meshToMeshInterpolation/meshToMeshNew/calcMapNearest.C b/src/sampling/meshToMeshInterpolation/meshToMeshNew/calcMapNearest.C index 110979532f..0276ee5604 100644 --- a/src/sampling/meshToMeshInterpolation/meshToMeshNew/calcMapNearest.C +++ b/src/sampling/meshToMeshInterpolation/meshToMeshNew/calcMapNearest.C @@ -48,8 +48,6 @@ void Foam::meshToMeshNew::calcMapNearest label srcCellI = srcSeedI; label tgtCellI = tgtSeedI; - boolList tgtMapFlag(tgt.nCells(), true); - do { // find nearest tgt cell @@ -61,7 +59,6 @@ void Foam::meshToMeshNew::calcMapNearest // mark source cell srcCellI and tgtCellI as matched mapFlag[srcCellI] = false; - tgtMapFlag[tgtCellI] = false; // accumulate intersection volume V_ += srcVc[srcCellI]; @@ -80,11 +77,44 @@ void Foam::meshToMeshNew::calcMapNearest } while (srcCellI >= 0); - // If there are more target cells than source cells, some target cells - // will not yet be mapped - forAll(tgtMapFlag, tgtCellI) + + // for the case of multiple source cells per target cell, select the + // nearest source cell only and discard the others + const vectorField& srcCc = src.cellCentres(); + const vectorField& tgtCc = tgt.cellCentres(); + + forAll(tgtToSrc, targetCellI) { - if (tgtMapFlag[tgtCellI]) + if (tgtToSrc[targetCellI].size() > 1) + { + const vector& tgtC = tgtCc[tgtCellI]; + + DynamicList