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
) const;
//- Add the faces and owner information for the patches,
// optionally removing any zero-size patches
//- Add the faces and owner information for the patches
void 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
List<DynamicList<label> >& patchOwners
) const;
//- Remove points that are no longer used by any faces

View File

@ -1777,8 +1777,16 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
) const
{
patchNames = geometryToConformTo_.patchNames();
patchTypes.setSize(patchNames.size(), wallPolyPatch::typeName);
procNeighbours.setSize(patchNames.size(), -1);
patchTypes.setSize(patchNames.size() + 1, wallPolyPatch::typeName);
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;
@ -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;
label nPatches = patchNames.size();
@ -1996,7 +1994,7 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
if (!patchFaces[defaultPatchIndex].empty())
{
Info<< nl << patchFaces[defaultPatchIndex].size()
Pout<< nl << patchFaces[defaultPatchIndex].size()
<< " faces were not able to have their patch determined from "
<< "the surface. "
<< nl << "Adding to patch " << patchNames[defaultPatchIndex]
@ -2027,14 +2025,10 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
nInternalFaces,
faces,
owner,
patchTypes,
patchNames,
patchSizes,
patchStarts,
procNeighbours,
patchFaces,
patchOwners,
includeEmptyPatches
patchOwners
);
}
@ -2293,96 +2287,27 @@ 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
List<DynamicList<label> >& patchOwners
) const
{
// Always write out all patches in parallel
if (Pstream::parRun())
{
includeEmptyPatches = true;
}
label nPatches = patchFaces.size();
label nTotalPatches = patchNames.size();
label nValidPatches = 0;
PackedBoolList validPatch(nTotalPatches, false);
wordList allPatchTypes = patchTypes;
wordList allPatchNames = patchNames;
labelList allProcNeighbours = procNeighbours;
patchSizes.setSize(nTotalPatches, -1);
patchStarts.setSize(nTotalPatches, -1);
patchSizes.setSize(nPatches, -1);
patchStarts.setSize(nPatches, -1);
label nBoundaryFaces = 0;
forAll(patchFaces, p)
{
// Check if the patch has any faces. Never create an empty
// default patch.
patchSizes[p] = patchFaces[p].size();
patchStarts[p] = nInternalFaces + nBoundaryFaces;
if
(
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;
// }
}
nBoundaryFaces += patchSizes[p];
}
patchTypes.setSize(nValidPatches);
patchNames.setSize(nValidPatches);
procNeighbours.setSize(nValidPatches);
patchSizes.setSize(nValidPatches);
patchStarts.setSize(nValidPatches);
faces.setSize(nInternalFaces + nBoundaryFaces);
owner.setSize(nInternalFaces + nBoundaryFaces);
@ -2390,15 +2315,12 @@ void Foam::conformalVoronoiMesh::addPatches
forAll(patchFaces, p)
{
if (validPatch[p])
forAll(patchFaces[p], f)
{
forAll(patchFaces[p], f)
{
faces[faceI] = patchFaces[p][f];
owner[faceI] = patchOwners[p][f];
faces[faceI] = patchFaces[p][f];
owner[faceI] = patchOwners[p][f];
faceI++;
}
faceI++;
}
}
}

View File

