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;
832 if (globalNumbering.
isLocal(globalI))
834 return globalNumbering.
toLocal(globalI);
840 return compactMap[proci][index];
872 reinterpret_cast<char*>(recvFields[domain].begin()),
873 recvFields[domain].size()*
sizeof(
bool),
888 boolList& subField = sendFields[domain];
905 reinterpret_cast<const char*>(subField.
begin()),
906 subField.
size()*
sizeof(bool),
948 if (recvFields[domain][i])
951 newMap[newI++] = map[i];
954 if (newI < map.
size())
966 label maxConstructIndex = -1;
977 label destinationI = map[i];
980 destinationI =
mag(destinationI)-1;
984 if (elemIsUsed[destinationI])
986 maxConstructIndex =
max(maxConstructIndex, destinationI);
988 newMap[newI++] = map[i];
991 if (newI < map.
size())
1008 const label localSize,
1039 reinterpret_cast<char*>(recvFields[domain].begin()),
1040 recvFields[domain].size()*
sizeof(
bool),
1055 boolList& subField = sendFields[domain];
1059 label index = map[i];
1062 index =
mag(index)-1;
1064 subField[i] = elemIsUsed[index];
1071 reinterpret_cast<const char*>(subField.
begin()),
1072 subField.
size()*
sizeof(bool),
1088 label index = map[i];
1091 index =
mag(index)-1;
1107 oldToNewSub.
setSize(localSize, -1);
1109 boolList sendElemIsUsed(localSize,
false);
1116 if (recvFields[domain][i])
1118 label index = map[i];
1121 index =
mag(index)-1;
1123 sendElemIsUsed[index] =
true;
1129 forAll(sendElemIsUsed, i)
1131 if (sendElemIsUsed[i])
1133 oldToNewSub[i] = newI++;
1149 if (recvFields[domain][i])
1152 label index = map[i];
1160 index =
mag(index)-1;
1162 label newIndex = oldToNewSub[index];
1165 newIndex = sign*(newIndex+1);
1167 newMap[newI++] = newIndex;
1199 label destinationI = map[i];
1203 if (destinationI < 0)
1207 destinationI =
mag(destinationI)-1;
1211 if (elemIsUsed[destinationI])
1213 label newIndex = oldToNewConstruct[destinationI];
1216 newIndex = sign*(newIndex+1);
1218 newMap[newI++] = newIndex;
1235 <<
"Attempted assignment to self" 1251 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 simple container for copying or transferring objects of type <T>.
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.
Xfer< mapDistributeBase > xfer()
Transfer contents to the Xfer container.
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...
Xfer< T > xferMove(T &)
Construct by transferring the contents of the arg.
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 occurence 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.