45 void Foam::mapDistribute::transform::operator()
53 void Foam::mapDistribute::transform::operator()
60 void Foam::mapDistribute::transform::operator()
67 void Foam::mapDistribute::transform::operator()
76 void Foam::mapDistribute::transform::operator()
84 void Foam::mapDistribute::transform::operator()
91 void Foam::mapDistribute::transform::operator()
98 void Foam::mapDistribute::transform::operator()
107 void Foam::mapDistribute::transform::operator()
115 void Foam::mapDistribute::transform::operator()
122 void Foam::mapDistribute::transform::operator()
129 void Foam::mapDistribute::transform::operator()
155 if (subMap[procI].size())
160 if (constructMap[procI].size())
167 allComms = commsSet.
toc();
187 if (
findIndex(allComms, nbrData[i]) == -1)
191 allComms[sz] = nbrData[i];
211 toMaster << allComms;
221 fromMaster >> allComms;
265 if (schedulePtr_.empty())
275 return schedulePtr_();
279 void Foam::mapDistribute::checkReceivedSize
282 const label expectedSize,
283 const label receivedSize
286 if (receivedSize != expectedSize)
290 "template<class T>\n" 291 "void mapDistribute::distribute\n" 293 " const Pstream::commsTypes commsType,\n" 294 " const List<labelPair>& schedule,\n" 295 " const label constructSize,\n" 296 " const labelListList& subMap,\n" 297 " const labelListList& constructMap,\n" 300 ) <<
"Expected from processor " << procI
301 <<
" " << expectedSize <<
" but received " 302 << receivedSize <<
" elements." 313 forAll(constructMap_, procI)
315 const labelList& construct = constructMap_[procI];
316 minIndex[procI] =
min(minIndex[procI],
min(construct));
317 maxIndex[procI] =
max(maxIndex[procI],
max(construct));
330 os <<
"Layout: (constructSize:" << constructSize_ <<
")" <<
endl 332 <<
" start : 0" <<
endl 333 <<
" size : " << localSize <<
endl;
335 label offset = localSize;
340 if (constructMap_[procI].size() > 0)
342 if (minIndex[procI] != offset)
345 <<
"offset:" << offset
346 <<
" procI:" << procI
347 <<
" minIndex:" << minIndex[procI]
351 label size = maxIndex[procI]-minIndex[procI]+1;
352 os <<
"processor " << procI <<
':' << endl
353 <<
" start : " << offset << endl
354 <<
" size : " << size <<
endl;
360 forAll(transformElements_, trafoI)
362 if (transformElements_[trafoI].size() > 0)
364 os <<
"transform " << trafoI <<
':' << endl
365 <<
" start : " << transformStart_[trafoI] << endl
366 <<
" size : " << transformElements_[trafoI].size() <<
endl;
375 void Foam::mapDistribute::calcCompactAddressing
391 if (globalIndex != -1 && !globalNumbering.
isLocal(globalIndex))
400 compactMap[procI].clear();
403 compactMap[procI].resize(2*nNonLocal[procI]);
413 if (globalIndex != -1 && !globalNumbering.
isLocal(globalIndex))
416 label index = globalNumbering.
toLocal(procI, globalIndex);
417 label nCompact = compactMap[procI].size();
418 compactMap[procI].insert(index, nCompact);
424 void Foam::mapDistribute::calcCompactAddressing
438 const labelList& cCells = cellCells[cellI];
444 if (globalIndex != -1 && !globalNumbering.
isLocal(globalIndex))
454 compactMap[procI].clear();
457 compactMap[procI].resize(2*nNonLocal[procI]);
465 const labelList& cCells = cellCells[cellI];
471 if (globalIndex != -1 && !globalNumbering.
isLocal(globalIndex))
474 label index = globalNumbering.
toLocal(procI, globalIndex);
475 label nCompact = compactMap[procI].size();
476 compactMap[procI].insert(index, nCompact);
483 void Foam::mapDistribute::exchangeAddressing
498 constructSize_ = globalNumbering.
localSize();
499 forAll(compactStart, procI)
503 compactStart[procI] = constructSize_;
504 constructSize_ += compactMap[procI].
size();
522 wantedRemoteElements[procI] =
identity(nLocal);
523 constructMap_[procI] =
identity(nLocal);
528 labelList& remoteElem = wantedRemoteElements[procI];
529 labelList& localElem = constructMap_[procI];
530 remoteElem.
setSize(compactMap[procI].size());
531 localElem.
setSize(compactMap[procI].size());
535 const label compactI = compactStart[procI] + iter();
536 remoteElem[i] = iter.key();
537 localElem[i] = compactI;
546 Pstream::exchange<labelList, label>
548 wantedRemoteElements,
558 elements[i] =
renumber(globalNumbering, compactMap, elements[i]);
563 void Foam::mapDistribute::exchangeAddressing
578 constructSize_ = globalNumbering.
localSize();
579 forAll(compactStart, procI)
583 compactStart[procI] = constructSize_;
584 constructSize_ += compactMap[procI].
size();
602 wantedRemoteElements[procI] =
identity(nLocal);
603 constructMap_[procI] =
identity(nLocal);
608 labelList& remoteElem = wantedRemoteElements[procI];
609 labelList& localElem = constructMap_[procI];
610 remoteElem.
setSize(compactMap[procI].size());
611 localElem.
setSize(compactMap[procI].size());
615 const label compactI = compactStart[procI] + iter();
616 remoteElem[i] = iter.key();
617 localElem[i] = compactI;
626 Pstream::exchange<labelList, label>
628 wantedRemoteElements,
642 cCells[i] =
renumber(globalNumbering, compactMap, cCells[i]);
666 constructSize_(constructSize),
668 constructMap_(constructMap),
676 const label constructSize,
683 constructSize_(constructSize),
685 constructMap_(constructMap),
686 transformElements_(transformElements),
687 transformStart_(transformStart),
701 if (sendProcs.
size() != recvProcs.
size())
705 "mapDistribute::mapDistribute(const labelList&, const labelList&)" 706 ) <<
"The send and receive data is not the same length. sendProcs:" 707 << sendProcs.
size() <<
" recvProcs:" << recvProcs.
size()
715 forAll(sendProcs, sampleI)
717 label sendProc = sendProcs[sampleI];
718 label recvProc = recvProcs[sampleI];
739 subMap_[procI].
setSize(nSend[procI]);
740 constructMap_[procI].
setSize(nRecv[procI]);
745 forAll(sendProcs, sampleI)
747 label sendProc = sendProcs[sampleI];
748 label recvProc = recvProcs[sampleI];
753 subMap_[recvProc][nSend[recvProc]++] = sampleI;
758 constructMap_[sendProc][nRecv[sendProc]++] = sampleI;
760 constructSize_ = sampleI+1;
780 calcCompactAddressing
838 calcCompactAddressing
899 calcCompactAddressing
907 forAll(transformedElements, i)
914 label nCompact = compactMap[procI].size();
915 compactMap[procI].insert(index, nCompact);
938 forAll(transformedElements, i)
942 nPerTransform[trafoI]++;
945 transformStart_.
setSize(nTrafo);
946 transformElements_.
setSize(nTrafo);
947 forAll(transformStart_, trafoI)
949 transformStart_[trafoI] = constructSize_;
950 constructSize_ += nPerTransform[trafoI];
951 transformElements_[trafoI].
setSize(nPerTransform[trafoI]);
957 transformedIndices.
setSize(transformedElements.
size());
958 forAll(transformedElements, i)
970 : compactMap[procI][index]
973 label&
n = nPerTransform[trafoI];
975 transformElements_[trafoI][
n] = rawElemI;
977 transformedIndices[i] = transformStart_[trafoI]+
n;
1005 calcCompactAddressing
1013 forAll(transformedElements, cellI)
1023 label nCompact = compactMap[procI].size();
1024 compactMap[procI].insert(index, nCompact);
1048 forAll(transformedElements, cellI)
1055 nPerTransform[trafoI]++;
1059 transformStart_.
setSize(nTrafo);
1060 transformElements_.
setSize(nTrafo);
1061 forAll(transformStart_, trafoI)
1063 transformStart_[trafoI] = constructSize_;
1064 constructSize_ += nPerTransform[trafoI];
1065 transformElements_[trafoI].
setSize(nPerTransform[trafoI]);
1071 transformedIndices.
setSize(transformedElements.
size());
1072 forAll(transformedElements, cellI)
1088 : compactMap[procI][index]
1091 label&
n = nPerTransform[trafoI];
1093 transformElements_[trafoI][
n] = rawElemI;
1095 transformedIndices[cellI][i] = transformStart_[trafoI]+
n;
1109 constructSize_(map.constructSize_),
1110 subMap_(map.subMap_),
1111 constructMap_(map.constructMap_),
1112 transformElements_(map.transformElements_),
1113 transformStart_(map.transformStart_),
1120 constructSize_(map().constructSize_),
1121 subMap_(map().subMap_.
xfer()),
1122 constructMap_(map().constructMap_.
xfer()),
1123 transformElements_(map().transformElements_.
xfer()),
1124 transformStart_(map().transformStart_.
xfer()),
1133 return findLower(transformStart_, index+1);
1139 constructSize_ = rhs.constructSize_;
1141 constructMap_.
transfer(rhs.constructMap_);
1142 transformElements_.
transfer(rhs.transformElements_);
1143 transformStart_.
transfer(rhs.transformStart_);
1144 schedulePtr_.clear();
1165 if (globalNumbering.
isLocal(globalI))
1167 return globalNumbering.
toLocal(globalI);
1173 return compactMap[procI][index];
1205 reinterpret_cast<char*>(recvFields[domain].begin()),
1206 recvFields[domain].size()*
sizeof(
bool),
1217 const labelList& map = constructMap_[domain];
1221 boolList& subField = sendFields[domain];
1225 subField[i] = elemIsUsed[map[i]];
1232 reinterpret_cast<const char*>(subField.
begin()),
1233 subField.
size()*
sizeof(bool),
1269 if (recvFields[domain][i])
1272 newMap[newI++] = map[i];
1275 if (newI < map.
size())
1287 label maxConstructIndex = -1;
1291 const labelList& map = constructMap_[domain];
1298 label destinationI = map[i];
1301 if (elemIsUsed[destinationI])
1303 maxConstructIndex =
max(maxConstructIndex, destinationI);
1305 newMap[newI++] = destinationI;
1308 if (newI < map.
size())
1310 newMap.setSize(newI);
1311 constructMap_[domain].
transfer(newMap);
1315 constructSize_ = maxConstructIndex+1;
1318 schedulePtr_.clear();
1331 "Foam::mapDistribute::operator=(const Foam::mapDistribute&)" 1332 ) <<
"Attempted assignment to self" 1335 constructSize_ = rhs.constructSize_;
1336 subMap_ = rhs.subMap_;
1337 constructMap_ = rhs.constructMap_;
1338 transformElements_ = rhs.transformElements_;
1339 transformStart_ = rhs.transformStart_;
1340 schedulePtr_.clear();
1348 is.
fatalCheck(
"operator>>(Istream&, mapDistribute&)");
1350 is >> map.constructSize_ >> map.subMap_ >> map.constructMap_
1351 >> map.transformElements_ >> map.transformStart_;
static bool & parRun()
Is this a parallel run?
Determination and storage of the possible independent transforms introduced by coupledPolyPatches, as well as all of the possible permutations of these transforms generated by the presence of multiple coupledPolyPatches, i.e. more than one cyclic boundary.
bool isLocal(const label i) const
Is on local processor.
label whichTransform(const label index) const
Find transform from transformElements.
label localSize() const
My local size.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
An ordered pair of two objects of type <T> with first() and second() elements.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
const labelListList & transformElements() const
For every globalIndexAndTransform::transformPermutations.
static label renumber(const globalIndex &, const List< Map< label > > &compactMap, const label globalElement)
Helper for construct from globalIndex. Renumbers element.
const List< vectorTensorTransform > & transformPermutations() const
Return access to the permuted transforms.
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.
Class containing processor-to-processor mapping information.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
A simple container for copying or transferring objects of type <T>.
#define forAllIter(Container, container, iter)
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void operator=(const mapDistribute &)
void size(const label)
Override size to be inconsistent with allocated storage.
Output inter-processor communications stream.
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.
Various functions to operate on Lists.
void compact(const boolList &elemIsUsed, const int tag=UPstream::msgType())
Compact maps. Gets per field a bool whether it is used (locally)
Ostream & operator<<(Ostream &, const edgeMesh &)
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
mapDistribute()
Construct null.
iterator begin()
Return an iterator to begin traversing the UList.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A List with indirect addressing.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
void fatalCheck(const char *operation) const
Check IOstream status for given operation.
Spatial transformation functions for primitive fields.
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
static int & msgType()
Message tag of standard messages.
Determines the order in which a set of processors should communicate with one another.
static const label labelMin
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
label findLower(const ListType &, typename ListType::const_reference, const label stary, const BinaryOp &bop)
Find last element < given value in sorted list and return index,.
List< Key > toc() const
Return the table of contents.
Xfer< mapDistribute > xfer()
Transfer contents to the Xfer container.
errorManip< error > abort(error &err)
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
static label nRequests()
Get number of outstanding requests.
Vector-tensor class used to perform translations and rotations in 3D space.
const List< labelPair > & schedule() const
Return a schedule. Demand driven. See above.
const labelList & transformStart() const
Destination in constructMap for transformed elements.
Input inter-processor communications stream.
label toLocal(const label i) const
From global to local on current processor.
static int masterNo()
Process index of the master.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
A HashTable with keys but without contents.
Pair< label > labelPair
Label pair.
Istream & operator>>(Istream &, edgeMesh &)
void transfer(mapDistribute &)
Transfer the contents of the argument and annul the argument.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
static bool master(const label communicator=0)
Am I the master process.
static int firstSlave()
Process index of first slave.
static int lastSlave(const label communicator=0)
Process index of last slave.
static label index(const labelPair &globalIAndTransform)
Index carried by the object.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
static label worldComm
Default communicator (all processors)
static label transformIndex(const labelPair &globalIAndTransform)
Transform carried by the object.
static label processor(const labelPair &globalIAndTransform)
Which processor does this come from?
void printLayout(Ostream &os) const
Debug: print layout. Can only be used on maps with sorted.
label whichProcID(const label i) const
Which processor does global come from? Binary search.
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout,"Pout")
label constructSize() const
Constructed data size.
static const label labelMax
bool insert(const Key &key)
Insert a new entry.