ENH: Create points in a batch before insertion to allow distribution.

This commit is contained in:
graham
2011-06-13 15:45:27 +01:00
parent 1eb8b8ef12
commit 17314265fc
5 changed files with 86 additions and 26 deletions

View File

@ -244,7 +244,10 @@ void Foam::conformalVoronoiMesh::insertPoints
// Send the points that are not on this processor to the appropriate // Send the points that are not on this processor to the appropriate
// place // place
decomposition_().distributePoints(transferPoints); Foam::autoPtr<Foam::mapDistribute> map
(
decomposition_().distributePoints(transferPoints)
);
forAll(transferPoints, tPI) forAll(transferPoints, tPI)
{ {
@ -269,7 +272,7 @@ void Foam::conformalVoronoiMesh::insertPoints
label nVert = number_of_vertices(); label nVert = number_of_vertices();
Info<< "TEMPORARILY USING INDIVIDUAL INSERTION" << endl; Info<< "TEMPORARILY USING INDIVIDUAL INSERTION TO DETECT FAILURE" << endl;
// using the range insert (faster than inserting points one by one) // using the range insert (faster than inserting points one by one)
// insert(points.begin(), points.end()); // insert(points.begin(), points.end());
for for
@ -322,6 +325,10 @@ void Foam::conformalVoronoiMesh::insertSurfacePointPairs
<< exit(FatalError); << exit(FatalError);
} }
DynamicList<Foam::point> pts;
DynamicList<label> indices;
DynamicList<label> types;
forAll(surfaceHits, i) forAll(surfaceHits, i)
{ {
vectorField norm(1); vectorField norm(1);
@ -336,24 +343,58 @@ void Foam::conformalVoronoiMesh::insertSurfacePointPairs
const Foam::point& surfacePt(surfaceHits[i].hitPoint()); const Foam::point& surfacePt(surfaceHits[i].hitPoint());
insertPointPair createPointPair
( (
pointPairDistance(surfacePt), pointPairDistance(surfacePt),
surfacePt, surfacePt,
normal normal,
pts,
indices,
types
);
}
if (Pstream::parRun())
{
// The link between vertices that form the boundary via pairs cannot be
// strict because both points may end up on different processors. The
// only important thing is that each vertex knows its own role.
// Therefore, index and type are set to 0 or 1, then on the destination
// processor add back the new index to both.
// Each of points generated in this process are pair points, so there
// is no risk of underflowing type.
Pout<< "Suface point pair points before " << pts.size() << endl;
// Distribute points to their appropriate processor
autoPtr<mapDistribute> map
(
decomposition_().distributePoints(pts)
);
Pout<< "Suface point pair points after " << pts.size() << endl;
map().distribute(indices);
map().distribute(types);
}
forAll(pts, pI)
{
// creation of points and indices is done assuming that it will be
// relative to the instantaneous number_of_vertices() at insertion.
insertPoint
(
pts[pI],
indices[pI] + number_of_vertices(),
types[pI] + number_of_vertices()
); );
} }
if(cvMeshControls().objOutput() && fName != fileName::null) if(cvMeshControls().objOutput() && fName != fileName::null)
{ {
List<Foam::point> surfacePts(surfaceHits.size()); writePoints(fName, pts);
forAll(surfacePts, i)
{
surfacePts[i] = surfaceHits[i].hitPoint();
}
writePoints(fName, surfacePts);
} }
} }
@ -965,6 +1006,8 @@ void Foam::conformalVoronoiMesh::insertInitialPoints()
Info<< "NEED TO CHANGE storeSizesAndAlignments AFTER DISTRIBUTE" << endl; Info<< "NEED TO CHANGE storeSizesAndAlignments AFTER DISTRIBUTE" << endl;
Info<< "NEED TO MAP FEATURE POINTS AFTER DISTRIBUTE" << endl; Info<< "NEED TO MAP FEATURE POINTS AFTER DISTRIBUTE" << endl;
Info<< "NEED TO ENSURE THAT FEATURE POINTS ARE INSERTED ON THE "
<< "CORRECT PRCOESSOR" << endl;
storeSizesAndAlignments(initPts); storeSizesAndAlignments(initPts);
} }
@ -1065,10 +1108,13 @@ void Foam::conformalVoronoiMesh::distribute()
forAll(cellVertices, cI) forAll(cellVertices, cI)
{ {
// Give a small but finite weight for empty cells. Some
// decomposition methods have difficulty with integer overflows in
// the sum of the normalised weight field.
cellWeights.internalField()[cI] = max cellWeights.internalField()[cI] = max
( (
cellVertices[cI].size(), cellVertices[cI].size(),
1e-2 // Small but finite weight for empty cells 1e-2
); );
} }

View File

@ -267,13 +267,16 @@ private:
bool distribute = true bool distribute = true
); );
//- Insert a point-pair at a ppDist distance either side of //- Create a point-pair at a ppDist distance either side of
// surface point surfPt, in the direction n // surface point surfPt, in the direction n
inline void insertPointPair inline void createPointPair
( (
const scalar ppDist, const scalar ppDist,
const Foam::point& surfPt, const Foam::point& surfPt,
const vector& n const vector& n,
DynamicList<Foam::point>& pts,
DynamicList<label>& indices,
DynamicList<label>& types
); );
//- Insert a Vb (a typedef of CGAL::indexedVertex<K>) with the //- Insert a Vb (a typedef of CGAL::indexedVertex<K>) with the
@ -823,7 +826,7 @@ public:
const scalarField& radiusSqrs const scalarField& radiusSqrs
) const; ) const;
//- Conversion functions between point (OpenFOAM) and Point (CGAL) //- Conversion functions between point (FOAM::) and Point (CGAL)
# ifdef CGAL_INEXACT # ifdef CGAL_INEXACT
typedef const Foam::point& pointFromPoint; typedef const Foam::point& pointFromPoint;

View File

@ -1120,7 +1120,7 @@ void Foam::conformalVoronoiMesh::referVertices
{ {
// For the initial referred vertices, the original // For the initial referred vertices, the original
// processor is the one that is sending it. // processor is the one that is sending it.
label encodedProcI = -(procI + 1); label encodedProcI = Vb::encodeProcIndex(procI);
// Pout<< "Insert " // Pout<< "Insert "
// << parallelPoints[constructMap[i]] // << parallelPoints[constructMap[i]]

View File

@ -257,22 +257,27 @@ inline void Foam::conformalVoronoiMesh::insertPoint
} }
inline void Foam::conformalVoronoiMesh::insertPointPair inline void Foam::conformalVoronoiMesh::createPointPair
( (
const scalar ppDist, const scalar ppDist,
const Foam::point& surfPt, const Foam::point& surfPt,
const vector& n const vector& n,
DynamicList<Foam::point>& pts,
DynamicList<label>& indices,
DynamicList<label>& types
) )
{ {
vector ppDistn = ppDist*n; vector ppDistn = ppDist*n;
label master = insertPoint // Master
( pts.append(surfPt - ppDistn);
surfPt - ppDistn, indices.append(0);
number_of_vertices() + 1 types.append(1);
);
insertPoint(surfPt + ppDistn, master); // Slave
pts.append(surfPt + ppDistn);
types.append(1);
types.append(0);
} }

View File

@ -252,6 +252,12 @@ public:
} }
inline static int encodeProcIndex(int procI)
{
return -(procI + 1);
}
//- Set the point to be internal //- Set the point to be internal
inline void setInternal() inline void setInternal()
{ {