ENH: More queries and point distribution function.

This commit is contained in:
graham
2011-06-10 17:05:11 +01:00
parent 6ecf2915fd
commit 50f146ee20
7 changed files with 192 additions and 56 deletions

View File

@ -1055,6 +1055,18 @@ Foam::backgroundMeshDecomposition::distribute
return mapDist;
}
void Foam::backgroundMeshDecomposition::distributePoints
(
List<point>& points
) const
{
labelList toProc(processorPosition(points));
autoPtr<mapDistribute> map(buildMap(toProc));
map().distribute(points);
}
bool Foam::backgroundMeshDecomposition::positionOnThisProcessor
(
@ -1067,6 +1079,22 @@ bool Foam::backgroundMeshDecomposition::positionOnThisProcessor
}
Foam::boolList Foam::backgroundMeshDecomposition::positionOnThisProcessor
(
const List<point>& pts
) const
{
boolList posProc(pts.size(), true);
forAll(pts, pI)
{
posProc[pI] = positionOnThisProcessor(pts[pI]);
}
return posProc;
}
Foam::pointIndexHit Foam::backgroundMeshDecomposition::findLine
(
const point& start,

View File

@ -210,9 +210,15 @@ public:
List<DynamicList<point> >& cellVertices
);
//- Distribute supplied the points to the appropriate processor
void distributePoints(List<point>& points) const;
//- Is the given position inside the domain of this decomposition
bool positionOnThisProcessor(const point& pt) const;
//- Are the given positions inside the domain of this decomposition
boolList positionOnThisProcessor(const List<point>& pts) const;
//- Find nearest intersection of line between start and end, (exposing
// underlying indexedOctree)
pointIndexHit findLine

View File

