From 2877964cb64ff8dfbfd6fe09232e9272a92f7350 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Wed, 9 May 2018 12:55:16 +0100 Subject: [PATCH] Global face index handling in passive processor patches --- .../finiteVolume/domainDecomposition.C | 22 ++++++++++++-- .../finiteVolume/domainDecomposition.H | 4 +++ .../passiveProcessorPolyPatch.C | 29 +++++++++++++++---- .../passiveProcessorPolyPatch.H | 12 +++++++- 4 files changed, 58 insertions(+), 9 deletions(-) diff --git a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.C b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.C index a873dceb2..ed03b62eb 100644 --- a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.C +++ b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.C @@ -32,7 +32,6 @@ License #include "fvMesh.H" #include "OSspecific.H" #include "Map.H" -#include "globalMeshData.H" #include "DynamicList.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -52,6 +51,7 @@ Foam::domainDecomposition::domainDecomposition decompositionDict_(dict), nProcs_(readInt(decompositionDict_.lookup("numberOfSubdomains"))), distributed_(false), + gfIndex_(mesh_), cellToProc_(mesh_.nCells()), patchNbrCellToProc_(mesh_.boundaryMesh().size()), procPointAddressing_(nProcs_), @@ -269,8 +269,25 @@ Foam::autoPtr Foam::domainDecomposition::processorMesh if (createPassiveProcPatches) { + // Creation of passiveProcessor patches requires a global face index + + // Get global index + const labelList& globalIndex = gfIndex_.globalLabel(); + forAll (curProcessorPatchSizes, procPatchI) { + // Assemble the global face index for all passive processor patch + // faces + labelList patchGlobalIndex(curProcessorPatchSizes[procPatchI]); + + const label curPatchStart = curProcessorPatchStarts[procPatchI]; + + forAll (patchGlobalIndex, fI) + { + patchGlobalIndex[fI] = + globalIndex[mag(curFaceLabels[curPatchStart + fI]) - 1]; + } + procPatches[nPatches] = new passiveProcessorPolyPatch ( @@ -282,7 +299,8 @@ Foam::autoPtr Foam::domainDecomposition::processorMesh nPatches, procMesh.boundaryMesh(), procI, - curNeighbourProcessors[procPatchI] + curNeighbourProcessors[procPatchI], + patchGlobalIndex ); nPatches++; diff --git a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.H b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.H index 88f1fb572..baa87b319 100644 --- a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.H +++ b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.H @@ -42,6 +42,7 @@ SourceFiles #include "SLList.H" #include "PtrList.H" #include "point.H" +#include "globalProcFaceIndex.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -68,6 +69,9 @@ class domainDecomposition //- Is the decomposition data to be distributed for each processor bool distributed_; + //- Global face index + globalProcFaceIndex gfIndex_; + //- Processor label for each cell labelList cellToProc_; diff --git a/src/decompositionMethods/decomposeReconstruct/passivePatches/passiveProcessorPolyPatch/passiveProcessorPolyPatch.C b/src/decompositionMethods/decomposeReconstruct/passivePatches/passiveProcessorPolyPatch/passiveProcessorPolyPatch.C index 5c445eef1..60c0f8638 100644 --- a/src/decompositionMethods/decomposeReconstruct/passivePatches/passiveProcessorPolyPatch/passiveProcessorPolyPatch.C +++ b/src/decompositionMethods/decomposeReconstruct/passivePatches/passiveProcessorPolyPatch/passiveProcessorPolyPatch.C @@ -60,13 +60,25 @@ Foam::passiveProcessorPolyPatch::passiveProcessorPolyPatch const label index, const polyBoundaryMesh& bm, const int myProcNo, - const int neighbProcNo + const int neighbProcNo, + const labelList& globalFaceIndex ) : polyPatch(name, size, start, index, bm), myProcNo_(myProcNo), - neighbProcNo_(neighbProcNo) -{} + neighbProcNo_(neighbProcNo), + globalFaceIndex_(globalFaceIndex) +{ + if (globalFaceIndex.size() != size) + { + FatalErrorIn + ( + "passiveProcessorPolyPatch::passiveProcessorPolyPatch(...)" + ) << "Bad global index list. Patch size: " << this->size() + << " global index size: " << globalFaceIndex.size() + << abort(FatalError); + } +} Foam::passiveProcessorPolyPatch::passiveProcessorPolyPatch @@ -79,7 +91,8 @@ Foam::passiveProcessorPolyPatch::passiveProcessorPolyPatch : polyPatch(name, dict, index, bm), myProcNo_(readLabel(dict.lookup("myProcNo"))), - neighbProcNo_(readLabel(dict.lookup("neighbProcNo"))) + neighbProcNo_(readLabel(dict.lookup("neighbProcNo"))), + globalFaceIndex_(dict.lookup("globalFaceIndex")) {} @@ -91,7 +104,8 @@ Foam::passiveProcessorPolyPatch::passiveProcessorPolyPatch : polyPatch(pp, bm), myProcNo_(pp.myProcNo_), - neighbProcNo_(pp.neighbProcNo_) + neighbProcNo_(pp.neighbProcNo_), + globalFaceIndex_(pp.size(), -1) {} @@ -106,7 +120,8 @@ Foam::passiveProcessorPolyPatch::passiveProcessorPolyPatch : polyPatch(pp, bm, index, newSize, newStart), myProcNo_(pp.myProcNo_), - neighbProcNo_(pp.neighbProcNo_) + neighbProcNo_(pp.neighbProcNo_), + globalFaceIndex_(newSize, -1) // Cannot set global index. HJ, 4/May/2018 {} @@ -125,6 +140,8 @@ void Foam::passiveProcessorPolyPatch::write(Ostream& os) const << token::END_STATEMENT << nl; os.writeKeyword("neighbProcNo") << neighbProcNo_ << token::END_STATEMENT << nl; + + globalFaceIndex_.writeEntry("globalFaceIndex", os); } diff --git a/src/decompositionMethods/decomposeReconstruct/passivePatches/passiveProcessorPolyPatch/passiveProcessorPolyPatch.H b/src/decompositionMethods/decomposeReconstruct/passivePatches/passiveProcessorPolyPatch/passiveProcessorPolyPatch.H index 134fe30e2..9818cf479 100644 --- a/src/decompositionMethods/decomposeReconstruct/passivePatches/passiveProcessorPolyPatch/passiveProcessorPolyPatch.H +++ b/src/decompositionMethods/decomposeReconstruct/passivePatches/passiveProcessorPolyPatch/passiveProcessorPolyPatch.H @@ -65,6 +65,9 @@ class passiveProcessorPolyPatch //- Neighbour processor number int neighbProcNo_; + //- Global processor face index + labelList globalFaceIndex_; + public: @@ -83,7 +86,8 @@ public: const label index, const polyBoundaryMesh& bm, const int myProcNo, - const int neighbProcNo + const int neighbProcNo, + const labelList& globalFaceIndex ); //- Construct from dictionary @@ -161,6 +165,12 @@ public: return neighbProcNo_; } + //- Return global processor face index + const labelList& globalFaceIndex() const + { + return globalFaceIndex_; + } + //- Write the polyPatch data as a dictionary virtual void write(Ostream&) const; };