37 const List<Type>& elems,
45 os <<
' ' << elems[elemI];
54 const List<Type>& values,
56 const label fromProcNo,
58 List<taggedValue>& dest
63 taggedValue& tagVal = dest[destI];
65 tagVal.value() = values[elemI];
66 tagVal.index() = indices[elemI];
67 tagVal.procID() = fromProcNo;
77 const List<Type>& elems,
81 pivots.
setSize(Pstream::nProcs());
87 pivots[pivotI] = elems[pivotPos];
89 pivotPos += elems.size()/Pstream::nProcs();
100 const label destProci
103 if (destProci != Pstream::myProcNo())
106 indices.setSize(bufSize);
110 Pout<<
"Sending to " << destProci <<
" elements:" << values
115 OPstream toSlave(Pstream::commsTypes::blocking, destProci);
116 toSlave << values << indices;
166 getPivots(sorted, pivots);
185 ListListOps::combine<labelList>
196 write(allPivots,
Pout);
200 getPivots(sortedPivots, pivots);
206 Pout<<
"new pivots:";
231 if ((pivotI <
Pstream::nProcs()) && (sorted[sortedI] > pivots[pivotI]))
233 checkAndSend(sendValues, sendIndices, sendI, destProci);
236 sendValues.setSize(sorted.
size());
237 sendIndices.setSize(sorted.
size());
246 sendValues[sendI] = sorted[sortedI];
247 sendIndices[sendI] = sorted.
indices()[sortedI];
252 ownValues[ownI] = sorted[sortedI];
253 ownIndices[ownI] = sorted.
indices()[sortedI];
262 checkAndSend(sendValues, sendIndices, sendI, destProci);
266 ownValues.setSize(ownI);
267 ownIndices.setSize(ownI);
271 Pout<<
"Not sending (to myself) elements " 272 << ownValues <<
endl;
292 Pout<<
"Copying from own:" << ownValues <<
endl;
296 copyInto(ownValues, ownIndices, proci, combinedI, combinedValues);
306 Pout<<
"Receiving from " << proci <<
endl;
311 fromSlave >> recValues >> recIndices;
315 Pout<<
"Received from " << proci
316 <<
" elements:" << recValues <<
endl;
322 Pout<<
"Copying starting at:" << combinedI <<
endl;
324 copyInto(recValues, recIndices, proci, combinedI, combinedValues);
327 combinedValues.
setSize(combinedI);
337 forAll(combinedValues, elemI)
339 this->
operator[](elemI) = combinedValues[elemI].value();
340 indices_[elemI] = combinedValues[elemI].index();
341 procs_[elemI] = combinedValues[elemI].procID();
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Inter-processor communication reduction functions.
Type & operator[](const label)
Return element of UList.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A list that is sorted upon construction or when explicitly requested with the sort() method...
void size(const label)
Override size to be inconsistent with allocated storage.
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.
Input inter-processor communications stream.
List< label > labelList
A List of labels.
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
void setSize(const label)
Reset size of List.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
prefixOSstream Pout(cout, "Pout")
ParSortableList(const UList< Type > &)
Construct from List, sorting the elements.
Implementation of PSRS parallel sorting routine.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
label size() const
Return the number of elements in the UList.
void sort()
(stable) sort the list (if changed after construction time)