ENH: Always create all patches, even if they are empty.

Move the default patch before the processor patches.

Add a new boundBox to the geometry to assess the bounds of the "mesh" - really
the bounds of the Delaunay vertices which gets updated and can overlap.
This commit is contained in:
graham
2011-04-22 15:42:40 +01:00
parent a803f9ea2c
commit b6071774f2
6 changed files with 83 additions and 164 deletions

View File

@ -725,21 +725,16 @@ private:
List<Pair<DynamicList<label> > >& patchSortingIndices List<Pair<DynamicList<label> > >& patchSortingIndices
) const; ) const;
//- Add the faces and owner information for the patches, //- Add the faces and owner information for the patches
// optionally removing any zero-size patches
void addPatches void addPatches
( (
const label nInternalFaces, const label nInternalFaces,
faceList& faces, faceList& faces,
labelList& owner, labelList& owner,
wordList& patchTypes,
wordList& patchNames,
labelList& patchSizes, labelList& patchSizes,
labelList& patchStarts, labelList& patchStarts,
labelList& procNeighbours,
List<DynamicList<face> >& patchFaces, List<DynamicList<face> >& patchFaces,
List<DynamicList<label> >& patchOwners, List<DynamicList<label> >& patchOwners
bool includeEmptyPatches
) const; ) const;
//- Remove points that are no longer used by any faces //- Remove points that are no longer used by any faces

View File