@ -511,9 +511,7 @@ bool Foam::conformalVoronoiMesh::clipLineToBox
else
{
// b is outside, clip b to bounding box.
intersects = box.intersects(b, a, boxPt);
b = boxPt;
}
}
@ -523,9 +521,7 @@ bool Foam::conformalVoronoiMesh::clipLineToBox
if (box.posBits(b) == 0)
{
// b is inside
intersects = box.intersects(a, b, boxPt);
a = boxPt;
}
else
@ -537,9 +533,7 @@ bool Foam::conformalVoronoiMesh::clipLineToBox
if (intersects)
{
a = boxPt;
box.intersects(b, a, boxPt);
b = boxPt;
}
}
@ -563,16 +557,14 @@ void Foam::conformalVoronoiMesh::buildParallelInterface
}
{
// Update the bounds of the domain
Info<< "USING SINGLE PROCESSOR PER DOMAIN" << endl;
// Update the processorMeshBounds
DynamicList<Foam::point> parallelAllPoints;
DynamicList<label> targetProcessor;
DynamicList<label> parallelAllIndices;
Foam::point minPt(VGREAT, VGREAT, VGREAT);
Foam::point maxPt(-VGREAT, -VGREAT, -VGREAT);
Foam::point minPt = geometryToConformTo_.bounds().min();
Foam::point maxPt = geometryToConformTo_.bounds().max();
for
(
@ -590,35 +582,27 @@ void Foam::conformalVoronoiMesh::buildParallelInterface
}
}
Pout<< "Before processorDomains update"
<< geometryToConformTo_.processorDomains()[Pstream::myProcNo()]
<< endl;
treeBoundBox& procMeshBb =
geometryToConformTo_.processorMeshBounds()[Pstream::myProcNo()];
geometryToConformTo_.processorDomains()[Pstream::myProcNo()][0] =
treeBoundBox(minPt, maxPt);
Pout<< "Before processorMeshBounds update" << procMeshBb << endl;
Pout<< "After processorDomains update"
<< geometryToConformTo_.processorDomains()[Pstream::myProcNo()]
<< endl;
procMeshBb = treeBoundBox(minPt, maxPt);
Pout<< "After processorMeshBounds update" << procMeshBb << endl;
{
OFstream str
(
runTime_.path()
/"procDomainUpdated_"
/"processorMeshBoundsUpdated_"
+ name(Pstream::myProcNo())
+ "_bounds.obj"
);
Pout<< "Writing " << str.name() << endl;
pointField bbPoints
(
geometryToConformTo_.processorDomains()
[
Pstream::myProcNo()
][0].points()
);
pointField bbPoints(procMeshBb.points());
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);
@ -1214,26 +1198,21 @@ void Foam::conformalVoronoiMesh::parallelInterfaceInfluence
// Pout<< nl << "# circumradius " << sqrt(circumradiusSqr) << endl;
// drawDelaunayCell(Pout, cit);
forAll(geometryToConformTo_.processorDomains(), procI)
forAll(geometryToConformTo_.processorMeshBounds(), procI)
{
if (procI == Pstream::myProcNo())
{
continue;
}
const treeBoundBoxList& procBbs =
geometryToConformTo_.processorDomains()[procI];
const treeBoundBox& procBb =
geometryToConformTo_.processorMeshBounds()[procI];
forAll(procBbs, pBI)
if (procBb.overlaps(circumcentre, circumradiusSqr))
{
const treeBoundBox& procBb = procBbs[pBI];
toProc[procI] = true;
if (procBb.overlaps(circumcentre, circumradiusSqr))
{
toProc[procI] = true;
break;
}
break;
}
}
}
@ -1599,7 +1578,7 @@ void Foam::conformalVoronoiMesh::limitDisplacement
if (magSqr(pt - surfHit.hitPoint()) <= searchDistanceSqr)
{
// Cannot limit displacement, point closer than tolerance
// Cannot limit displacement, point closer than tolerance
return;
}
}
@ -1774,6 +1753,11 @@ void Foam::conformalVoronoiMesh::addSurfaceAndEdgeHits
if (edHit.hit())
{
if(!geometryToConformTo_.positionOnThisProc(edHit.hitPoint()))
{
continue;
}
if (!nearFeaturePt(edHit.hitPoint()))
{
if

View File

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

View File

@ -103,9 +103,13 @@ class conformationSurfaces
scalar spanMagSqr_;
//- All of the treeBoundBoxes representing volumes held by all
// processors
// processors. A non-overlapping set of volumes.
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
// domain to be meshed
List<searchableSurface::volumeType> referenceVolumeTypes_;
@ -166,12 +170,15 @@ public:
//- Return spanSqr
inline scalar spanMagSqr() const;
//- Return non-const access to the processorDomains
inline List<treeBoundBoxList>& processorDomains();
//- Return the processorDomains
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

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>&
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_;
}
// ************************************************************************* //