46 template<
class T,
class CombineOp>
62 for (
const label belowID : myComm.
below())
72 reinterpret_cast<char*>(&received),
80 Pout<<
" received from " 81 << belowID <<
" data:" << received <<
endl;
96 T received(fromBelow);
100 Pout<<
" received from " 101 << belowID <<
" data:" << received <<
endl;
104 cop(value, received);
109 if (myComm.
above() != -1)
114 <<
" data:" << value <<
endl;
123 reinterpret_cast<const char*
>(&value),
149 const List<UPstream::commsStruct>& comms,
155 #ifndef Foam_Pstream_scatter_nobroadcast 164 if (myComm.above() != -1)
166 if (is_contiguous<T>::value)
172 reinterpret_cast<char*
>(&value),
188 value =
T(fromAbove);
195 const label belowID = myComm.below()[belowI];
197 if (is_contiguous<T>::value)
203 reinterpret_cast<const char*>(&value),
227 template<
class T,
class CombineOp>
231 const CombineOp& cop,
255 #ifndef Foam_Pstream_scatter_nobroadcast 269 template<
class T,
class CombineOp>
274 const CombineOp& cop,
284 template<
class T,
class CombineOp>
288 const CombineOp& cop,
305 template<
class T,
class CombineOp>
310 const CombineOp& cop,
321 for (
const label belowID : myComm.
below())
331 received.data_bytes(),
332 received.size_bytes(),
339 Pout<<
" received from " 340 << belowID <<
" data:" << received <<
endl;
345 cop(
values[i], received[i]);
362 Pout<<
" received from " 363 << belowID <<
" data:" << received <<
endl;
368 cop(
values[i], received[i]);
374 if (myComm.
above() != -1)
414 const List<UPstream::commsStruct>& comms,
420 #ifndef Foam_Pstream_scatter_nobroadcast 429 if (myComm.above() != -1)
431 if (is_contiguous<T>::value)
460 const label belowID = myComm.below()[belowI];
462 if (is_contiguous<T>::value)
492 template<
class T,
class CombineOp>
496 const CombineOp& cop,
520 #ifndef Foam_Pstream_scatter_nobroadcast 534 template<
class T,
class CombineOp>
538 const CombineOp& cop,
555 template<
class Container,
class CombineOp>
560 const CombineOp& cop,
571 for (
const label belowID : myComm.
below())
583 Container received(fromBelow);
587 Pout<<
" received from " 588 << belowID <<
" data:" << received <<
endl;
593 auto recvIter = received.cbegin();
594 recvIter != received.cend();
598 auto masterIter =
values.find(recvIter.key());
600 if (masterIter !=
values.end())
603 cop(masterIter.val(), recvIter.val());
608 values.insert(recvIter.key(), recvIter.val());
614 if (myComm.
above() != -1)
636 template<
class Container>
639 const List<UPstream::commsStruct>& comms,
645 #ifndef Foam_Pstream_scatter_nobroadcast 654 if (myComm.above() != -1)
668 Pout<<
" received from " 669 << myComm.above() <<
" data:" <<
values <<
endl;
676 const label belowID = myComm.below()[belowI];
698 template<
class Container,
class CombineOp>
702 const CombineOp& cop,
718 template<
class Container>
726 #ifndef Foam_Pstream_scatter_nobroadcast 740 template<
class Container,
class CombineOp>
744 const CombineOp& cop,
const labelList & below() const noexcept
The procIDs of all processors directly below.
static void mapCombineGather(const List< commsStruct > &comms, Container &values, const CombineOp &cop, const int tag, const label comm)
static bool write(const UPstream::commsTypes commsType, const int toProcNo, const char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Write buffer contents to given processor.
static void combineScatter(const List< commsStruct > &comms, T &value, const int tag, const label comm)
Broadcast data: Distribute without modification.
static void mapCombineScatter(const List< commsStruct > &comms, Container &values, const int tag, const label comm)
Broadcast data: Distribute without modification.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
static const List< commsStruct > & whichCommunication(const label communicator=worldComm)
Communication schedule for linear/tree all-to-master (proc 0). Chooses based on the value of UPstream...
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
label above() const noexcept
The procID of the processor directly above.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all processes in communicator.
#define forAll(list, i)
Loop across all elements in list.
Input inter-processor communications stream.
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator) is 1 for serial run.
static void combineGather(const List< commsStruct > &comms, T &value, const CombineOp &cop, const int tag, const label comm)
Gather data, applying cop to inplace combine value from different processors.
"scheduled" : (MPI_Send, MPI_Recv)
static void listCombineScatter(const List< commsStruct > &comms, List< T > &value, const int tag, const label comm)
Broadcast data: Distribute without modification.
Structure for communicating between processors.
static void combineReduce(const List< commsStruct > &comms, T &value, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) applying cop to inplace combine value from different processors...
int debug
Static debugging option.
Output inter-processor communications stream.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
A template class to specify that a data type can be considered as being contiguous in memory...
static void listCombineGather(const List< commsStruct > &comms, List< T > &values, const CombineOp &cop, const int tag, const label comm)
#define forAllReverse(list, i)
Reverse loop across all elements in list.
static void mapCombineReduce(Container &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) applying cop to inplace combine map values from different processo...
static label read(const commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Read buffer contents from given processor.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
static void listCombineReduce(List< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
After completion all processors have the same data.