@ -198,6 +198,121 @@ Foam::tensor Foam::conformalVoronoiMesh::requiredAlignment
}
void Foam::conformalVoronoiMesh::insertPoints
(
std::list<Point>& points,
bool distribute
)
{
label preInsertionSize(number_of_vertices());
label nPoints = points.size();
if (Pstream::parRun())
{
reduce(nPoints, sumOp<label>());
}
Info<< " " << nPoints << " points to insert..." << endl;
if (Pstream::parRun() && distribute)
{
label preDistributionSize(points.size());
DynamicList<Foam::point> transferPoints;
for
(
std::list<Point>::iterator pit=points.begin();
pit != points.end();
// No action
)
{
Foam::point p(topoint(*pit));
if (!positionOnThisProc(p))
{
transferPoints.append(p);
pit = points.erase(pit);
}
else
{
++pit;
}
}
nPoints = points.size();
reduce(nPoints, sumOp<label>());
Info<< " " << nPoints
<< " points to insert after erasure..." << endl;
// Send the points that are not on this processor to the appropriate
// place
decomposition_().distributePoints(transferPoints);
forAll(transferPoints, tPI)
{
points.push_back(toPoint(transferPoints[tPI]));
}
label sizeChange = preDistributionSize - label(points.size());
if (mag(sizeChange) > 0)
{
Pout<< " distribution points size change " << sizeChange
<< endl;
}
nPoints = points.size();
reduce(nPoints, sumOp<label>());
Info<< " " << nPoints
<< " points to insert after distribution..." << endl;
}
label nVert = number_of_vertices();
Info<< "TEMPORARILY USING INDIVIDUAL INSERTION" << endl;
// using the range insert (faster than inserting points one by one)
// insert(points.begin(), points.end());
for
(
std::list<Point>::iterator pit=points.begin();
pit != points.end();
++pit
)
{
insertVb(*pit);
}
label nInserted(number_of_vertices() - preInsertionSize);
if (Pstream::parRun())
{
reduce(nInserted, sumOp<label>());
}
Info<< " " << nInserted << " points inserted" << endl;
for
(
Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
vit != finite_vertices_end();
++vit
)
{
if (vit->uninitialised())
{
vit->index() = nVert++;
}
}
}
void Foam::conformalVoronoiMesh::insertSurfacePointPairs
(
const List<pointIndexHit>& surfaceHits,
@ -846,7 +961,9 @@ void Foam::conformalVoronoiMesh::insertInitialPoints()
timeCheck("After initial points call");
insertPoints(initPts);
// Assume that the initial points method made the correct decision for
// which processor each point should be on, so give distribute = false
insertPoints(initPts, false);
if(cvMeshControls().objOutput())
{
@ -1024,9 +1141,16 @@ void Foam::conformalVoronoiMesh::storeSizesAndAlignments
storedAlignments_.setSize(sizeAndAlignmentLocations_.size());
forAll(sizeAndAlignmentLocations_, i)
label i = 0;
for
(
std::list<Point>::const_iterator pit=storePts.begin();
pit != storePts.end();
++pit
)
{
sizeAndAlignmentLocations_[i] = topoint(storePts[i]);
sizeAndAlignmentLocations_[i] = topoint(*pit);
storedSizes_[i] = cellSizeControl().cellSize
(
@ -1035,6 +1159,8 @@ void Foam::conformalVoronoiMesh::storeSizesAndAlignments
);
storedAlignments_[i] = requiredAlignment(sizeAndAlignmentLocations_[i]);
i++;
}
timeCheck("Sizes and alignments calculated, build tree");
@ -1847,6 +1973,20 @@ bool Foam::conformalVoronoiMesh::positionOnThisProc
}
Foam::boolList Foam::conformalVoronoiMesh::positionOnThisProc
(
const Foam::pointField& pts
) const
{
if (Pstream::parRun())
{
return decomposition_().positionOnThisProcessor(pts);
}
return boolList(pts.size(), true);
}
Foam::labelList Foam::conformalVoronoiMesh::positionProc
(
const Foam::pointField& pts

View File

@ -258,9 +258,14 @@ private:
const label type
);
//- Insert a std::vector of CGAL Points using the CGAL range insertion
// method
inline void insertPoints(const std::vector<Point>& points);
//- Insert CGAL Points using the CGAL range insertion method,
// optionally check processor occupancy and distribute to other
// processors
void insertPoints
(
std::list<Point>& points,
bool distribute = true
);
//- Insert a point-pair at a ppDist distance either side of
// surface point surfPt, in the direction n
@ -813,6 +818,9 @@ public:
//- Check if the point is in the domain handled by this processor
bool positionOnThisProc(const Foam::point& pt) const;
//- Check if the point is in the domain handled by this processor
boolList positionOnThisProc(const Foam::pointField& pts) const;
//- Which processor's domain handles this point
labelList positionProc(const Foam::pointField& pts) const;

View File

@ -802,9 +802,11 @@ void Foam::conformalVoronoiMesh::buildParallelInterfaceInfluence
circumcentre.setSize(cI);
circumradiusSqr.setSize(cI);
// Increasing the circumspheres to increase the overlaps and compensate for
// floating point errors missing some referrals
labelListList circumsphereOverlaps
(
overlapsProc(circumcentre, circumradiusSqr)
overlapsProc(circumcentre, sqr(1.01)*circumradiusSqr)
);
cI = 0;

View File

@ -257,49 +257,6 @@ inline void Foam::conformalVoronoiMesh::insertPoint
}
inline void Foam::conformalVoronoiMesh::insertPoints
(
const std::vector<Point>& points
)
{
label nPoints = points.size();
if (Pstream::parRun())
{
reduce(nPoints, sumOp<label>());
}
Info<< " " << nPoints << " points to insert..." << endl;
label nVert = number_of_vertices();
// using the range insert (faster than inserting points one by one)
insert(points.begin(), points.end());
label nInserted = number_of_vertices() - startOfInternalPoints_;
if (Pstream::parRun())
{
reduce(nInserted, sumOp<label>());
}
Info<< " " << nInserted << " points inserted" << endl;
for
(
Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
vit != finite_vertices_end();
++vit
)
{
if (vit->uninitialised())
{
vit->index() = nVert++;
}
}
}
inline void Foam::conformalVoronoiMesh::insertPointPair
(
const scalar ppDist,

View File

@ -75,12 +75,7 @@ std::list<Vb::Point> pointFile::initialPoints() const
}
// Filter the points to be only those on this processor
boolList procPt(points.size(), false);
forAll(points, ptI)
{
procPt[ptI] = cvMesh_.positionOnThisProc(points[ptI]);
}
boolList procPt(cvMesh_.positionOnThisProc(points));
if (Pstream::parRun())
{