43 template<
class T,
class CombineOp>
53 if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
56 const commsStruct& myComm = comms[UPstream::myProcNo(comm)];
70 reinterpret_cast<char*>(&value),
78 Pout<<
" received from " 79 << belowID <<
" data:" << value <<
endl;
86 IPstream fromBelow(UPstream::scheduled, belowID, 0, tag, comm);
91 Pout<<
" received from " 92 << belowID <<
" data:" << value <<
endl;
100 if (myComm.
above() != -1)
105 <<
" data:" << Value <<
endl;
114 reinterpret_cast<const char*
>(&Value),
137 template<
class T,
class CombineOp>
141 const CombineOp& cop,
146 if (UPstream::nProcs(comm) < UPstream::nProcsSimpleSum)
150 UPstream::linearCommunication(comm),
161 UPstream::treeCommunication(comm),
180 if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
186 if (myComm.
above() != -1)
194 reinterpret_cast<char*
>(&Value),
210 Value =
T(fromAbove);
215 Pout<<
" received from " 216 << myComm.
above() <<
" data:" << Value <<
endl;
227 Pout<<
" sending to " << belowID <<
" data:" << Value <<
endl;
236 reinterpret_cast<const char*>(&Value),
244 OPstream toBelow(UPstream::scheduled, belowID, 0, tag, comm);
260 if (UPstream::nProcs(comm) < UPstream::nProcsSimpleSum)
262 combineScatter(UPstream::linearCommunication(comm), Value, tag, comm);
266 combineScatter(UPstream::treeCommunication(comm), Value, tag, comm);
271 template<
class T,
class CombineOp>
276 const CombineOp& cop,
281 if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
284 const commsStruct& myComm = comms[UPstream::myProcNo(comm)];
299 reinterpret_cast<char*>(receivedValues.begin()),
300 receivedValues.byteSize(),
307 Pout<<
" received from " 308 << belowID <<
" data:" << receivedValues <<
endl;
313 cop(Values[i], receivedValues[i]);
318 IPstream fromBelow(UPstream::scheduled, belowID, 0, tag, comm);
319 List<T> receivedValues(fromBelow);
323 Pout<<
" received from " 324 << belowID <<
" data:" << receivedValues <<
endl;
329 cop(Values[i], receivedValues[i]);
335 if (myComm.
above() != -1)
340 <<
" data:" << Values <<
endl;
349 reinterpret_cast<const char*
>(Values.
begin()),
372 template<
class T,
class CombineOp>
376 const CombineOp& cop,
381 if (UPstream::nProcs(comm) < UPstream::nProcsSimpleSum)
385 UPstream::linearCommunication(comm),
396 UPstream::treeCommunication(comm),
415 if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
421 if (myComm.
above() != -1)
429 reinterpret_cast<char*
>(Values.
begin()),
450 Pout<<
" received from " 451 << myComm.
above() <<
" data:" << Values <<
endl;
462 Pout<<
" sending to " << belowID <<
" data:" << Values <<
endl;
471 reinterpret_cast<const char*>(Values.
begin()),
479 OPstream toBelow(UPstream::scheduled, belowID, 0, tag, comm);
495 if (UPstream::nProcs(comm) < UPstream::nProcsSimpleSum)
499 UPstream::linearCommunication(comm),
509 UPstream::treeCommunication(comm),
518 template<
class Container,
class CombineOp>
523 const CombineOp& cop,
528 if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
531 const commsStruct& myComm = comms[UPstream::myProcNo(comm)];
538 IPstream fromBelow(UPstream::scheduled, belowID, 0, tag, comm);
539 Container receivedValues(fromBelow);
543 Pout<<
" received from " 544 << belowID <<
" data:" << receivedValues <<
endl;
549 typename Container::const_iterator slaveIter =
550 receivedValues.begin();
551 slaveIter != receivedValues.end();
555 typename Container::iterator
556 masterIter = Values.find(slaveIter.key());
558 if (masterIter != Values.end())
560 cop(masterIter(), slaveIter());
564 Values.insert(slaveIter.key(), slaveIter());
570 if (myComm.
above() != -1)
575 <<
" data:" << Values <<
endl;
578 OPstream toAbove(UPstream::scheduled, myComm.
above(), 0, tag, comm);
585 template<
class Container,
class CombineOp>
589 const CombineOp& cop,
594 if (UPstream::nProcs(comm) < UPstream::nProcsSimpleSum)
598 UPstream::linearCommunication(comm),
609 UPstream::treeCommunication(comm),
619 template<
class Container>
628 if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
634 if (myComm.
above() != -1)
648 Pout<<
" received from " 649 << myComm.
above() <<
" data:" << Values <<
endl;
660 Pout<<
" sending to " << belowID <<
" data:" << Values <<
endl;
663 OPstream toBelow(UPstream::scheduled, belowID, 0, tag, comm);
670 template<
class Container>
678 if (UPstream::nProcs(comm) < UPstream::nProcsSimpleSum)
682 UPstream::linearCommunication(comm),
692 UPstream::treeCommunication(comm),
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
#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.
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.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Template function to specify if the data of a type are contiguous.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
static void mapCombineScatter(const List< commsStruct > &comms, Container &Values, const int tag, const label comm)
Scatter data. Reverse of combineGather.
Input inter-processor communications stream.
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
std::streamsize byteSize() const
Return the binary size in number of characters of the UList.
bool read(const char *, int32_t &)
static void combineGather(T &Value, const CombineOp &cop, const int tag=Pstream::msgType(), const label comm=Pstream::worldComm)
Like above but switches between linear/tree communication.
iterator begin()
Return an iterator to begin traversing the UList.
static void combineGather(const List< commsStruct > &comms, T &Value, const CombineOp &cop, const int tag, const label comm)
static void mapCombineGather(const List< commsStruct > &comms, Container &Values, const CombineOp &cop, const int tag, const label comm)
Structure for communicating between processors.
prefixOSstream Pout(cout,"Pout")
Output inter-processor communications stream.
const labelList & below() const
static void combineScatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.