From 873c863859f213012c1c1c8711954480698f65c4 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 20 Nov 2013 13:02:52 +0000 Subject: [PATCH] ENH: decompositionMethod: cleanup of baffle handling --- src/meshTools/regionSplit/localPointRegion.C | 59 +++++ src/meshTools/regionSplit/localPointRegion.H | 4 + .../decompositionMethod/decompositionMethod.C | 226 +----------------- 3 files changed, 67 insertions(+), 222 deletions(-) diff --git a/src/meshTools/regionSplit/localPointRegion.C b/src/meshTools/regionSplit/localPointRegion.C index ddaa684987..bad9ca8d57 100644 --- a/src/meshTools/regionSplit/localPointRegion.C +++ b/src/meshTools/regionSplit/localPointRegion.C @@ -585,6 +585,65 @@ Foam::labelList Foam::localPointRegion::findDuplicateFaces } +Foam::List Foam::localPointRegion::findDuplicateFacePairs +( + const polyMesh& mesh +) +{ + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + // Faces to test: all boundary faces + labelList testFaces + ( + identity(mesh.nFaces()-mesh.nInternalFaces()) + + mesh.nInternalFaces() + ); + + // Find correspondencing baffle face (or -1) + const labelList duplicateFace(findDuplicateFaces(mesh, testFaces)); + + // Convert into list of coupled face pairs (mesh face labels). + DynamicList baffles(testFaces.size()); + + forAll(duplicateFace, i) + { + label otherFaceI = duplicateFace[i]; + + if (otherFaceI != -1 && i < otherFaceI) + { + label meshFace0 = testFaces[i]; + label patch0 = patches.whichPatch(meshFace0); + label meshFace1 = testFaces[otherFaceI]; + label patch1 = patches.whichPatch(meshFace1); + + // Check for illegal topology. Should normally not happen! + if + ( + (patch0 != -1 && isA(patches[patch0])) + || (patch1 != -1 && isA(patches[patch1])) + ) + { + FatalErrorIn + ( + "localPointRegion::findDuplicateFacePairs(const polyMesh&)" + ) << "One of two duplicate faces is on" + << " processorPolyPatch." + << "This is not allowed." << nl + << "Face:" << meshFace0 + << " is on patch:" << patches[patch0].name() + << nl + << "Face:" << meshFace1 + << " is on patch:" << patches[patch1].name() + << abort(FatalError); + } + + baffles.append(labelPair(meshFace0, meshFace1)); + } + } + return baffles.shrink(); +} + + void Foam::localPointRegion::updateMesh(const mapPolyMesh& map) { { diff --git a/src/meshTools/regionSplit/localPointRegion.H b/src/meshTools/regionSplit/localPointRegion.H index 946a402498..83bbce1e51 100644 --- a/src/meshTools/regionSplit/localPointRegion.H +++ b/src/meshTools/regionSplit/localPointRegion.H @@ -48,6 +48,7 @@ SourceFiles #include "HashSet.H" #include "faceList.H" #include "boolList.H" +#include "labelPair.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -149,6 +150,9 @@ public: const labelList& ); + //- Helper routine to find all baffles (two boundary faces + // using the same points but in reverse order) + static labelPairList findDuplicateFacePairs(const polyMesh&); // Access diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C index 4e19610373..c098db091f 100644 --- a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C +++ b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C @@ -1103,75 +1103,12 @@ void Foam::decompositionMethod::setConstraints << "Keeping owner of faces in baffles " << " on same processor." << endl; - // Faces to test: all boundary faces - labelList testFaces - ( - identity(mesh.nFaces()-mesh.nInternalFaces()) - + mesh.nInternalFaces() - ); - - // Find correspondencing baffle face (or -1) - labelList duplicateFace - ( - localPointRegion::findDuplicateFaces - ( - mesh, - testFaces - ) - ); - - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - // Convert into list of coupled face pairs (mesh face labels). - explicitConnections.setSize(testFaces.size()); - label dupI = 0; - - forAll(duplicateFace, i) + explicitConnections = localPointRegion::findDuplicateFacePairs(mesh); + forAll(explicitConnections, i) { - label otherFaceI = duplicateFace[i]; - - if (otherFaceI != -1 && i < otherFaceI) - { - label meshFace0 = testFaces[i]; - label patch0 = patches.whichPatch(meshFace0); - label meshFace1 = testFaces[otherFaceI]; - label patch1 = patches.whichPatch(meshFace1); - - // Check for illegal topology. Should normally not happen! - if - ( - (patch0 != -1 && isA(patches[patch0])) - || (patch1 != -1 && isA(patches[patch1])) - ) - { - FatalErrorIn - ( - "decompositionMethod::decompose(const polyMesh&)" - ) << "One of two duplicate faces is on" - << " processorPolyPatch." - << "This is not allowed." << nl - << "Face:" << meshFace0 - << " is on patch:" << patches[patch0].name() - << nl - << "Face:" << meshFace1 - << " is on patch:" << patches[patch1].name() - << abort(FatalError); - } - - explicitConnections[dupI++] = labelPair(meshFace0, meshFace1); - if (blockedFace[meshFace0]) - { - blockedFace[meshFace0] = false; - //nUnblocked++; - } - if (blockedFace[meshFace1]) - { - blockedFace[meshFace1] = false; - //nUnblocked++; - } - } + blockedFace[explicitConnections[i].first()] = false; + blockedFace[explicitConnections[i].second()] = false; } - explicitConnections.setSize(dupI); } if @@ -1256,161 +1193,6 @@ Foam::labelList Foam::decompositionMethod::decompose const scalarField& cellWeights ) { - //labelHashSet sameProcFaces; - // - //if (decompositionDict_.found("preservePatches")) - //{ - // wordList pNames(decompositionDict_.lookup("preservePatches")); - // - // Info<< nl - // << "Keeping owner of faces in patches " << pNames - // << " on same processor. This only makes sense for cyclics." - // << endl; - // - // const polyBoundaryMesh& patches = mesh.boundaryMesh(); - // - // forAll(pNames, i) - // { - // const label patchI = patches.findPatchID(pNames[i]); - // - // if (patchI == -1) - // { - // FatalErrorIn - // ( - // "decompositionMethod::decompose(const polyMesh&)") - // << "Unknown preservePatch " << pNames[i] - // << endl << "Valid patches are " << patches.names() - // << exit(FatalError); - // } - // - // const polyPatch& pp = patches[patchI]; - // - // forAll(pp, i) - // { - // sameProcFaces.insert(pp.start() + i); - // } - // } - //} - //if (decompositionDict_.found("preserveFaceZones")) - //{ - // wordList zNames(decompositionDict_.lookup("preserveFaceZones")); - // - // Info<< nl - // << "Keeping owner and neighbour of faces in zones " << zNames - // << " on same processor" << endl; - // - // const faceZoneMesh& fZones = mesh.faceZones(); - // - // forAll(zNames, i) - // { - // label zoneI = fZones.findZoneID(zNames[i]); - // - // if (zoneI == -1) - // { - // FatalErrorIn - // ("decompositionMethod::decompose(const polyMesh&)") - // << "Unknown preserveFaceZone " << zNames[i] - // << endl << "Valid faceZones are " << fZones.names() - // << exit(FatalError); - // } - // - // const faceZone& fz = fZones[zoneI]; - // - // forAll(fz, i) - // { - // sameProcFaces.insert(fz[i]); - // } - // } - //} - // - // - //// Specified processor for group of cells connected to faces - // - ////- Sets of faces to move together - //PtrList specifiedProcessorFaces; - ////- Destination processor - //labelList specifiedProcessor; - // - //label nProcSets = 0; - //if (decompositionDict_.found("singleProcessorFaceSets")) - //{ - // List > zNameAndProcs - // ( - // decompositionDict_.lookup("singleProcessorFaceSets") - // ); - // - // specifiedProcessorFaces.setSize(zNameAndProcs.size()); - // specifiedProcessor.setSize(zNameAndProcs.size()); - // - // forAll(zNameAndProcs, setI) - // { - // Info<< "Keeping all cells connected to faceSet " - // << zNameAndProcs[setI].first() - // << " on processor " << zNameAndProcs[setI].second() << endl; - // - // // Read faceSet - // faceSet fz(mesh, zNameAndProcs[setI].first()); - // - // specifiedProcessorFaces.set(setI, new labelList(fz.sortedToc())); - // specifiedProcessor[setI] = zNameAndProcs[setI].second(); - // nProcSets += fz.size(); - // } - // reduce(nProcSets, sumOp