41 template<
class T,
class BinaryOp>
58 for (
const label belowID : myComm.below())
68 reinterpret_cast<char*>(&received),
79 value = bop(value, received);
83 if (myComm.above() >= 0)
91 reinterpret_cast<const char*
>(&value),
128 allValues.resize(numProc);
131 if (is_contiguous<T>::value)
135 reinterpret_cast<const char*>(&localValue),
136 allValues.data_bytes(),
149 allValues[0] = localValue;
151 for (
int proci = 1; proci < numProc; ++proci)
167 allValues[0] = localValue;
197 <<
"Attempting to send " << allValues.
size()
198 <<
" values to " << numProc <<
" processors" <<
endl 202 if (is_contiguous<T>::value)
207 reinterpret_cast<char*
>(&localValue),
218 List<DynamicList<char>> sendBuffers(numProc);
220 for (
int proci = 1; proci < numProc; ++proci)
230 toProc << allValues[proci];
249 if (!allValues.
empty())
void size(const label n)
Older name for setAddressableSize.
static T listScatterValues(const UList< T > &allValues, const label comm=UPstream::worldComm, const int tag=UPstream::msgType())
Scatter individual values from list locations.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static label nRequests() noexcept
Number of outstanding requests (on the internal list of requests)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static const List< commsStruct > & whichCommunication(const label communicator=worldComm)
Communication schedule for all-to-master (proc 0) as linear/tree/none with switching based on UPstrea...
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
static List< T > listGatherValues(const T &localValue, const label comm=UPstream::worldComm, const int tag=UPstream::msgType())
Gather individual values into list locations.
static void waitRequests()
Wait for all requests to finish.
const char * cdata_bytes() const noexcept
Return pointer to the underlying array serving as data storage,.
static void gather(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Gather (reduce) data, applying bop to combine value from different processors. The basis for Foam::re...
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
static void recv(Type &value, const int fromProcNo, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Receive and deserialize a value. Uses operator>> for de-serialization.
static bool is_rank(const label communicator=worldComm)
True if process corresponds to any rank (master or sub-rank) in the given communicator.
"scheduled" (MPI standard) : (MPI_Send, MPI_Recv)
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
static bool is_parallel(const label communicator=worldComm)
True if parallel algorithm or exchange is required.
static void mpiGather(const char *sendData, char *recvData, int count, const label communicator=worldComm)
Receive identically-sized char data from all ranks.
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
static void mpiScatter(const char *sendData, char *recvData, int count, const label communicator=worldComm)
Send identically-sized char data to all ranks.
A template class to specify that a data type can be considered as being contiguous in memory...
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
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, UPstream::Request *req=nullptr, const UPstream::sendModes sendMode=UPstream::sendModes::normal)
Write buffer contents to given processor.
"nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
bool send()
Send buffer contents now and not in destructor [advanced usage]. Returns true on success.
static std::streamsize read(const UPstream::commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, UPstream::Request *req=nullptr)
Read buffer contents from given processor.