Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BUG: patchCloudSet: only take hits. Use local bounding box for tree

  • Loading branch information...
commit 4385da96e172ba189d29c8336b7dc4a95295fad2 1 parent c0f4804
mattijs authored
Showing with 23 additions and 40 deletions.
  1. +23 −40 src/sampling/sampledSet/patchCloud/patchCloudSet.C
View
63 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<pointIndexHit, Tuple2<scalar, label> > 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<nearInfo> nearest(sampleCoords_.size());
+ List<directMappedPatchBase::nearInfo> 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());
Please sign in to comment.
Something went wrong with that request. Please try again.