@ -1777,8 +1777,16 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
) const ) const
{ {
patchNames = geometryToConformTo_.patchNames(); patchNames = geometryToConformTo_.patchNames();
patchTypes.setSize(patchNames.size(), wallPolyPatch::typeName); patchTypes.setSize(patchNames.size() + 1, wallPolyPatch::typeName);
procNeighbours.setSize(patchNames.size(), -1); procNeighbours.setSize(patchNames.size() + 1, -1);
patchNames.setSize(patchNames.size() + 1);
label defaultPatchIndex = patchNames.size() - 1;
patchTypes[defaultPatchIndex] = wallPolyPatch::typeName;
procNeighbours[defaultPatchIndex] = -1;
patchNames[defaultPatchIndex] = "cvMesh_defaultPatch";
label nProcPatches = 0; label nProcPatches = 0;
@ -1836,16 +1844,6 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
} }
} }
patchTypes.setSize(patchNames.size() + 1);
procNeighbours.setSize(patchNames.size() + 1);
patchNames.setSize(patchNames.size() + 1);
label defaultPatchIndex = patchNames.size() - 1;
patchTypes[defaultPatchIndex] = wallPolyPatch::typeName;
procNeighbours[defaultPatchIndex] = -1;
patchNames[defaultPatchIndex] = "cvMesh_defaultPatch";
// Pout<< patchTypes << " " << patchNames << endl; // Pout<< patchTypes << " " << patchNames << endl;
label nPatches = patchNames.size(); label nPatches = patchNames.size();
@ -1996,7 +1994,7 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
if (!patchFaces[defaultPatchIndex].empty()) if (!patchFaces[defaultPatchIndex].empty())
{ {
Info<< nl << patchFaces[defaultPatchIndex].size() Pout<< nl << patchFaces[defaultPatchIndex].size()
<< " faces were not able to have their patch determined from " << " faces were not able to have their patch determined from "
<< "the surface. " << "the surface. "
<< nl << "Adding to patch " << patchNames[defaultPatchIndex] << nl << "Adding to patch " << patchNames[defaultPatchIndex]
@ -2027,14 +2025,10 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
nInternalFaces, nInternalFaces,
faces, faces,
owner, owner,
patchTypes,
patchNames,
patchSizes, patchSizes,
patchStarts, patchStarts,
procNeighbours,
patchFaces, patchFaces,
patchOwners, patchOwners
includeEmptyPatches
); );
} }
@ -2293,95 +2287,26 @@ void Foam::conformalVoronoiMesh::addPatches
const label nInternalFaces, const label nInternalFaces,
faceList& faces, faceList& faces,
labelList& owner, labelList& owner,
wordList& patchTypes,
wordList& patchNames,
labelList& patchSizes, labelList& patchSizes,
labelList& patchStarts, labelList& patchStarts,
labelList& procNeighbours,
List<DynamicList<face> >& patchFaces, List<DynamicList<face> >& patchFaces,
List<DynamicList<label> >& patchOwners, List<DynamicList<label> >& patchOwners
bool includeEmptyPatches
) const ) const
{ {
// Always write out all patches in parallel label nPatches = patchFaces.size();
if (Pstream::parRun())
{
includeEmptyPatches = true;
}
label nTotalPatches = patchNames.size(); patchSizes.setSize(nPatches, -1);
patchStarts.setSize(nPatches, -1);
label nValidPatches = 0;
PackedBoolList validPatch(nTotalPatches, false);
wordList allPatchTypes = patchTypes;
wordList allPatchNames = patchNames;
labelList allProcNeighbours = procNeighbours;
patchSizes.setSize(nTotalPatches, -1);
patchStarts.setSize(nTotalPatches, -1);
label nBoundaryFaces = 0; label nBoundaryFaces = 0;
forAll(patchFaces, p) forAll(patchFaces, p)
{ {
// Check if the patch has any faces. Never create an empty patchSizes[p] = patchFaces[p].size();
// default patch. patchStarts[p] = nInternalFaces + nBoundaryFaces;
if nBoundaryFaces += patchSizes[p];
(
patchFaces[p].size()
|| (includeEmptyPatches && (p != nTotalPatches - 1))
)
{
patchTypes[nValidPatches] = allPatchTypes[p];
patchNames[nValidPatches] = allPatchNames[p];
procNeighbours[nValidPatches] = allProcNeighbours[p];
patchSizes[nValidPatches] = patchFaces[p].size();
patchStarts[nValidPatches] = nInternalFaces + nBoundaryFaces;
nBoundaryFaces += patchSizes[nValidPatches];
nValidPatches++;
validPatch[p] = 1;
} }
else
{
// // Warn if a patch is empty and includeEmptyPatches is
// // false, unless it is the default patch or a processor patch
// if (p != nTotalPatches - 1 && procNeighbours[p] < 0)
// {
// WarningIn
// (
// "void Foam::conformalVoronoiMesh::addPatches"
// "("
// "const label nInternalFaces,"
// "faceList& faces,"
// "labelList& owner,"
// "wordList& patchTypes,"
// "wordList& patchNames,"
// "labelList& patchSizes,"
// "labelList& patchStarts,"
// "labelList& procNeighbours,"
// "List<DynamicList<face> >& patchFaces,"
// "List<DynamicList<label> >& patchOwners,"
// "bool includeEmptyPatches"
// ") const"
// )
// << "Patch " << patchNames[p]
// << " has no faces, not creating." << endl;
// }
}
}
patchTypes.setSize(nValidPatches);
patchNames.setSize(nValidPatches);
procNeighbours.setSize(nValidPatches);
patchSizes.setSize(nValidPatches);
patchStarts.setSize(nValidPatches);
faces.setSize(nInternalFaces + nBoundaryFaces); faces.setSize(nInternalFaces + nBoundaryFaces);
owner.setSize(nInternalFaces + nBoundaryFaces); owner.setSize(nInternalFaces + nBoundaryFaces);
@ -2389,8 +2314,6 @@ void Foam::conformalVoronoiMesh::addPatches
label faceI = nInternalFaces; label faceI = nInternalFaces;
forAll(patchFaces, p) forAll(patchFaces, p)
{
if (validPatch[p])
{ {
forAll(patchFaces[p], f) forAll(patchFaces[p], f)
{ {
@ -2400,7 +2323,6 @@ void Foam::conformalVoronoiMesh::addPatches
faceI++; faceI++;
} }
} }
}
} }

View File

