diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C index 0c524920af..0955585f5e 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C @@ -27,7 +27,7 @@ License #include "mapDistribute.H" #include "commSchedule.H" #include "HashSet.H" -#include "ListOps.H" +#include "globalIndex.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -257,6 +257,292 @@ Foam::mapDistribute::mapDistribute } +Foam::mapDistribute::mapDistribute +( + const globalIndex& globalNumbering, + labelList& elements, + List >& compactMap +) +: + constructSize_(0), + schedulePtr_() +{ + // 1. Construct per processor compact addressing of the global elements + // needed. The ones from the local processor are not included since + // these are always all needed. + compactMap.setSize(Pstream::nProcs()); + { + // Count all (non-local) elements needed. Just for presizing map. + labelList nNonLocal(Pstream::nProcs(), 0); + + forAll(elements, i) + { + label globalIndex = elements[i]; + + if (!globalNumbering.isLocal(globalIndex)) + { + label procI = globalNumbering.whichProcID(globalIndex); + nNonLocal[procI]++; + } + } + + forAll(compactMap, procI) + { + if (procI != Pstream::myProcNo()) + { + compactMap[procI].resize(2*nNonLocal[procI]); + } + } + + + // Collect all (non-local) elements needed. + forAll(elements, i) + { + label globalIndex = elements[i]; + + if (!globalNumbering.isLocal(globalIndex)) + { + label procI = globalNumbering.whichProcID(globalIndex); + label index = globalNumbering.toLocal(procI, globalIndex); + label nCompact = compactMap[procI].size(); + compactMap[procI].insert(index, nCompact); + } + } + + //// Sort remote elements needed (not really necessary) + //forAll(compactMap, procI) + //{ + // if (procI != Pstream::myProcNo()) + // { + // Map