ENH: Add dynamicIndexedOctree to cvMesh

This commit is contained in:
laurence
2012-02-03 14:21:17 +00:00
parent 36419e5eff
commit 4289ae94db
2 changed files with 70 additions and 65 deletions

View File

@ -61,6 +61,8 @@ SourceFiles
#include "plane.H" #include "plane.H"
#include "SortableList.H" #include "SortableList.H"
#include "meshTools.H" #include "meshTools.H"
#include "dynamicIndexedOctree.H"
#include "dynamicTreeDataPoint.H"
#include "indexedOctree.H" #include "indexedOctree.H"
#include "treeDataPoint.H" #include "treeDataPoint.H"
#include "unitConversion.H" #include "unitConversion.H"
@ -662,16 +664,16 @@ private:
( (
pointIndexHit& pHit, pointIndexHit& pHit,
DynamicList<Foam::point>& newEdgeLocations, DynamicList<Foam::point>& newEdgeLocations,
pointField& existingEdgeLocations, DynamicList<Foam::point>& existingEdgeLocations,
autoPtr<indexedOctree<treeDataPoint> >& edgeLocationTree dynamicIndexedOctree<dynamicTreeDataPoint>& edgeLocationTree
) const; ) const;
//- Build or rebuild the edgeLocationTree //- Build or rebuild the edgeLocationTree
void buildEdgeLocationTree // void buildEdgeLocationTree
( // (
autoPtr<indexedOctree<treeDataPoint> >& edgeLocationTree, // autoPtr<dynamicIndexedOctree<dynamicTreeDataPoint> >& edgeLocationTree,
const pointField& existingEdgeLocations // const pointField& existingEdgeLocations
) const; // ) const;
//- Build or rebuild the sizeAndAlignmentTree //- Build or rebuild the sizeAndAlignmentTree
void buildSizeAndAlignmentTree() const; void buildSizeAndAlignmentTree() const;
@ -691,8 +693,8 @@ private:
DynamicList<pointIndexHit>& featureEdgeHits, DynamicList<pointIndexHit>& featureEdgeHits,
DynamicList<label>& featureEdgeFeaturesHit, DynamicList<label>& featureEdgeFeaturesHit,
DynamicList<Foam::point>& newEdgeLocations, DynamicList<Foam::point>& newEdgeLocations,
pointField& existingEdgeLocations, DynamicList<Foam::point>& existingEdgeLocations,
autoPtr<indexedOctree<treeDataPoint> >& edgeLocationTree dynamicIndexedOctree<dynamicTreeDataPoint>& edgeLocationTree
) const; ) const;
//- Store the surface conformation with the indices offset to be //- Store the surface conformation with the indices offset to be

View File

