36 template<
class Container,
class T>
53 if (sendBufs.
size() != UPstream::nProcs(comm))
56 <<
"Size of list " << sendBufs.
size()
57 <<
" does not equal the number of processors " 58 << UPstream::nProcs(comm)
66 if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
68 label startOfRequests = Pstream::nRequests();
75 label nRecv = recvSizes[proci];
77 if (proci != Pstream::myProcNo(comm) && nRecv > 0)
82 UPstream::commsTypes::nonBlocking,
84 reinterpret_cast<char*>(recvBufs[proci].begin()),
98 if (proci != Pstream::myProcNo(comm) && sendBufs[proci].size() > 0)
104 UPstream::commsTypes::nonBlocking,
106 reinterpret_cast<const char*>(sendBufs[proci].begin()),
107 sendBufs[proci].size()*
sizeof(
T),
114 <<
"Cannot send outgoing message. " 115 <<
"to:" << proci <<
" nBytes:" 116 <<
label(sendBufs[proci].size()*
sizeof(
T))
128 Pstream::waitRequests(startOfRequests);
133 recvBufs[Pstream::myProcNo(comm)] = sendBufs[Pstream::myProcNo(comm)];
137 template<
class Container>
140 const Container& sendBufs,
145 if (sendBufs.size() != UPstream::nProcs(comm))
148 <<
"Size of container " << sendBufs.size()
149 <<
" does not equal the number of processors " 150 << UPstream::nProcs(comm)
157 sendSizes[proci] = sendBufs[proci].size();
159 recvSizes.
setSize(sendSizes.size());
160 allToAll(sendSizes, recvSizes, comm);
164 template<
class Container,
class T>
175 exchangeSizes(sendBufs, recvSizes, comm);
177 exchange<Container, T>(sendBufs, recvSizes, recvBufs, tag, comm, block);
#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.
#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...
Template function to specify if the data of a type are contiguous.
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 block=true)
Helper: exchange contiguous data. Sends sendData, receives into.
Combination-Reduction operation for a parallel run. The information from all nodes is collected on th...
static void exchangeSizes(const Container &sendData, labelList &sizes, const label comm=UPstream::worldComm)
Helper: exchange sizes of sendData. sendData is the data per.
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 setSize(const label)
Reset size of List.
label size() const
Return the number of elements in the UList.