39 const commsTypes commsType,
41 DynamicList<char>& externalBuf,
42 label& externalBufPosition,
45 const bool clearAtEnd,
52 fromProcNo_(fromProcNo),
53 externalBuf_(externalBuf),
54 externalBufPosition_(externalBufPosition),
57 clearAtEnd_(clearAtEnd),
63 if (commsType == commsTypes::nonBlocking)
71 label wantedSize = externalBuf_.capacity();
75 Pout<<
"UIPstream::UIPstream : read from:" << fromProcNo
76 <<
" tag:" << tag <<
" comm:" << comm_
77 <<
" wanted size:" << wantedSize
93 MPI_Get_count(&status, MPI_BYTE, &messageSize_);
95 externalBuf_.setCapacity(messageSize_);
96 wantedSize = messageSize_;
100 Pout<<
"UIPstream::UIPstream : probed size:" << wantedSize
109 externalBuf_.begin(),
116 externalBuf_.setSize(messageSize_);
128 UPstream(buffers.commsType_),
129 Istream(buffers.format_, buffers.version_),
130 fromProcNo_(fromProcNo),
131 externalBuf_(buffers.recvBuf_[fromProcNo]),
132 externalBufPosition_(buffers.recvBufPos_[fromProcNo]),
134 comm_(buffers.comm_),
140 commsType() != UPstream::commsTypes::scheduled
141 && !buffers.finishedSendsCalled_
145 <<
"PstreamBuffers::finishedSends() never called." <<
endl
146 <<
"Please call PstreamBuffers::finishedSends() after doing"
147 <<
" all your sends (using UOPstream) and before doing any"
154 if (commsType() == commsTypes::nonBlocking)
157 messageSize_ = buffers.recvBuf_[fromProcNo].size();
161 Pout<<
"UIPstream::UIPstream PstreamBuffers :"
162 <<
" fromProcNo:" << fromProcNo
163 <<
" tag:" << tag_ <<
" comm:" << comm_
164 <<
" receive buffer size:" << messageSize_
172 label wantedSize = externalBuf_.capacity();
176 Pout<<
"UIPstream::UIPstream PstreamBuffers :"
177 <<
" read from:" << fromProcNo
178 <<
" tag:" << tag_ <<
" comm:" << comm_
179 <<
" wanted size:" << wantedSize
194 MPI_Get_count(&status, MPI_BYTE, &messageSize_);
196 externalBuf_.setCapacity(messageSize_);
197 wantedSize = messageSize_;
201 Pout<<
"UIPstream::UIPstream PstreamBuffers : probed size:"
210 externalBuf_.begin(),
217 externalBuf_.setSize(messageSize_);
231 const commsTypes commsType,
232 const int fromProcNo,
234 const std::streamsize bufSize,
236 const label communicator
241 Pout<<
"UIPstream::read : starting read from:" << fromProcNo
242 <<
" tag:" << tag <<
" comm:" << communicator
243 <<
" wanted size:" <<
label(bufSize)
249 Pout<<
"UIPstream::read : starting read from:" << fromProcNo
250 <<
" tag:" << tag <<
" comm:" << communicator
251 <<
" wanted size:" <<
label(bufSize)
277 <<
"MPI_Recv cannot receive incoming message"
287 MPI_Get_count(&status, MPI_BYTE, &messageSize);
291 Pout<<
"UIPstream::read : finished read from:" << fromProcNo
292 <<
" tag:" << tag <<
" read size:" <<
label(bufSize)
297 if (messageSize > bufSize)
300 <<
"buffer (" <<
label(bufSize)
301 <<
") not large enough for incoming message ("
302 << messageSize <<
')'
327 <<
"MPI_Recv cannot start non-blocking receive"
335 Pout<<
"UIPstream::read : started read from:" << fromProcNo
336 <<
" tag:" << tag <<
" read size:" <<
label(bufSize)
350 <<
"Unsupported communications type "
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
UIPstream(const commsTypes commsType, const int fromProcNo, DynamicList< char > &externalBuf, label &externalBufPosition, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, const bool clearAtEnd=false, streamFormat format=BINARY, versionNumber version=currentVersion)
Construct given process index to read from and optional buffer size,.
static label read(const commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=0)
Read into given buffer from given processor and return the.
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
static const NamedEnum< commsTypes, 3 > commsTypeNames
commsTypes commsType() const
Get the communications type of the stream.
static void printStack(Ostream &)
Helper function to print a stack.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
DynamicList< MPI_Comm > MPICommunicators_
DynamicList< MPI_Request > outstandingRequests_
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
prefixOSstream Pout(cout, "Pout")
word format(conversionProperties.lookup("format"))