From 4385da96e172ba189d29c8336b7dc4a95295fad2 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 14 Jul 2011 15:21:56 +0100 Subject: [PATCH] BUG: patchCloudSet: only take hits. Use local bounding box for tree --- src/sampling/sampledSet/patchCloud/patchCloudSet.C | 63 ++++++++-------------- 1 file changed, 23 insertions(+), 40 deletions(-) diff --git a/src/sampling/sampledSet/patchCloud/patchCloudSet.C b/src/sampling/sampledSet/patchCloud/patchCloudSet.C index 534b70ca..f8442b72 100644 --- a/src/sampling/sampledSet/patchCloud/patchCloudSet.C +++ b/src/sampling/sampledSet/patchCloud/patchCloudSet.C @@ -26,14 +26,13 @@ License #include "patchCloudSet.H" #include "polyMesh.H" #include "addToRunTimeSelectionTable.H" -#include "pointIndexHit.H" -#include "Tuple2.H" #include "treeBoundBox.H" -#include "indexedOctree.H" #include "treeDataFace.H" #include "Time.H" #include "meshTools.H" #include "wordReList.H" +// For 'nearInfo' helper class only +#include "directMappedPatchBase.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -41,36 +40,6 @@ namespace Foam { defineTypeNameAndDebug(patchCloudSet, 0); addToRunTimeSelectionTable(sampledSet, patchCloudSet, word); - - - //- Helper class for finding nearest - // Nearest: - // - point+local index - // - sqr(distance) - // - processor - typedef Tuple2 > nearInfo; - - class nearestEqOp - { - - public: - - void operator()(nearInfo& x, const nearInfo& y) const - { - if (y.first().hit()) - { - if (!x.first().hit()) - { - x = y; - } - else if (y.second().first() < x.second().first()) - { - x = y; - } - } - } - }; - } @@ -116,7 +85,8 @@ void Foam::patchCloudSet::calcSamples patchFaces[sz++] = pp.start()+i; } - const boundBox patchBb(pp.localPoints()); + // Do not do reduction. + const boundBox patchBb(pp.localPoints(), false); bb.min() = min(bb.min(), patchBb.min()); bb.max() = max(bb.max(), patchBb.max()); @@ -127,6 +97,7 @@ void Foam::patchCloudSet::calcSamples // Make bb asymetric just to avoid problems on symmetric meshes bb = bb.extend(rndGen, 1E-4); + // Make sure bb is 3D. bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); @@ -148,7 +119,7 @@ void Foam::patchCloudSet::calcSamples // All the info for nearest. Construct to miss - List nearest(sampleCoords_.size()); + List nearest(sampleCoords_.size()); forAll(sampleCoords_, sampleI) { @@ -157,7 +128,15 @@ void Foam::patchCloudSet::calcSamples pointIndexHit& nearInfo = nearest[sampleI].first(); // Find the nearest locally - nearInfo = patchTree.findNearest(sample, magSqr(bb.span())); + if (patchFaces.size()) + { + nearInfo = patchTree.findNearest(sample, magSqr(bb.span())); + } + else + { + nearInfo.setMiss(); + } + // Fill in the distance field and the processor field if (!nearInfo.hit()) @@ -181,7 +160,7 @@ void Foam::patchCloudSet::calcSamples // Find nearest. - Pstream::listCombineGather(nearest, nearestEqOp()); + Pstream::listCombineGather(nearest, directMappedPatchBase::nearestEqOp()); Pstream::listCombineScatter(nearest); @@ -212,10 +191,14 @@ void Foam::patchCloudSet::calcSamples // Store the sampling locations on the nearest processor forAll(nearest, sampleI) { - if (nearest[sampleI].second().second() == Pstream::myProcNo()) - { - const pointIndexHit& nearInfo = nearest[sampleI].first(); + const pointIndexHit& nearInfo = nearest[sampleI].first(); + if + ( + nearInfo.hit() + && nearest[sampleI].second().second() == Pstream::myProcNo() + ) + { label faceI = nearInfo.index(); samplingPts.append(nearInfo.hitPoint()); -- 2.11.4.GIT