40 const List<Type>& elems,
48 os <<
' ' << elems[elemI];
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();
167 labelList& pivots = sortedGatherList[Pstream::myProcNo()];
169 getPivots(sorted, pivots);
183 Pstream::gatherList(sortedGatherList);
185 if (Pstream::master())
188 ListListOps::combine<labelList>
191 accessOp<labelList>()
194 SortableList<Type> sortedPivots(allPivots);
203 getPivots(sortedPivots, pivots);
205 Pstream::broadcast(pivots);
209 Pout<<
"new pivots:";
234 if ((pivotI < Pstream::nProcs()) && (sorted[sortedI] > pivots[pivotI]))
236 checkAndSend(sendValues, sendIndices, sendI, destProci);
239 sendValues.setSize(sorted.size());
240 sendIndices.setSize(sorted.size());
247 if (destProci != Pstream::myProcNo())
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);
269 ownValues.setSize(ownI);
270 ownIndices.setSize(ownI);
274 Pout<<
"Not sending (to myself) elements " 275 << ownValues <<
endl;
285 List<taggedValue> combinedValues(2 *
n/Pstream::nProcs());
289 for (
const int proci : Pstream::allProcs())
291 if (proci == Pstream::myProcNo())
295 Pout<<
"Copying from own:" << ownValues <<
endl;
299 copyInto(ownValues, ownIndices, proci, combinedI, combinedValues);
309 Pout<<
"Receiving from " << proci <<
endl;
312 IPstream fromSlave(Pstream::commsTypes::blocking, proci);
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.
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...
Ostream & endl(Ostream &os)
Add newline and flush stream.
#define forAll(list, i)
Loop across all elements in list.
points setSize(newPointi)
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
void setSize(const label n)
Alias for resize()
void sort(UList< T > &list)
Sort the list.
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
ParSortableList(const UList< Type > &)
Construct from List, sorting the elements.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
Implementation of PSRS parallel sorting routine.
List< label > labelList
A List of labels.
void sort()
(stable) sort the list (if changed after construction time)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.