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;
259 if (constructMap_[proci].size() > 0)
261 if (minIndex[proci] !=
offset)
265 <<
" proci:" << proci
266 <<
" minIndex:" << minIndex[proci]
270 label size = maxIndex[proci]-minIndex[proci]+1;
271 os <<
"processor " << proci <<
':' <<
endl
273 <<
" size : " << size <<
endl;
307 compactMap[proci].clear();
310 compactMap[proci].resize(2*nNonLocal[proci]);
324 label nCompact = compactMap[proci].size();
325 compactMap[proci].insert(index, nCompact);
345 const labelList& cCells = cellCells[cellI];
361 compactMap[proci].clear();
364 compactMap[proci].resize(2*nNonLocal[proci]);
372 const labelList& cCells = cellCells[cellI];
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();
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();
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
571 constructSize_(constructSize),
572 subMap_(move(subMap)),
573 constructMap_(move(constructMap)),
574 subHasFlip_(subHasFlip),
575 constructHasFlip_(constructHasFlip),
588 constructHasFlip_(false),
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;
664 constructHasFlip_(false),
724 constructHasFlip_(false),
776 constructSize_(map.constructSize_),
777 subMap_(map.subMap_),
778 constructMap_(map.constructMap_),
779 subHasFlip_(map.subHasFlip_),
780 constructHasFlip_(map.constructHasFlip_),
787 constructSize_(map.constructSize_),
788 subMap_(move(map.subMap_)),
789 constructMap_(move(map.constructMap_)),
790 subHasFlip_(map.subHasFlip_),
791 constructHasFlip_(map.constructHasFlip_),
811 schedulePtr_.clear();
826 if (globalNumbering.
isLocal(globalI))
828 return globalNumbering.
toLocal(globalI);
834 return compactMap[proci][index];
886 reinterpret_cast<char*
>(recvFields[domain].begin()),
887 recvFields[domain].size()*
sizeof(
bool),
897 const labelList& map = constructMap_[domain];
901 boolList& subField = sendFields[domain];
905 subField[i] = accessAndFlip
918 reinterpret_cast<const char*
>(subField.
begin()),
919 subField.
size()*
sizeof(
bool),
938 if (recvFields[domain][i])
941 newMap[newI++] = map[i];
944 if (newI < map.
size())
947 subMap_[domain].transfer(newMap);
953 label maxConstructIndex = -1;
956 const labelList& map = constructMap_[domain];
963 label destinationI = map[i];
964 if (constructHasFlip_)
966 destinationI =
mag(destinationI)-1;
970 if (elemIsUsed[destinationI])
972 maxConstructIndex =
max(maxConstructIndex, destinationI);
974 newMap[newI++] = map[i];
977 if (newI < map.
size())
980 constructMap_[domain].transfer(newMap);
984 constructSize_ = maxConstructIndex+1;
987 schedulePtr_.clear();
994 const label localSize,
1041 reinterpret_cast<char*
>(recvFields[domain].begin()),
1042 recvFields[domain].size()*
sizeof(
bool),
1052 const labelList& map = constructMap_[domain];
1056 boolList& subField = sendFields[domain];
1060 subField[i] = accessAndFlip
1073 reinterpret_cast<const char*
>(subField.
begin()),
1074 subField.
size()*
sizeof(
bool),
1085 oldToNewSub.
setSize(localSize, -1);
1087 boolList sendElemIsUsed(localSize,
false);
1094 if (recvFields[domain][i])
1096 label index = map[i];
1099 index =
mag(index)-1;
1101 sendElemIsUsed[index] =
true;
1107 forAll(sendElemIsUsed, i)
1109 if (sendElemIsUsed[i])
1111 oldToNewSub[i] = newI++;
1126 if (recvFields[domain][i])
1129 label index = map[i];
1137 index =
mag(index)-1;
1139 label newIndex = oldToNewSub[index];
1142 newIndex =
sign*(newIndex+1);
1144 newMap[newI++] = newIndex;
1148 subMap_[domain].transfer(newMap);
1159 oldToNewConstruct[i] = constructSize_++;
1165 const labelList& map = constructMap_[domain];
1172 label destinationI = map[i];
1174 if (constructHasFlip_)
1176 if (destinationI < 0)
1180 destinationI =
mag(destinationI)-1;
1184 if (elemIsUsed[destinationI])
1186 label newIndex = oldToNewConstruct[destinationI];
1187 if (constructHasFlip_)
1189 newIndex =
sign*(newIndex+1);
1191 newMap[newI++] = newIndex;
1195 constructMap_[domain].transfer(newMap);
1208 <<
"Attempted assignment to self"
1216 schedulePtr_.clear();
1224 is.
fatalCheck(
"operator>>(Istream&, distributionMapBase&)");
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
A HashTable with keys but without contents.
bool insert(const Key &key)
Insert a new entry.
List< Key > toc() const
Return the table of contents.
void fatalCheck(const char *operation) const
Check IOstream status for given operation.
Input inter-processor communications stream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
Output inter-processor communications stream.
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.
A List with indirect addressing.
iterator begin()
Return an iterator to begin traversing the UList.
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.
static int masterNo()
Process index of the master.
static bool master(const label communicator=0)
Am I the master process.
static int lastSlave(const label communicator=0)
Process index of last slave.
static label worldComm
Default communicator (all processors)
static label nRequests()
Get number of outstanding requests.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
static int firstSlave()
Process index of first slave.
static bool & parRun()
Is this a parallel run?
static int & msgType()
Message tag of standard messages.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Determines the order in which a set of processors should communicate with one another.
Class containing processor-to-processor mapping information.
bool constructHasFlip_
Whether constructMap includes flip or not.
label constructSize_
Size of reconstructed data.
const List< labelPair > & schedule() const
Return a schedule. Demand driven. See above.
const labelListList & constructMap() const
From subsetted data to new reconstructed data.
const labelListList & subMap() const
From subsetted data back to original data.
void operator=(const distributionMapBase &)
void printLayout(Ostream &os) const
Debug: print layout. Can only be used on maps with sorted.
void transfer(distributionMapBase &)
Transfer the contents of the argument and annul the argument.
bool subHasFlip_
Whether subMap includes flip or not.
static void checkReceivedSize(const label proci, const label expectedSize, const label receivedSize)
static label renumber(const globalIndex &, const List< Map< label >> &compactMap, const label globalElement)
Helper for construct from globalIndex. Renumbers element.
labelListList subMap_
Maps from subsetted data back to original data.
distributionMapBase()
Construct null.
void calcCompactAddressing(const globalIndex &globalNumbering, const labelList &elements, List< Map< label >> &compactMap) const
Construct per processor compact addressing of the global elements.
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.
void compact(const boolList &elemIsUsed, const int tag=UPstream::msgType())
Compact maps. Gets per field a bool whether it is used (locally)
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
label whichProcID(const label i) const
Which processor does global come from? Binary search.
label localSize() const
My local size.
label toLocal(const label i) const
From global to local on current processor.
bool isLocal(const label i) const
Is on local processor.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Pair< label > labelPair
Label pair.
dimensionedScalar sign(const dimensionedScalar &ds)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
Istream & operator>>(Istream &, pistonPointEdgeData &)
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
prefixOSstream Pout(cout, "Pout")
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
static const label labelMax
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
void offset(label &lst, const label o)
static const label labelMin