@ -128,12 +128,27 @@ void Foam::conformalVoronoiMesh::buildSurfaceConformation
// Initialise containers to store the edge conformation locations // Initialise containers to store the edge conformation locations
DynamicList<Foam::point> newEdgeLocations; DynamicList<Foam::point> newEdgeLocations;
pointField existingEdgeLocations(0); DynamicList<Foam::point> existingEdgeLocations;
autoPtr<indexedOctree<treeDataPoint> > edgeLocationTree; treeBoundBox overallBb
(
geometryToConformTo_.globalBounds().extend(rndGen_, 1e-4)
);
overallBb.min() -= Foam::point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
overallBb.max() += Foam::point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
dynamicIndexedOctree<dynamicTreeDataPoint> edgeLocationTree
(
dynamicTreeDataPoint(existingEdgeLocations),
overallBb, // overall search domain
10, // max levels
10.0, // maximum ratio of cubes v.s. cells
100.0 // max. duplicity; n/a since no bounding boxes.
);
// Initialise the edgeLocationTree // Initialise the edgeLocationTree
buildEdgeLocationTree(edgeLocationTree, existingEdgeLocations); //buildEdgeLocationTree(edgeLocationTree, existingEdgeLocations);
label initialTotalHits = 0; label initialTotalHits = 0;
@ -1830,8 +1845,8 @@ bool Foam::conformalVoronoiMesh::nearFeatureEdgeLocation
( (
pointIndexHit& pHit, pointIndexHit& pHit,
DynamicList<Foam::point>& newEdgeLocations, DynamicList<Foam::point>& newEdgeLocations,
pointField& existingEdgeLocations, DynamicList<Foam::point>& existingEdgeLocations,
autoPtr<indexedOctree<treeDataPoint> >& edgeLocationTree dynamicIndexedOctree<dynamicTreeDataPoint>& edgeLocationTree
) const ) const
{ {
const Foam::point pt = pHit.hitPoint(); const Foam::point pt = pHit.hitPoint();
@ -1841,37 +1856,25 @@ bool Foam::conformalVoronoiMesh::nearFeatureEdgeLocation
// 0.01 and 1000 determined from speed tests, varying the indexedOctree // 0.01 and 1000 determined from speed tests, varying the indexedOctree
// rebuild frequency and balance of additions to queries. // rebuild frequency and balance of additions to queries.
if
(
newEdgeLocations.size() label startIndex = existingEdgeLocations.size();
>= max(0.01*existingEdgeLocations.size(), 1000)
)
{
const label originalSize = existingEdgeLocations.size();
existingEdgeLocations.append(newEdgeLocations); existingEdgeLocations.append(newEdgeLocations);
buildEdgeLocationTree(edgeLocationTree, existingEdgeLocations); label endIndex = existingEdgeLocations.size();
edgeLocationTree.insert(startIndex, endIndex);
newEdgeLocations.clear(); newEdgeLocations.clear();
}
else
{
// Search for the nearest point in newEdgeLocations.
// Searching here first, because the intention is that the value of
// newEdgeLocationsSizeLimit should make this faster by design.
if (min(magSqr(newEdgeLocations - pt)) <= exclusionRangeSqr) pointIndexHit info = edgeLocationTree.findNearest(pt, exclusionRangeSqr);
{
// Average the points...
return true;
}
}
// Searching for the nearest point in existingEdgeLocations using the // Searching for the nearest point in existingEdgeLocations using the
// indexedOctree // indexedOctree
pointIndexHit info = edgeLocationTree().findNearest(pt, exclusionRangeSqr);
// Average the points... // Average the points...
// if (info.hit()) // if (info.hit())
@ -1917,32 +1920,32 @@ bool Foam::conformalVoronoiMesh::nearFeatureEdgeLocation
} }
void Foam::conformalVoronoiMesh::buildEdgeLocationTree //void Foam::conformalVoronoiMesh::buildEdgeLocationTree
( //(
autoPtr<indexedOctree<treeDataPoint> >& edgeLocationTree, // autoPtr<indexedOctree<treeDataPoint> >& edgeLocationTree,
const pointField& existingEdgeLocations // DynamicList<Foam::point>& existingEdgeLocations
) const //) const
{ //{
treeBoundBox overallBb // treeBoundBox overallBb
( // (
geometryToConformTo_.globalBounds().extend(rndGen_, 1e-4) // geometryToConformTo_.globalBounds().extend(rndGen_, 1e-4)
); // );
//
overallBb.min() -= Foam::point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); // overallBb.min() -= Foam::point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
overallBb.max() += Foam::point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); // overallBb.max() += Foam::point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
//
edgeLocationTree.reset // edgeLocationTree.reset
( // (
new indexedOctree<treeDataPoint> // new indexedOctree<treeDataPoint>
( // (
treeDataPoint(existingEdgeLocations), // treeDataPoint(existingEdgeLocations),
overallBb, // overall search domain // overallBb, // overall search domain
10, // max levels // 10, // max levels
10.0, // maximum ratio of cubes v.s. cells // 10.0, // maximum ratio of cubes v.s. cells
100.0 // max. duplicity; n/a since no bounding boxes. // 100.0 // max. duplicity; n/a since no bounding boxes.
) // )
); // );
} //}
void Foam::conformalVoronoiMesh::buildSizeAndAlignmentTree() const void Foam::conformalVoronoiMesh::buildSizeAndAlignmentTree() const
@ -1990,8 +1993,8 @@ void Foam::conformalVoronoiMesh::addSurfaceAndEdgeHits
DynamicList<pointIndexHit>& featureEdgeHits, DynamicList<pointIndexHit>& featureEdgeHits,
DynamicList<label>& featureEdgeFeaturesHit, DynamicList<label>& featureEdgeFeaturesHit,
DynamicList<Foam::point>& newEdgeLocations, DynamicList<Foam::point>& newEdgeLocations,
pointField& existingEdgeLocations, DynamicList<Foam::point>& existingEdgeLocations,
autoPtr<indexedOctree<treeDataPoint> >& edgeLocationTree dynamicIndexedOctree<dynamicTreeDataPoint>& edgeLocationTree
) const ) const
{ {
bool keepSurfacePoint = true; bool keepSurfacePoint = true;