40 const List<Type>& elems,
48 os <<
' ' << elems[elemI];
57 const List<Type>& values,
58 const labelList& indices,
59 const label fromProcNo,
61 List<taggedValue>& dest
66 taggedValue& tagVal = dest[destI];
68 tagVal.value() =
values[elemI];
69 tagVal.index() = indices[elemI];
70 tagVal.procID() = fromProcNo;
80 const List<Type>& elems,
84 pivots.
setSize(Pstream::nProcs());
90 pivots[pivotI] = elems[pivotPos];
92 pivotPos += elems.size()/Pstream::nProcs();
103 const label destProci
106 if (destProci != Pstream::myProcNo())
109 indices.setSize(bufSize);
113 Pout<<
"Sending to " << destProci <<
" elements:" <<
values
118 OPstream toSlave(Pstream::commsTypes::blocking, destProci);
119 toSlave <<
values << indices;
156 label
n = this->size();
169 getPivots(sorted, pivots);
188 ListListOps::combine<labelList>
203 getPivots(sortedPivots, pivots);
209 Pout<<
"new pivots:";
234 if ((pivotI <
Pstream::nProcs()) && (sorted[sortedI] > pivots[pivotI]))
236 checkAndSend(sendValues, sendIndices, sendI, destProci);
249 sendValues[sendI] = sorted[sortedI];
250 sendIndices[sendI] = sorted.
indices()[sortedI];
255 ownValues[ownI] = sorted[sortedI];
256 ownIndices[ownI] = sorted.
indices()[sortedI];
265 checkAndSend(sendValues, sendIndices, sendI, destProci);
274 Pout<<
"Not sending (to myself) elements "
275 << ownValues <<
endl;
295 Pout<<
"Copying from own:" << ownValues <<
endl;
299 copyInto(ownValues, ownIndices, proci, combinedI, combinedValues);
309 Pout<<
"Receiving from " << proci <<
endl;
314 fromSlave >> recValues >> recIndices;
318 Pout<<
"Received from " << proci
319 <<
" elements:" << recValues <<
endl;
325 Pout<<
"Copying starting at:" << combinedI <<
endl;
327 copyInto(recValues, recIndices, proci, combinedI, combinedValues);
330 combinedValues.
setSize(combinedI);
337 indices_.setSize(combinedI);
338 procs_.setSize(combinedI);
340 forAll(combinedValues, elemI)
342 this->operator[](elemI) = combinedValues[elemI].value();
343 indices_[elemI] = combinedValues[elemI].index();
344 procs_[elemI] = combinedValues[elemI].procID();
Inter-processor communication reduction functions.
Input inter-processor communications stream.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(const label n)
Alias for resize()
Implementation of PSRS parallel sorting routine.
void sort()
(stable) sort the list (if changed after construction time)
UPstream::rangeType allProcs() const noexcept
Range of ranks indices associated with PstreamBuffers.
label nProcs() const noexcept
Number of ranks associated with PstreamBuffers.
static void gatherList(const List< commsStruct > &comms, List< T > &values, const int tag, const label comm)
static void scatter(const List< commsStruct > &comms, T &value, const int tag, const label comm)
Broadcast data: Distribute without modification.
A list that is sorted upon construction or when explicitly requested with the sort() method.
const labelList & indices() const noexcept
Return the list of sorted indices. Updated every sort.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
virtual bool write()
Write the output fields.
int myProcNo() const noexcept
Return processor number.
splitCell * master() const
OBJstream os(runTime.globalPath()/outputName)
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
void sort(UList< T > &list)
Sort the list.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
points setSize(newPointi)
#define forAll(list, i)
Loop across all elements in list.