From 9025a4d66fea8c87eb913217898f9a4e758362b8 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 7 Aug 2013 09:58:29 +0100 Subject: [PATCH 1/7] BUG: decompositionMethod: enforce explicitConnections to be on same proc --- .../decompositionMethod/decompositionMethod.C | 45 +++++++++++++++++++ .../decompositionMethod/decompositionMethod.H | 7 ++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C index a04edc3149..53baa65b18 100644 --- a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C +++ b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C @@ -884,6 +884,51 @@ Foam::labelList Foam::decompositionMethod::decompose ); + + // Implement the explicitConnections since above decompose + // does not know about them + forAll(explicitConnections, i) + { + const labelPair& baffle = explicitConnections[i]; + label f0 = baffle.first(); + label f1 = baffle.second(); + + if (!blockedFace[f0] && !blockedFace[f1]) + { + // Note: what if internal faces and owner and neighbour on + // different processor? So for now just push owner side + // proc + + const label procI = finalDecomp[mesh.faceOwner()[f0]]; + + finalDecomp[mesh.faceOwner()[f1]] = procI; + if (mesh.isInternalFace(f1)) + { + finalDecomp[mesh.faceNeighbour()[f1]] = procI; + } + } + else if (blockedFace[f0] != blockedFace[f1]) + { + FatalErrorIn + ( + "labelList decompose\n" + "(\n" + " const polyMesh&,\n" + " const scalarField&,\n" + " const boolList&,\n" + " const PtrList&,\n" + " const labelList&,\n" + " const List&\n" + ")" + ) << "On explicit connection between faces " << f0 + << " and " << f1 + << " the two blockedFace status are not equal : " + << blockedFace[f0] << " and " << blockedFace[f1] + << exit(FatalError); + } + } + + // For specifiedProcessorFaces rework the cellToProc to enforce // all on one processor since we can't guarantee that the input // to regionSplit was a single region. diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H index 43e538dc4e..638cbcb59b 100644 --- a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H +++ b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H @@ -266,13 +266,16 @@ public: ); // Decompose a mesh with constraints: - // - blockedFace : whether owner and neighbour should be on + // - blockedFace : whether owner and neighbour should be on same + // processor // - specifiedProcessorFaces, specifiedProcessor : sets of faces // that should go to same processor (as specified in // specifiedProcessor, can be -1) // - explicitConnections : connections between baffle faces + // (blockedFace should be false on these). Owner and + // neighbour on same processor. // Set all to zero size to have unconstrained decomposition. - labelList decompose + virtual labelList decompose ( const polyMesh& mesh, const scalarField& cellWeights, From 4298a4c0a082562adf06adbba8b1d6f357072d83 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 7 Aug 2013 10:00:10 +0100 Subject: [PATCH 2/7] STYLE: meshRefinementMerge: ordering --- .../autoMesh/autoHexMesh/meshRefinement/meshRefinementMerge.C | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementMerge.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementMerge.C index ea4e0b3cec..4fc1b40077 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementMerge.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementMerge.C @@ -293,11 +293,13 @@ Foam::label Foam::meshRefinement::mergePatchFacesUndo ) ); + // Filter out any set that contains any preserveFace label compactI = 0; forAll(allFaceSets, i) { - bool keep = true; const labelList& set = allFaceSets[i]; + + bool keep = true; forAll(set, j) { if (preserveFaces[set[j]] != -1) From 431fea984475b733d9c2a47a30f63aa687c7862d Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 7 Aug 2013 10:01:35 +0100 Subject: [PATCH 3/7] BUG: meshRefinement: make sure blockedFace not set on couples --- .../autoMesh/autoHexMesh/meshRefinement/meshRefinement.C | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C index 2dbac062ae..041e08cdad 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C @@ -1375,6 +1375,15 @@ Foam::autoPtr Foam::meshRefinement::balance // ); //} + + // Make sure blockedFace not set on couples + forAll(couples, i) + { + const labelPair& baffle = couples[i]; + blockedFace[baffle.first()] = false; + blockedFace[baffle.second()] = false; + } + distribution = decomposer.decompose ( mesh_, From f9139aa0317b66b8f5337b73c9cdb6376f55bece Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 7 Aug 2013 11:03:01 +0100 Subject: [PATCH 4/7] ENH: decomposePar: added logic for preserving baffles --- .../decomposePar/decomposeParDict | 5 + .../meshRefinement/meshRefinement.C | 52 +++++++-- .../decompositionMethods/Make/options | 2 + .../decompositionMethod/decompositionMethod.C | 103 ++++++++++++++++-- .../decompositionMethod/decompositionMethod.H | 10 +- 5 files changed, 152 insertions(+), 20 deletions(-) diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposeParDict b/applications/utilities/parallelProcessing/decomposePar/decomposeParDict index 6a27bdfb2c..39483a01e3 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposeParDict +++ b/applications/utilities/parallelProcessing/decomposePar/decomposeParDict @@ -33,6 +33,11 @@ numberOfSubdomains 2; //singleProcessorFaceSets ((f0 -1)); +//- Keep owner and neighbour of baffles on same processor (i.e. keep it +// detectable as a baffle). Baffles are two boundary face sharing the +// same points. +//preserveBaffles true; + //- Use the volScalarField named here as a weight for each cell in the // decomposition. For example, use a particle population field to decompose // for a balanced number of particles in a lagrangian simulation. diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C index 041e08cdad..123fd22281 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C @@ -1209,18 +1209,19 @@ Foam::autoPtr Foam::meshRefinement::balance PtrList specifiedProcessorFaces; labelList specifiedProcessor; + // Pairs of baffles + List couples; + // Constraints from decomposeParDict decomposer.setConstraints ( mesh_, blockedFace, specifiedProcessorFaces, - specifiedProcessor + specifiedProcessor, + couples ); - // Pairs of baffles - List couples; - if (keepZoneFaces || keepBaffles) { @@ -1314,12 +1315,43 @@ Foam::autoPtr Foam::meshRefinement::balance if (keepBaffles) { - // Get boundary baffles that need to stay together. - couples = getDuplicateFaces // all baffles - ( - identity(mesh_.nFaces()-mesh_.nInternalFaces()) - +mesh_.nInternalFaces() - ); + label nBnd = mesh_.nFaces()-mesh_.nInternalFaces(); + + labelList coupledFace(mesh_.nFaces(), -1); + { + // Get boundary baffles that need to stay together + List allCouples = getDuplicateFaces + ( + identity(nBnd) + +mesh_.nInternalFaces() + ); + + // Merge with any couples from + // decompositionMethod::setConstraints + forAll(couples, i) + { + const labelPair& baffle = couples[i]; + coupledFace[baffle.first()] = baffle.second(); + coupledFace[baffle.second()] = baffle.first(); + } + forAll(allCouples, i) + { + const labelPair& baffle = allCouples[i]; + coupledFace[baffle.first()] = baffle.second(); + coupledFace[baffle.second()] = baffle.first(); + } + } + + couples.setSize(nBnd); + label nCpl = 0; + forAll(coupledFace, faceI) + { + if (coupledFace[faceI] != -1 && faceI < coupledFace[faceI]) + { + couples[nCpl++] = labelPair(faceI, coupledFace[faceI]); + } + } + couples.setSize(nCpl); } label nCouples = returnReduce(couples.size(), sumOp