38template<
class Container,
class T>
39void Foam::Pstream::exchangeContainer
41 const UList<Container>& sendBufs,
42 const labelUList& recvSizes,
43 List<Container>& recvBufs,
62 recvBufs[proci].data_bytes(),
63 recvSizes[proci]*
sizeof(
T),
84 sendBufs[proci].cdata_bytes(),
85 sendBufs[proci].size_bytes(),
92 <<
"Cannot send outgoing message. "
93 <<
"to:" << proci <<
" nBytes:"
94 << label(sendBufs[proci].size_bytes())
112void Foam::Pstream::exchangeBuf
115 const UList<const char*>& sendBufs,
117 List<char*>& recvBufs,
137 recvSizes[proci]*
sizeof(
T),
159 sendSizes[proci]*
sizeof(
T),
166 <<
"Cannot send outgoing message. "
167 <<
"to:" << proci <<
" nBytes:"
168 << label(sendSizes[proci]*
sizeof(
T))
185template<
class Container,
class T>
206 <<
"Size of list " << sendBufs.
size()
207 <<
" does not equal the number of processors "
219 const label nRecv = recvSizes[proci];
230 exchangeContainer<Container, T>
255 const label maxChunkSize
259 static_cast<label
>(1),
271 nChunks =
max(nChunks, sendBufs[proci].size());
279 nChunks = 1 + (nChunks/maxChunkSize);
292 for (label iter = 0; iter < nChunks; ++iter)
299 sendBufs[proci].size()-startSend[proci]
304 recvBufs[proci].size()-startRecv[proci]
310 ?
reinterpret_cast<const char*
>
312 &(sendBufs[proci][startSend[proci]])
319 ?
reinterpret_cast<char*
>
321 &(recvBufs[proci][startRecv[proci]])
344 startSend[proci] += nSend[proci];
345 startRecv[proci] += nRecv[proci];
356template<
class Container>
361 const Container& sendBufs,
370 <<
"Size of container " << sendBufs.size()
371 <<
" does not equal the number of processors "
379 sendSizes[i] = sendBufs[sendProcs[i]].
size();
387 for (
const label proci : recvProcs)
393 reinterpret_cast<char*
>(&recvSizes[proci]),
406 reinterpret_cast<char*
>(&sendSizes[i]),
433template<
class Container>
436 const Container& sendBufs,
444 <<
"Size of container " << sendBufs.size()
445 <<
" does not equal the number of processors "
453 sendSizes[proci] = sendBufs[proci].
size();
460template<
class Container,
class T>
471 exchangeSizes(sendBufs, recvSizes, comm);
473 exchange<Container, T>(sendBufs, recvSizes, recvBufs, tag, comm, wait);
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...
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
label nProcs() const noexcept
Number of ranks associated with PstreamBuffers.
static void exchangeSizes(const labelUList &sendProcs, const labelUList &recvProcs, const Container &sendData, labelList &sizes, const label tag=UPstream::msgType(), const label comm=UPstream::worldComm)
static void exchange(const UList< Container > &sendData, const labelUList &recvSizes, List< Container > &recvData, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, const bool wait=true)
virtual bool read()
Re-read model coefficients if they have changed.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
@ nonBlocking
"nonBlocking"
static label nRequests()
Get number of outstanding requests.
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
static void allToAll(const UList< int32_t > &sendData, UList< int32_t > &recvData, const label communicator=worldComm)
Exchange integer data with all processors (in the communicator).
static int maxCommsSize
Optional maximum message size (bytes)
static bool & parRun() noexcept
Test if this a parallel run.
virtual bool write()
Write the output fields.
int myProcNo() const noexcept
Return processor number.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0)
UList< label > labelUList
A UList of labels.
#define forAll(list, i)
Loop across all elements in list.
A template class to specify that a data type can be considered as being contiguous in memory.