@ -511,9 +511,7 @@ bool Foam::conformalVoronoiMesh::clipLineToBox
else else
{ {
// b is outside, clip b to bounding box. // b is outside, clip b to bounding box.
intersects = box.intersects(b, a, boxPt); intersects = box.intersects(b, a, boxPt);
b = boxPt; b = boxPt;
} }
} }
@ -523,9 +521,7 @@ bool Foam::conformalVoronoiMesh::clipLineToBox
if (box.posBits(b) == 0) if (box.posBits(b) == 0)
{ {
// b is inside // b is inside
intersects = box.intersects(a, b, boxPt); intersects = box.intersects(a, b, boxPt);
a = boxPt; a = boxPt;
} }
else else
@ -537,9 +533,7 @@ bool Foam::conformalVoronoiMesh::clipLineToBox
if (intersects) if (intersects)
{ {
a = boxPt; a = boxPt;
box.intersects(b, a, boxPt); box.intersects(b, a, boxPt);
b = boxPt; b = boxPt;
} }
} }
@ -563,16 +557,14 @@ void Foam::conformalVoronoiMesh::buildParallelInterface
} }
{ {
// Update the bounds of the domain // Update the processorMeshBounds
Info<< "USING SINGLE PROCESSOR PER DOMAIN" << endl;
DynamicList<Foam::point> parallelAllPoints; DynamicList<Foam::point> parallelAllPoints;
DynamicList<label> targetProcessor; DynamicList<label> targetProcessor;
DynamicList<label> parallelAllIndices; DynamicList<label> parallelAllIndices;
Foam::point minPt(VGREAT, VGREAT, VGREAT); Foam::point minPt = geometryToConformTo_.bounds().min();
Foam::point maxPt(-VGREAT, -VGREAT, -VGREAT); Foam::point maxPt = geometryToConformTo_.bounds().max();
for for
( (
@ -590,35 +582,27 @@ void Foam::conformalVoronoiMesh::buildParallelInterface
} }
} }
Pout<< "Before processorDomains update" treeBoundBox& procMeshBb =
<< geometryToConformTo_.processorDomains()[Pstream::myProcNo()] geometryToConformTo_.processorMeshBounds()[Pstream::myProcNo()];
<< endl;
geometryToConformTo_.processorDomains()[Pstream::myProcNo()][0] = Pout<< "Before processorMeshBounds update" << procMeshBb << endl;
treeBoundBox(minPt, maxPt);
Pout<< "After processorDomains update" procMeshBb = treeBoundBox(minPt, maxPt);
<< geometryToConformTo_.processorDomains()[Pstream::myProcNo()]
<< endl; Pout<< "After processorMeshBounds update" << procMeshBb << endl;
{ {
OFstream str OFstream str
( (
runTime_.path() runTime_.path()
/"procDomainUpdated_" /"processorMeshBoundsUpdated_"
+ name(Pstream::myProcNo()) + name(Pstream::myProcNo())
+ "_bounds.obj" + "_bounds.obj"
); );
Pout<< "Writing " << str.name() << endl; Pout<< "Writing " << str.name() << endl;
pointField bbPoints pointField bbPoints(procMeshBb.points());
(
geometryToConformTo_.processorDomains()
[
Pstream::myProcNo()
][0].points()
);
forAll(bbPoints, i) forAll(bbPoints, i)
{ {
@ -638,9 +622,9 @@ void Foam::conformalVoronoiMesh::buildParallelInterface
} }
} }
Pstream::gatherList(geometryToConformTo_.processorDomains()); Pstream::gatherList(geometryToConformTo_.processorMeshBounds());
Pstream::scatterList(geometryToConformTo_.processorDomains()); Pstream::scatterList(geometryToConformTo_.processorMeshBounds());
} }
boolList sendToProc(Pstream::nProcs(), false); boolList sendToProc(Pstream::nProcs(), false);
@ -1214,19 +1198,15 @@ void Foam::conformalVoronoiMesh::parallelInterfaceInfluence
// Pout<< nl << "# circumradius " << sqrt(circumradiusSqr) << endl; // Pout<< nl << "# circumradius " << sqrt(circumradiusSqr) << endl;
// drawDelaunayCell(Pout, cit); // drawDelaunayCell(Pout, cit);
forAll(geometryToConformTo_.processorDomains(), procI) forAll(geometryToConformTo_.processorMeshBounds(), procI)
{ {
if (procI == Pstream::myProcNo()) if (procI == Pstream::myProcNo())
{ {
continue; continue;
} }
const treeBoundBoxList& procBbs = const treeBoundBox& procBb =
geometryToConformTo_.processorDomains()[procI]; geometryToConformTo_.processorMeshBounds()[procI];
forAll(procBbs, pBI)
{
const treeBoundBox& procBb = procBbs[pBI];
if (procBb.overlaps(circumcentre, circumradiusSqr)) if (procBb.overlaps(circumcentre, circumradiusSqr))
{ {
@ -1236,7 +1216,6 @@ void Foam::conformalVoronoiMesh::parallelInterfaceInfluence
} }
} }
} }
}
} }
@ -1774,6 +1753,11 @@ void Foam::conformalVoronoiMesh::addSurfaceAndEdgeHits
if (edHit.hit()) if (edHit.hit())
{ {
if(!geometryToConformTo_.positionOnThisProc(edHit.hitPoint()))
{
continue;
}
if (!nearFeaturePt(edHit.hitPoint())) if (!nearFeaturePt(edHit.hitPoint()))
{ {
if if

View File

@ -49,6 +49,7 @@ Foam::conformationSurfaces::conformationSurfaces
spanMag_(), spanMag_(),
spanMagSqr_(), spanMagSqr_(),
processorDomains_(), processorDomains_(),
processorMeshBounds_(),
referenceVolumeTypes_(0) referenceVolumeTypes_(0)
{ {
const dictionary& surfacesDict const dictionary& surfacesDict
@ -248,6 +249,8 @@ Foam::conformationSurfaces::conformationSurfaces
{ {
processorDomains_.setSize(Pstream::nProcs()); processorDomains_.setSize(Pstream::nProcs());
processorMeshBounds_.setSize(Pstream::nProcs());
if (Pstream::nProcs() == 2) if (Pstream::nProcs() == 2)
{ {
processorDomains_[Pstream::myProcNo()] = treeBoundBoxList(4); processorDomains_[Pstream::myProcNo()] = treeBoundBoxList(4);
@ -273,9 +276,7 @@ Foam::conformationSurfaces::conformationSurfaces
bounds_ = treeBoundBox(allBbPoints); bounds_ = treeBoundBox(allBbPoints);
// Replace 4 bound boxes with one
processorDomains_[Pstream::myProcNo()] =
treeBoundBoxList(1, bounds_);
} }
else if (Pstream::nProcs() == 8) else if (Pstream::nProcs() == 8)
{ {
@ -299,9 +300,13 @@ Foam::conformationSurfaces::conformationSurfaces
<< exit(FatalError); << exit(FatalError);
} }
Pstream::gatherList(processorDomains_); processorMeshBounds_[Pstream::myProcNo()] = bounds_;
Pstream::gatherList(processorDomains_);
Pstream::scatterList(processorDomains_); Pstream::scatterList(processorDomains_);
Pstream::gatherList(processorMeshBounds_);
Pstream::scatterList(processorMeshBounds_);
} }
else else
{ {

View File

@ -103,9 +103,13 @@ class conformationSurfaces
scalar spanMagSqr_; scalar spanMagSqr_;
//- All of the treeBoundBoxes representing volumes held by all //- All of the treeBoundBoxes representing volumes held by all
// processors // processors. A non-overlapping set of volumes.
List<treeBoundBoxList> processorDomains_; List<treeBoundBoxList> processorDomains_;
//- The bounds of the mesh on each processor - can overlap as the mesh
// is generated, used to determine which vertices to refer.
treeBoundBoxList processorMeshBounds_;
//- The pattern/signature of volumeTypes representing a point in the //- The pattern/signature of volumeTypes representing a point in the
// domain to be meshed // domain to be meshed
List<searchableSurface::volumeType> referenceVolumeTypes_; List<searchableSurface::volumeType> referenceVolumeTypes_;
@ -166,12 +170,15 @@ public:
//- Return spanSqr //- Return spanSqr
inline scalar spanMagSqr() const; inline scalar spanMagSqr() const;
//- Return non-const access to the processorDomains
inline List<treeBoundBoxList>& processorDomains();
//- Return the processorDomains //- Return the processorDomains
inline const List<treeBoundBoxList>& processorDomains() const; inline const List<treeBoundBoxList>& processorDomains() const;
//- Return the processorMeshBounds
inline const treeBoundBoxList& processorMeshBounds() const;
//- Return non-const access to the processorMeshBounds
inline treeBoundBoxList& processorMeshBounds();
// Query // Query

View File

@ -74,13 +74,6 @@ inline Foam::scalar Foam::conformationSurfaces::spanMagSqr() const
} }
inline Foam::List<Foam::treeBoundBoxList>&
Foam::conformationSurfaces::processorDomains()
{
return processorDomains_;
}
inline const Foam::List<Foam::treeBoundBoxList>& inline const Foam::List<Foam::treeBoundBoxList>&
Foam::conformationSurfaces::processorDomains() const Foam::conformationSurfaces::processorDomains() const
{ {
@ -88,4 +81,17 @@ Foam::conformationSurfaces::processorDomains() const
} }
inline const Foam::treeBoundBoxList&
Foam::conformationSurfaces::processorMeshBounds() const
{
return processorMeshBounds_;
}
inline Foam::treeBoundBoxList& Foam::conformationSurfaces::processorMeshBounds()
{
return processorMeshBounds_;
}
// ************************************************************************* // // ************************************************************************* //