bb tolerances

This commit is contained in:
mattijs
2009-03-12 13:41:50 +00:00
parent 77a80dd5e7
commit cd107e764a
5 changed files with 60 additions and 27 deletions

View File

@ -209,7 +209,7 @@ void Foam::directMappedPolyPatch::findSamples
// patch faces // patch faces
const labelList patchFaces(identity(pp.size()) + pp.start()); const labelList patchFaces(identity(pp.size()) + pp.start());
const treeBoundBox patchBb treeBoundBox patchBb
( (
treeBoundBox(pp.points(), pp.meshPoints()).extend treeBoundBox(pp.points(), pp.meshPoints()).extend
( (
@ -217,6 +217,8 @@ void Foam::directMappedPolyPatch::findSamples
1E-4 1E-4
) )
); );
patchBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
patchBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
autoPtr<indexedOctree<treeDataFace> > boundaryTree autoPtr<indexedOctree<treeDataFace> > boundaryTree
( (

View File

@ -26,7 +26,6 @@ License
#include "indexedOctree.H" #include "indexedOctree.H"
#include "linePointRef.H" #include "linePointRef.H"
// #include "triSurface.H"
#include "meshTools.H" #include "meshTools.H"
#include "OFstream.H" #include "OFstream.H"

View File

@ -460,8 +460,10 @@ const Foam::indexedOctree<Foam::treeDataFace>& Foam::meshSearch::boundaryTree()
} }
treeBoundBox overallBb(mesh_.points()); treeBoundBox overallBb(mesh_.points());
Random rndGen(123456); Random rndGen(123456);
overallBb.extend(rndGen, 1E-4);
overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
boundaryTreePtr_ = new indexedOctree<treeDataFace> boundaryTreePtr_ = new indexedOctree<treeDataFace>
( (
@ -471,7 +473,7 @@ const Foam::indexedOctree<Foam::treeDataFace>& Foam::meshSearch::boundaryTree()
mesh_, mesh_,
bndFaces // boundary faces only bndFaces // boundary faces only
), ),
overallBb.extend(rndGen, 1E-3), // overall search domain overallBb, // overall search domain
8, // maxLevel 8, // maxLevel
10, // leafsize 10, // leafsize
3.0 // duplicity 3.0 // duplicity
@ -492,6 +494,10 @@ const Foam::indexedOctree<Foam::treeDataCell>& Foam::meshSearch::cellTree()
// //
treeBoundBox overallBb(mesh_.points()); 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<treeDataCell> cellTreePtr_ = new indexedOctree<treeDataCell>
( (
@ -522,6 +528,10 @@ const Foam::indexedOctree<Foam::treeDataPoint>&
// //
treeBoundBox overallBb(mesh_.cellCentres()); 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<treeDataPoint> cellCentreTreePtr_ = new indexedOctree<treeDataPoint>
( (

View File

@ -352,17 +352,24 @@ const Foam::indexedOctree<Foam::treeDataTriSurface>&
{ {
if (tree_.empty()) if (tree_.empty())
{ {
treeBoundBox bb(points(), meshPoints());
// Random number generator. Bit dodgy since not exactly random ;-) // Random number generator. Bit dodgy since not exactly random ;-)
Random rndGen(65431); 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 tree_.reset
( (
new indexedOctree<treeDataTriSurface> new indexedOctree<treeDataTriSurface>
( (
treeDataTriSurface(*this), treeDataTriSurface(*this),
bb.extend(rndGen, 1E-4), // slightly randomize bb bb,
10, // maxLevel 10, // maxLevel
10, // leafsize 10, // leafsize
3.0 // duplicity 3.0 // duplicity
@ -379,8 +386,6 @@ const Foam::indexedOctree<Foam::treeDataEdge>&
{ {
if (edgeTree_.empty()) if (edgeTree_.empty())
{ {
treeBoundBox bb(localPoints());
// Boundary edges // Boundary edges
labelList bEdges labelList bEdges
( (
@ -395,6 +400,15 @@ const Foam::indexedOctree<Foam::treeDataEdge>&
// Random number generator. Bit dodgy since not exactly random ;-) // Random number generator. Bit dodgy since not exactly random ;-)
Random rndGen(65431); 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 edgeTree_.reset
( (
new indexedOctree<treeDataEdge> new indexedOctree<treeDataEdge>
@ -406,7 +420,7 @@ const Foam::indexedOctree<Foam::treeDataEdge>&
localPoints(), // points localPoints(), // points
bEdges // selected edges bEdges // selected edges
), ),
bb.extend(rndGen, 1E-4), // slightly randomize bb bb, // bb
8, // maxLevel 8, // maxLevel
10, // leafsize 10, // leafsize
3.0 // duplicity 3.0 // duplicity
@ -463,8 +477,11 @@ void Foam::triSurfaceMesh::findNearest
forAll(samples, i) forAll(samples, i)
{ {
static_cast<pointIndexHit&>(info[i]) = static_cast<pointIndexHit&>(info[i]) = octree.findNearest
octree.findNearest(samples[i], nearestDistSqr[i]); (
samples[i],
nearestDistSqr[i]
);
} }
} }
@ -504,8 +521,11 @@ void Foam::triSurfaceMesh::findLineAny
forAll(start, i) forAll(start, i)
{ {
static_cast<pointIndexHit&>(info[i]) = static_cast<pointIndexHit&>(info[i]) = octree.findLineAny
octree.findLineAny(start[i], end[i]); (
start[i],
end[i]
);
} }
} }

View File

@ -50,19 +50,21 @@ triSurfaceSearch::triSurfaceSearch(const triSurface& surface)
surface_(surface), surface_(surface),
treePtr_(NULL) 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(); // Slightly extended bb. Slightly off-centred just so on symmetric
// geometry there are less face/edge aligned items.
point& bbMin = treeBb.min(); treeBoundBox treeBb
bbMin.x() -= tol; (
bbMin.y() -= tol; treeBoundBox(surface_.points(), surface_.meshPoints()).extend
bbMin.z() -= tol; (
rndGen,
point& bbMax = treeBb.max(); 1E-4
bbMax.x() += 2*tol; )
bbMax.y() += 2*tol; );
bbMax.z() += 2*tol; treeBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
treeBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
treePtr_.reset treePtr_.reset
( (