60 if (subMap[proci].size())
65 if (constructMap[proci].size())
72 allComms = commsSet.
toc();
92 if (
findIndex(allComms, nbrData[i]) == -1)
96 allComms[sz] = nbrData[i];
122 toMaster << allComms;
132 fromMaster >> allComms;
176 if (schedulePtr_.empty())
186 return schedulePtr_();
193 const label expectedSize,
194 const label receivedSize
197 if (receivedSize != expectedSize)
200 <<
"Expected from processor " << proci
201 <<
" " << expectedSize <<
" but received " 202 << receivedSize <<
" elements." 213 forAll(constructMap_, proci)
215 const labelList& construct = constructMap_[proci];
216 if (constructHasFlip_)
221 minIndex[proci] =
min(minIndex[proci], index);
222 maxIndex[proci] =
max(maxIndex[proci], index);
229 label index = construct[i];
230 minIndex[proci] =
min(minIndex[proci], index);
231 maxIndex[proci] =
max(maxIndex[proci], index);
246 os <<
"Layout: (constructSize:" << constructSize_
247 <<
" subHasFlip:" << subHasFlip_
248 <<
" constructHasFlip:" << constructHasFlip_
251 <<
" start : 0" <<
endl 252 <<
" size : " << localSize <<
endl;
254 label offset = localSize;
259 if (constructMap_[proci].size() > 0)
261 if (minIndex[proci] != offset)
264 <<
"offset:" << offset
265 <<
" proci:" << proci
266 <<
" minIndex:" << minIndex[proci]
270 label size = maxIndex[proci]-minIndex[proci]+1;
271 os <<
"processor " << proci <<
':' << endl
272 <<
" start : " << offset << endl
273 <<
" size : " << size <<
endl;
298 if (globalIndex != -1 && !globalNumbering.
isLocal(globalIndex))
307 compactMap[proci].clear();
310 compactMap[proci].resize(2*nNonLocal[proci]);
320 if (globalIndex != -1 && !globalNumbering.
isLocal(globalIndex))
323 label index = globalNumbering.
toLocal(proci, globalIndex);
324 label nCompact = compactMap[proci].size();
325 compactMap[proci].insert(index, nCompact);
345 const labelList& cCells = cellCells[cellI];
351 if (globalIndex != -1 && !globalNumbering.
isLocal(globalIndex))
361 compactMap[proci].clear();
364 compactMap[proci].resize(2*nNonLocal[proci]);
372 const labelList& cCells = cellCells[cellI];
378 if (globalIndex != -1 && !globalNumbering.
isLocal(globalIndex))
381 label index = globalNumbering.
toLocal(proci, globalIndex);
382 label nCompact = compactMap[proci].size();
383 compactMap[proci].insert(index, nCompact);
405 constructSize_ = globalNumbering.
localSize();
406 forAll(compactStart, proci)
410 compactStart[proci] = constructSize_;
411 constructSize_ += compactMap[proci].
size();
429 wantedRemoteElements[proci] =
identity(nLocal);
430 constructMap_[proci] =
identity(nLocal);
435 labelList& remoteElem = wantedRemoteElements[proci];
436 labelList& localElem = constructMap_[proci];
437 remoteElem.
setSize(compactMap[proci].size());
438 localElem.
setSize(compactMap[proci].size());
442 const label compactI = compactStart[proci] + iter();
443 remoteElem[i] = iter.key();
444 localElem[i] = compactI;
452 Pstream::exchange<labelList, label>
454 wantedRemoteElements,
463 elements[i] =
renumber(globalNumbering, compactMap, elements[i]);
483 constructSize_ = globalNumbering.
localSize();
484 forAll(compactStart, proci)
488 compactStart[proci] = constructSize_;
489 constructSize_ += compactMap[proci].
size();
507 wantedRemoteElements[proci] =
identity(nLocal);
508 constructMap_[proci] =
identity(nLocal);
513 labelList& remoteElem = wantedRemoteElements[proci];
514 labelList& localElem = constructMap_[proci];
515 remoteElem.
setSize(compactMap[proci].size());
516 localElem.
setSize(compactMap[proci].size());
520 const label compactI = compactStart[proci] + iter();
521 remoteElem[i] = iter.key();
522 localElem[i] = compactI;
530 Pstream::exchange<labelList, label>
532 wantedRemoteElements,
545 cCells[i] =
renumber(globalNumbering, compactMap, cCells[i]);
557 constructHasFlip_(false),
564 const label constructSize,
567 const bool subHasFlip,
568 const bool constructHasFlip
591 if (sendProcs.
size() != recvProcs.
size())
594 <<
"The send and receive data is not the same length. sendProcs:" 595 << sendProcs.
size() <<
" recvProcs:" << recvProcs.
size()
603 forAll(sendProcs, sampleI)
605 label sendProc = sendProcs[sampleI];
606 label recvProc = recvProcs[sampleI];
633 forAll(sendProcs, sampleI)
635 label sendProc = sendProcs[sampleI];
636 label recvProc = recvProcs[sampleI];
641 subMap_[recvProc][nSend[recvProc]++] = sampleI;
826 if (globalNumbering.
isLocal(globalI))
828 return globalNumbering.
toLocal(globalI);
834 return compactMap[proci][index];
870 reinterpret_cast<char*>(recvFields[domain].begin()),
871 recvFields[domain].size()*
sizeof(
bool),
886 boolList& subField = sendFields[domain];
903 reinterpret_cast<const char*>(subField.
begin()),
946 if (recvFields[domain][i])
949 newMap[newI++] = map[i];
952 if (newI < map.
size())
964 label maxConstructIndex = -1;
975 label destinationI = map[i];
978 destinationI =
mag(destinationI)-1;
982 if (elemIsUsed[destinationI])
984 maxConstructIndex =
max(maxConstructIndex, destinationI);
986 newMap[newI++] = map[i];
989 if (newI < map.
size())
1006 const label localSize,
1037 reinterpret_cast<char*>(recvFields[domain].begin()),
1038 recvFields[domain].size()*
sizeof(
bool),
1053 boolList& subField = sendFields[domain];
1057 label index = map[i];
1060 index =
mag(index)-1;
1062 subField[i] = elemIsUsed[index];
1069 reinterpret_cast<const char*>(subField.
begin()),
1086 label index = map[i];
1089 index =
mag(index)-1;
1105 oldToNewSub.
setSize(localSize, -1);
1107 boolList sendElemIsUsed(localSize,
false);
1114 if (recvFields[domain][i])
1116 label index = map[i];
1119 index =
mag(index)-1;
1121 sendElemIsUsed[index] =
true;
1127 forAll(sendElemIsUsed, i)
1129 if (sendElemIsUsed[i])
1131 oldToNewSub[i] = newI++;
1147 if (recvFields[domain][i])
1150 label index = map[i];
1158 index =
mag(index)-1;
1160 label newIndex = oldToNewSub[index];
1163 newIndex = sign*(newIndex+1);
1165 newMap[newI++] = newIndex;
1168 newMap.setSize(newI);
1197 label destinationI = map[i];
1201 if (destinationI < 0)
1205 destinationI =
mag(destinationI)-1;
1209 if (elemIsUsed[destinationI])
1211 label newIndex = oldToNewConstruct[destinationI];
1214 newIndex = sign*(newIndex+1);
1216 newMap[newI++] = newIndex;
1219 newMap.setSize(newI);
1233 <<
"Attempted assignment to self" 1249 is.
fatalCheck(
"operator>>(Istream&, distributionMapBase&)");
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
bool isLocal(const label i) const
Is on local processor.
dimensionedScalar sign(const dimensionedScalar &ds)
A HashTable with keys but without contents.
#define forAll(list, i)
Loop across all elements in list.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
static int masterNo()
Process index of the master.
static label renumber(const globalIndex &, const List< Map< label >> &compactMap, const label globalElement)
Helper for construct from globalIndex. Renumbers element.
Class containing processor-to-processor mapping information.
void operator=(const distributionMapBase &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static int firstSlave()
Process index of first slave.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
void size(const label)
Override size to be inconsistent with allocated storage.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool master(const label communicator=0)
Am I the master process.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
static label nRequests()
Get number of outstanding requests.
distributionMapBase()
Construct null.
static int & msgType()
Message tag of standard messages.
static label worldComm
Default communicator (all processors)
bool insert(const Key &key)
Insert a new entry.
bool subHasFlip_
Whether subMap includes flip or not.
static void checkReceivedSize(const label proci, const label expectedSize, const label receivedSize)
void compact(const boolList &elemIsUsed, const int tag=UPstream::msgType())
Compact maps. Gets per field a bool whether it is used (locally)
Various functions to operate on Lists.
Input inter-processor communications stream.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Istream & operator>>(Istream &, directionInfo &)
iterator begin()
Return an iterator to begin traversing the UList.
void calcCompactAddressing(const globalIndex &globalNumbering, const labelList &elements, List< Map< label >> &compactMap) const
Construct per processor compact addressing of the global elements.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
Pair< label > labelPair
Label pair.
label toLocal(const label i) const
From global to local on current processor.
static const label labelMax
label whichProcID(const label i) const
Which processor does global come from? Binary search.
errorManip< error > abort(error &err)
void fatalCheck(const char *operation) const
Check IOstream status for given operation.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
static label read(const commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=0)
Read into given buffer from given processor and return the.
Determines the order in which a set of processors should communicate with one another.
defineTypeNameAndDebug(combustionModel, 0)
static bool write(const commsTypes commsType, const int toProcNo, const char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=0)
Write given buffer to given processor.
void transfer(distributionMapBase &)
Transfer the contents of the argument and annul the argument.
Output inter-processor communications stream.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
bool constructHasFlip_
Whether constructMap includes flip or not.
static T accessAndFlip(const UList< T > &fld, const label index, const bool hasFlip, const negateOp &negOp)
void setSize(const label)
Reset size of List.
static bool & parRun()
Is this a parallel run?
static label nProcs(const label communicator=0)
Number of processes in parallel run.
prefixOSstream Pout(cout, "Pout")
A List with indirect addressing.
Ostream & operator<<(Ostream &, const ensightPart &)
void exchangeAddressing(const int tag, const globalIndex &globalNumbering, labelList &elements, List< Map< label >> &compactMap, labelList &compactStart)
labelListList constructMap_
Maps from subsetted data to new reconstructed data.
dimensioned< scalar > mag(const dimensioned< Type > &)
label constructSize_
Size of reconstructed data.
List< Key > toc() const
Return the table of contents.
void printLayout(Ostream &os) const
Debug: print layout. Can only be used on maps with sorted.
FvWallInfoData< WallInfo, bool > bool
autoPtr< List< labelPair > > schedulePtr_
Schedule.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
static const label labelMin
const List< labelPair > & schedule() const
Return a schedule. Demand driven. See above.
static int lastSlave(const label communicator=0)
Process index of last slave.
labelListList subMap_
Maps from subsetted data back to original data.
label localSize() const
My local size.