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.procIndex() = 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>
200 getPivots(sortedPivots, pivots);
206 Pout<<
"new pivots:";
231 if ((pivotI <
Pstream::nProcs()) && (sorted[sortedI] > pivots[pivotI]))
233 checkAndSend(sendValues, sendIndices, sendI, destProci);
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);
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);
334 indices_.setSize(combinedI);
335 procs_.setSize(combinedI);
337 forAll(combinedValues, elemI)
339 this->operator[](elemI) = combinedValues[elemI].value();
340 indices_[elemI] = combinedValues[elemI].index();
341 procs_[elemI] = combinedValues[elemI].procIndex();
Inter-processor communication reduction functions.
#define forAll(list, i)
Loop across all elements in list.
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 size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
Implementation of PSRS parallel sorting routine.
void sort()
(stable) sort the list (if changed after construction time)
ParSortableList(const UList< Type > &)
Construct from List, sorting the elements.
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
A list that is sorted upon construction or when explicitly requested with the sort() method.
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
static bool master(const label communicator=0)
Am I the master process.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
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)
prefixOSstream Pout(cout, "Pout")
points setSize(newPointi)