diff --git a/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.C b/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.C index 5d54517f0b..e97377294c 100644 --- a/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.C +++ b/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.C @@ -209,7 +209,7 @@ void Foam::directMappedPolyPatch::findSamples // patch faces const labelList patchFaces(identity(pp.size()) + pp.start()); - const treeBoundBox patchBb + treeBoundBox patchBb ( treeBoundBox(pp.points(), pp.meshPoints()).extend ( @@ -217,6 +217,8 @@ void Foam::directMappedPolyPatch::findSamples 1E-4 ) ); + patchBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + patchBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); autoPtr > boundaryTree ( diff --git a/src/meshTools/indexedOctree/indexedOctree.C b/src/meshTools/indexedOctree/indexedOctree.C index 385fb2d314..9b065c36ac 100644 --- a/src/meshTools/indexedOctree/indexedOctree.C +++ b/src/meshTools/indexedOctree/indexedOctree.C @@ -26,7 +26,6 @@ License #include "indexedOctree.H" #include "linePointRef.H" -// #include "triSurface.H" #include "meshTools.H" #include "OFstream.H" diff --git a/src/meshTools/meshSearch/meshSearch.C b/src/meshTools/meshSearch/meshSearch.C index 808da494b5..ef1aa46f67 100644 --- a/src/meshTools/meshSearch/meshSearch.C +++ b/src/meshTools/meshSearch/meshSearch.C @@ -460,8 +460,10 @@ const Foam::indexedOctree& Foam::meshSearch::boundaryTree() } treeBoundBox overallBb(mesh_.points()); - Random rndGen(123456); + overallBb.extend(rndGen, 1E-4); + overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); boundaryTreePtr_ = new indexedOctree ( @@ -471,7 +473,7 @@ const Foam::indexedOctree& Foam::meshSearch::boundaryTree() mesh_, bndFaces // boundary faces only ), - overallBb.extend(rndGen, 1E-3), // overall search domain + overallBb, // overall search domain 8, // maxLevel 10, // leafsize 3.0 // duplicity @@ -492,6 +494,10 @@ const Foam::indexedOctree& Foam::meshSearch::cellTree() // treeBoundBox overallBb(mesh_.points()); + Random rndGen(123456); + overallBb.extend(rndGen, 1E-4); + overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); cellTreePtr_ = new indexedOctree ( @@ -522,6 +528,10 @@ const Foam::indexedOctree& // treeBoundBox overallBb(mesh_.cellCentres()); + Random rndGen(123456); + overallBb.extend(rndGen, 1E-4); + overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); cellCentreTreePtr_ = new indexedOctree ( diff --git a/src/meshTools/searchableSurface/triSurfaceMesh.C b/src/meshTools/searchableSurface/triSurfaceMesh.C index 9958afd1b1..4703d69201 100644 --- a/src/meshTools/searchableSurface/triSurfaceMesh.C +++ b/src/meshTools/searchableSurface/triSurfaceMesh.C @@ -352,17 +352,24 @@ const Foam::indexedOctree& { if (tree_.empty()) { - treeBoundBox bb(points(), meshPoints()); - // Random number generator. Bit dodgy since not exactly random ;-) Random rndGen(65431); + // Slightly extended bb. Slightly off-centred just so on symmetric + // geometry there are less face/edge aligned items. + treeBoundBox bb + ( + treeBoundBox(points(), meshPoints()).extend(rndGen, 1E-4) + ); + bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + tree_.reset ( new indexedOctree ( treeDataTriSurface(*this), - bb.extend(rndGen, 1E-4), // slightly randomize bb + bb, 10, // maxLevel 10, // leafsize 3.0 // duplicity @@ -375,12 +382,10 @@ const Foam::indexedOctree& const Foam::indexedOctree& - Foam::triSurfaceMesh::edgeTree() const + Foam::triSurfaceMesh::edgeTree() const { if (edgeTree_.empty()) { - treeBoundBox bb(localPoints()); - // Boundary edges labelList bEdges ( @@ -395,6 +400,15 @@ const Foam::indexedOctree& // Random number generator. Bit dodgy since not exactly random ;-) Random rndGen(65431); + // Slightly extended bb. Slightly off-centred just so on symmetric + // geometry there are less face/edge aligned items. + treeBoundBox bb + ( + treeBoundBox(points(), meshPoints()).extend(rndGen, 1E-4) + ); + bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + edgeTree_.reset ( new indexedOctree @@ -406,7 +420,7 @@ const Foam::indexedOctree& localPoints(), // points bEdges // selected edges ), - bb.extend(rndGen, 1E-4), // slightly randomize bb + bb, // bb 8, // maxLevel 10, // leafsize 3.0 // duplicity @@ -463,8 +477,11 @@ void Foam::triSurfaceMesh::findNearest forAll(samples, i) { - static_cast(info[i]) = - octree.findNearest(samples[i], nearestDistSqr[i]); + static_cast(info[i]) = octree.findNearest + ( + samples[i], + nearestDistSqr[i] + ); } } @@ -504,8 +521,11 @@ void Foam::triSurfaceMesh::findLineAny forAll(start, i) { - static_cast(info[i]) = - octree.findLineAny(start[i], end[i]); + static_cast(info[i]) = octree.findLineAny + ( + start[i], + end[i] + ); } } diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C index 99f3a8eeaf..525126251f 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C @@ -50,19 +50,21 @@ triSurfaceSearch::triSurfaceSearch(const triSurface& surface) surface_(surface), treePtr_(NULL) { - treeBoundBox treeBb(surface_.points(), surface_.meshPoints()); + // Random number generator. Bit dodgy since not exactly random ;-) + Random rndGen(65431); - scalar tol = 1E-6 * treeBb.avgDim(); - - point& bbMin = treeBb.min(); - bbMin.x() -= tol; - bbMin.y() -= tol; - bbMin.z() -= tol; - - point& bbMax = treeBb.max(); - bbMax.x() += 2*tol; - bbMax.y() += 2*tol; - bbMax.z() += 2*tol; + // Slightly extended bb. Slightly off-centred just so on symmetric + // geometry there are less face/edge aligned items. + treeBoundBox treeBb + ( + treeBoundBox(surface_.points(), surface_.meshPoints()).extend + ( + rndGen, + 1E-4 + ) + ); + treeBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + treeBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); treePtr_.reset (