From b6071774f28ab80e9012fb6eeb4d9e3cbf69c0f0 Mon Sep 17 00:00:00 2001 From: graham Date: Fri, 22 Apr 2011 15:42:40 +0100 Subject: [PATCH] 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. --- .../conformalVoronoiMesh.H | 9 +- .../conformalVoronoiMeshCalcDualMesh.C | 124 ++++-------------- .../conformalVoronoiMeshConformToSurface.C | 66 ++++------ .../conformationSurfaces.C | 13 +- .../conformationSurfaces.H | 15 ++- .../conformationSurfacesI.H | 20 ++- 6 files changed, 83 insertions(+), 164 deletions(-) diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index a3db0f7657..85bb438e17 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H @@ -725,21 +725,16 @@ private: List > >& 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 >& patchFaces, - List >& patchOwners, - bool includeEmptyPatches + List >& patchOwners ) const; //- Remove points that are no longer used by any faces diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index ee0ea7c5fd..c35e077169 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -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 >& patchFaces, - List >& patchOwners, - bool includeEmptyPatches + List >& 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 >& patchFaces," - // "List >& 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++; } } } diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C index 7777a7e6cf..9bb0a96adf 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C @@ -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 parallelAllPoints; DynamicList