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];
116 toMaster << allComms;
126 fromMaster >> allComms;
170 if (schedulePtr_.empty())
180 return schedulePtr_();
187 const label expectedSize,
188 const label receivedSize
191 if (receivedSize != expectedSize)
194 <<
"Expected from processor " << proci
195 <<
" " << expectedSize <<
" but received " 196 << receivedSize <<
" elements." 207 forAll(constructMap_, proci)
209 const labelList& construct = constructMap_[proci];
210 if (constructHasFlip_)
215 minIndex[proci] =
min(minIndex[proci], index);
216 maxIndex[proci] =
max(maxIndex[proci], index);
223 label index = construct[i];
224 minIndex[proci] =
min(minIndex[proci], index);
225 maxIndex[proci] =
max(maxIndex[proci], index);
240 os <<
"Layout: (constructSize:" << constructSize_
241 <<
" subHasFlip:" << subHasFlip_
242 <<
" constructHasFlip:" << constructHasFlip_
245 <<
" start : 0" <<
endl 246 <<
" size : " << localSize <<
endl;
248 label offset = localSize;
253 if (constructMap_[proci].size() > 0)
255 if (minIndex[proci] != offset)
258 <<
"offset:" << offset
259 <<
" proci:" << proci
260 <<
" minIndex:" << minIndex[proci]
264 label size = maxIndex[proci]-minIndex[proci]+1;
265 os <<
"processor " << proci <<
':' << endl
266 <<
" start : " << offset << endl
267 <<
" size : " << size <<
endl;
292 if (globalIndex != -1 && !globalNumbering.
isLocal(globalIndex))
301 compactMap[proci].clear();
304 compactMap[proci].resize(2*nNonLocal[proci]);
314 if (globalIndex != -1 && !globalNumbering.
isLocal(globalIndex))
317 label index = globalNumbering.
toLocal(proci, globalIndex);
318 label nCompact = compactMap[proci].size();
319 compactMap[proci].insert(index, nCompact);
339 const labelList& cCells = cellCells[cellI];
345 if (globalIndex != -1 && !globalNumbering.
isLocal(globalIndex))
355 compactMap[proci].clear();
358 compactMap[proci].resize(2*nNonLocal[proci]);
366 const labelList& cCells = cellCells[cellI];
372 if (globalIndex != -1 && !globalNumbering.
isLocal(globalIndex))
375 label index = globalNumbering.
toLocal(proci, globalIndex);
376 label nCompact = compactMap[proci].size();
377 compactMap[proci].insert(index, nCompact);
399 constructSize_ = globalNumbering.
localSize();
400 forAll(compactStart, proci)
404 compactStart[proci] = constructSize_;
405 constructSize_ += compactMap[proci].
size();
423 wantedRemoteElements[proci] =
identity(nLocal);
424 constructMap_[proci] =
identity(nLocal);
429 labelList& remoteElem = wantedRemoteElements[proci];
430 labelList& localElem = constructMap_[proci];
431 remoteElem.
setSize(compactMap[proci].size());
432 localElem.
setSize(compactMap[proci].size());
436 const label compactI = compactStart[proci] + iter();
437 remoteElem[i] = iter.key();
438 localElem[i] = compactI;
446 Pstream::exchange<labelList, label>
448 wantedRemoteElements,
457 elements[i] =
renumber(globalNumbering, compactMap, elements[i]);
477 constructSize_ = globalNumbering.
localSize();
478 forAll(compactStart, proci)
482 compactStart[proci] = constructSize_;
483 constructSize_ += compactMap[proci].
size();
501 wantedRemoteElements[proci] =
identity(nLocal);
502 constructMap_[proci] =
identity(nLocal);
507 labelList& remoteElem = wantedRemoteElements[proci];
508 labelList& localElem = constructMap_[proci];
509 remoteElem.
setSize(compactMap[proci].size());
510 localElem.
setSize(compactMap[proci].size());
514 const label compactI = compactStart[proci] + iter();
515 remoteElem[i] = iter.key();
516 localElem[i] = compactI;
524 Pstream::exchange<labelList, label>
526 wantedRemoteElements,
539 cCells[i] =
renumber(globalNumbering, compactMap, cCells[i]);
551 constructHasFlip_(false),
558 const label constructSize,
561 const bool subHasFlip,
562 const bool constructHasFlip
585 if (sendProcs.
size() != recvProcs.
size())
588 <<
"The send and receive data is not the same length. sendProcs:" 589 << sendProcs.
size() <<
" recvProcs:" << recvProcs.
size()
597 forAll(sendProcs, sampleI)
599 label sendProc = sendProcs[sampleI];
600 label recvProc = recvProcs[sampleI];
627 forAll(sendProcs, sampleI)
629 label sendProc = sendProcs[sampleI];
630 label recvProc = recvProcs[sampleI];
635 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.
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.
static label renumber(const globalIndex &, const List< Map< label >> &compactMap, const label globalElement)
Helper for construct from globalIndex. Renumbers element.
void printLayout(Ostream &os) const
Debug: print layout. Can only be used on maps with sorted.
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.
#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 &)
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.
label whichProcID(const label i) const
Which processor does global come from? Binary search.
Pair< label > labelPair
Label pair.
static const label labelMax
errorManip< error > abort(error &err)
labelListList constructMap_
Maps from subsetted data to new reconstructed data.
List< Key > toc() const
Return the table of contents.
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...
prefixOSstream Pout(cout,"Pout")
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.
const List< labelPair > & schedule() const
Return a schedule. Demand driven. See above.
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 calcCompactAddressing(const globalIndex &globalNumbering, const labelList &elements, List< Map< label >> &compactMap) const
Construct per processor compact addressing of the global elements.
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.
label localSize() const
My local size.
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 > &)
bool isLocal(const label i) const
Is on local processor.
void transfer(mapDistributeBase &)
Transfer the contents of the argument and annul the argument.
label toLocal(const label i) const
From global to local on current processor.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
static const label labelMin
void fatalCheck(const char *operation) const
Check IOstream status for given operation.
static int lastSlave(const label communicator=0)
Process index of last slave.