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];
866 reinterpret_cast<char*>(recvFields[domain].begin()),
867 recvFields[domain].size()*
sizeof(
bool),
882 boolList& subField = sendFields[domain];
899 reinterpret_cast<const char*>(subField.
begin()),
900 subField.
size()*
sizeof(bool),
942 if (recvFields[domain][i])
945 newMap[newI++] = map[i];
948 if (newI < map.
size())
960 label maxConstructIndex = -1;
971 label destinationI = map[i];
974 destinationI =
mag(destinationI)-1;
978 if (elemIsUsed[destinationI])
980 maxConstructIndex =
max(maxConstructIndex, destinationI);
982 newMap[newI++] = map[i];
985 if (newI < map.
size())
1002 const label localSize,
1033 reinterpret_cast<char*>(recvFields[domain].begin()),
1034 recvFields[domain].size()*
sizeof(
bool),
1049 boolList& subField = sendFields[domain];
1053 label index = map[i];
1056 index =
mag(index)-1;
1058 subField[i] = elemIsUsed[index];
1065 reinterpret_cast<const char*>(subField.
begin()),
1066 subField.
size()*
sizeof(bool),
1082 label index = map[i];
1085 index =
mag(index)-1;
1101 oldToNewSub.
setSize(localSize, -1);
1103 boolList sendElemIsUsed(localSize,
false);
1110 if (recvFields[domain][i])
1112 label index = map[i];
1115 index =
mag(index)-1;
1117 sendElemIsUsed[index] =
true;
1123 forAll(sendElemIsUsed, i)
1125 if (sendElemIsUsed[i])
1127 oldToNewSub[i] = newI++;
1143 if (recvFields[domain][i])
1146 label index = map[i];
1154 index =
mag(index)-1;
1156 label newIndex = oldToNewSub[index];
1159 newIndex = sign*(newIndex+1);
1161 newMap[newI++] = newIndex;
1193 label destinationI = map[i];
1197 if (destinationI < 0)
1201 destinationI =
mag(destinationI)-1;
1205 if (elemIsUsed[destinationI])
1207 label newIndex = oldToNewConstruct[destinationI];
1210 newIndex = sign*(newIndex+1);
1212 newMap[newI++] = newIndex;
1229 <<
"Attempted assignment to self" 1245 is.
fatalCheck(
"operator>>(Istream&, mapDistributeBase&)");
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.
void compact(const boolList &elemIsUsed, const int tag=UPstream::msgType())
Compact maps. Gets per field a bool whether it is used (locally)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
static int masterNo()
Process index of the master.
void calcCompactAddressing(const globalIndex &globalNumbering, const labelList &elements, List< Map< label >> &compactMap) const
Construct per processor compact addressing of the global elements.
static label renumber(const globalIndex &, const List< Map< label >> &compactMap, const label globalElement)
Helper for construct from globalIndex. Renumbers element.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#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.
const List< labelPair > & schedule() const
Return a schedule. Demand driven. See above.
#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.
labelListList subMap_
Maps from subsetted data back to original data.
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.
static int & msgType()
Message tag of standard messages.
static label worldComm
Default communicator (all processors)
bool insert(const Key &key)
Insert a new entry.
mapDistributeBase()
Construct null.
label constructSize_
Size of reconstructed data.
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...
autoPtr< List< labelPair > > schedulePtr_
Schedule.
Istream & operator>>(Istream &, directionInfo &)
void printLayout(Ostream &os) const
Debug: print layout. Can only be used on maps with sorted.
static T accessAndFlip(const UList< T > &fld, const label index, const bool hasFlip, const negateOp &negOp)
iterator begin()
Return an iterator to begin traversing the UList.
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)
labelListList constructMap_
Maps from subsetted data to new reconstructed data.
void fatalCheck(const char *operation) const
Check IOstream status for given operation.
void operator=(const mapDistributeBase &)
Class containing processor-to-processor mapping information.
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.
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.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
bool subHasFlip_
Whether subMap includes flip or not.
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.
void exchangeAddressing(const int tag, const globalIndex &globalNumbering, labelList &elements, List< Map< label >> &compactMap, labelList &compactStart)
bool constructHasFlip_
Whether constructMap includes flip or not.
prefixOSstream Pout(cout, "Pout")
A List with indirect addressing.
Ostream & operator<<(Ostream &, const ensightPart &)
static void checkReceivedSize(const label proci, const label expectedSize, const label receivedSize)
dimensioned< scalar > mag(const dimensioned< Type > &)
void transfer(mapDistributeBase &)
Transfer the contents of the argument and annul the argument.
List< Key > toc() const
Return the table of contents.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
static const label labelMin
static int lastSlave(const label communicator=0)
Process index of last slave.
label localSize() const
My local size.