59 if (
values.size() < numProc)
62 <<
"List of values:" <<
values.size()
63 <<
" < numProcs:" << numProc <<
nl 68 const auto& myComm = comms[myProci];
71 for (
const label belowID : myComm.below())
73 const labelList& belowLeaves = comms[belowID].allBelow();
83 received.data_bytes(),
84 received.size_bytes(),
89 values[belowID] = received[0];
93 values[belowLeaves[leafI]] = received[leafI + 1];
106 fromBelow >>
values[belowID];
110 Perr<<
" received through " 111 << belowID <<
" data from:" << belowID
116 for (
const label leafID : belowLeaves)
118 fromBelow >>
values[leafID];
122 Perr<<
" received through " 123 << belowID <<
" data from:" << leafID
133 if (myComm.above() >= 0)
135 const labelList& belowLeaves = myComm.allBelow();
139 Perr<<
" sending to " << myComm.above()
140 <<
" data from me:" << myProci
147 sending[0] =
values[myProci];
149 forAll(belowLeaves, leafI)
151 sending[leafI + 1] =
values[belowLeaves[leafI]];
174 toAbove <<
values[myProci];
176 for (
const label leafID : belowLeaves)
180 Perr<<
" sending to " 181 << myComm.above() <<
" data from:" << leafID
184 toAbove <<
values[leafID];
195 const UList<UPstream::commsStruct>& comms,
210 if (
values.size() < numProc)
213 <<
"List of values:" <<
values.size()
214 <<
" < numProcs:" << numProc <<
nl 219 const auto& myComm = comms[myProci];
222 if (myComm.above() >= 0)
224 const labelList& notBelowLeaves = myComm.allNotBelow();
226 if (is_contiguous<T>::value)
228 List<T> received(notBelowLeaves.size());
234 received.data_bytes(),
235 received.size_bytes(),
240 forAll(notBelowLeaves, leafI)
242 values[notBelowLeaves[leafI]] = received[leafI];
256 for (
const label leafID : notBelowLeaves)
258 fromAbove >>
values[leafID];
262 Perr<<
" received through " 263 << myComm.above() <<
" data for:" << leafID
273 const label belowID = myComm.below()[belowI];
274 const labelList& notBelowLeaves = comms[belowID].allNotBelow();
276 if (is_contiguous<T>::value)
278 List<T> sending(notBelowLeaves.size());
280 forAll(notBelowLeaves, leafI)
282 sending[leafI] =
values[notBelowLeaves[leafI]];
289 sending.cdata_bytes(),
290 sending.size_bytes(),
307 for (
const label leafID : notBelowLeaves)
309 toBelow <<
values[leafID];
313 Perr<<
" sent through " 314 << belowID <<
" data for:" << leafID
376 <<
"List of values is too small:" <<
values.size()
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
void size(const label n)
Older name for setAddressableSize.
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.
static void scatterList(const UList< commsStruct > &comms, UList< T > &values, const int tag, const label comm)
Inverse of gatherList. Uses the specified communication schedule.
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void gatherList(const UList< commsStruct > &comms, UList< T > &values, const int tag, const label comm)
Gather data, but keep individual values separate. Uses the specified communication schedule...
static void mpiAllGather(char *allData, int count, const label communicator=worldComm)
Gather/scatter identically-sized char data.
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...
#define forAll(list, i)
Loop across all elements in list.
Input inter-processor communications stream.
const char * cdata_bytes() const noexcept
Return pointer to the underlying array serving as data storage,.
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). It is 1 for serial run. ...
"scheduled" (MPI standard) : (MPI_Send, MPI_Recv)
static bool is_parallel(const label communicator=worldComm)
True if parallel algorithm or exchange is required.
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...
int debug
Static debugging option.
Output inter-processor communications stream.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
static void allGatherList(UList< T > &values, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Gather data, but keep individual values separate. Uses MPI_Allgather or manual linear/tree communicat...
A template class to specify that a data type can be considered as being contiguous in memory...
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.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
List< label > labelList
A List of labels.
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the List data.
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.