diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C index 25996770bc..f5789cb4b2 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C @@ -480,6 +480,17 @@ Foam::mapDistribute::mapDistribute } +Foam::mapDistribute::mapDistribute +( + labelListList&& subMap, + const bool subHasFlip, + const bool constructHasFlip +) +: + mapDistributeBase(std::move(subMap), subHasFlip, constructHasFlip) +{} + + Foam::mapDistribute::mapDistribute(Istream& is) { is >> *this; diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H index 7ff14d980f..701b5b3f55 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H @@ -325,10 +325,10 @@ public: mapDistribute(); //- Copy construct - mapDistribute(const mapDistribute& map); + explicit mapDistribute(const mapDistribute& map); //- Move construct - mapDistribute(mapDistribute&& map); + explicit mapDistribute(mapDistribute&& map); //- Move construct from components mapDistribute @@ -416,8 +416,18 @@ public: const int tag = Pstream::msgType() ); + //- Construct from my elements to send. Assumes layout is my elements + // first followed by elements from all other processors in consecutive + // order + mapDistribute + ( + labelListList&& subMap, + const bool subHasFlip = false, + const bool constructHasFlip = false + ); + //- Construct from Istream - mapDistribute(Istream& is); + explicit mapDistribute(Istream& is); //- Clone autoPtr clone() const; diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C index 82e425da95..3c3ee41a71 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C @@ -790,6 +790,58 @@ Foam::mapDistributeBase::mapDistributeBase } +Foam::mapDistributeBase::mapDistributeBase +( + labelListList&& subMap, + const bool subHasFlip, + const bool constructHasFlip +) +: + constructSize_(0), + subMap_(std::move(subMap)), + subHasFlip_(subHasFlip), + constructHasFlip_(constructHasFlip), + schedulePtr_() +{ + // Send over how many i need to receive. + labelList recvSizes; + Pstream::exchangeSizes(subMap_, recvSizes); + + // Determine order of receiving + labelListList constructMap(Pstream::nProcs()); + + // My local segments first + label nLocal = recvSizes[Pstream::myProcNo()]; + { + labelList& myMap = constructMap[Pstream::myProcNo()]; + myMap.setSize(nLocal); + forAll(myMap, i) + { + myMap[i] = i; + } + } + + label segmenti = nLocal; + forAll(constructMap, proci) + { + if (proci != Pstream::myProcNo()) + { + // What i need to receive is what other processor is sending to me. + label nRecv = recvSizes[proci]; + constructMap[proci].setSize(nRecv); + + for (label i = 0; i < nRecv; i++) + { + constructMap[proci][i] = segmenti++; + } + } + } + + constructSize_ = segmenti; + constructMap_.transfer(constructMap); +} + + Foam::mapDistributeBase::mapDistributeBase(Istream& is) { is >> *this; diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.H index 8e41fc0968..8e1c16bf52 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.H @@ -199,10 +199,10 @@ public: mapDistributeBase(); //- Copy construct - mapDistributeBase(const mapDistributeBase& map); + explicit mapDistributeBase(const mapDistributeBase& map); //- Move construct - mapDistributeBase(mapDistributeBase&& map); + explicit mapDistributeBase(mapDistributeBase&& map); //- Construct from components mapDistributeBase @@ -246,6 +246,16 @@ public: const int tag = Pstream::msgType() ); + //- Construct from my elements to send. Assumes layout is my elements + // first followed by elements from all other processors in consecutive + // order + mapDistributeBase + ( + labelListList&& subMap, + const bool subHasFlip = false, + const bool constructHasFlip = false + ); + //- Construct from Istream mapDistributeBase(Istream& is);