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 2dbac062ae..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