43#ifndef Foam_UIPstream_H
44#define Foam_UIPstream_H
68 inline void checkEof();
71 inline void prepareBuffer(
const size_t align);
75 inline void readFromBuffer(
T& val);
80 inline void readFromBuffer(
void* data,
const size_t count);
83 inline Istream& readString(std::string& str);
124 const int fromProcNo,
126 label& receiveBufPosition,
129 const bool clearAtEnd =
false,
157 virtual std::ios_base::fmtflags
flags()
const override
159 return std::ios_base::fmtflags(0);
164 virtual std::ios_base::fmtflags
flags(std::ios_base::fmtflags)
override
166 return std::ios_base::fmtflags(0);
208 virtual
Istream&
read(
char* data, std::streamsize count) override;
213 virtual
Istream&
readRaw(
char* data, std::streamsize count) override;
219 virtual
bool endRawRead()
override {
return true; }
225 virtual void rewind()
override;
248 void bufferIPCrecv();
261 const int fromProcNo,
262 DynamicList<char>& receiveBuf,
263 label& receiveBufPosition,
266 const bool clearAtEnd =
false,
271 UIPstream(
const int fromProcNo, PstreamBuffers& buffers);
279 const DynamicList<char>& recvBuf,
299 static std::streamsize
read
302 const int fromProcNo,
304 std::streamsize count,
314 inline static std::streamsize
read
318 const int fromProcNo,
320 std::streamsize count,
327 inline static std::streamsize
read
330 const int fromProcNo,
340 inline static std::streamsize
read
343 const int fromProcNo,
353 inline static std::streamsize
read
357 const int fromProcNo,
365 inline static std::streamsize
read
369 const int fromProcNo,
390 void bufferIPCrecv();
402 label& receiveBufPosition,
404 const bool clearAtEnd =
false,
421 #include "UIPstream.txx"
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
streamFormat
Data format (ascii | binary | coherent).
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Istream(const Istream &)=default
Copy construct.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Buffers for inter-processor communications streams (UOPstream, UIPstream).
A non-owning sub-view of a List (allocated or unallocated storage).
Input inter-processor communications stream using MPI broadcast - operating on external buffer.
UIPBstream(DynamicList< char > &receiveBuf, label &receiveBufPosition, const int communicator=UPstream::worldComm, const bool clearAtEnd=false, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Construct using the given attached receive buffer,.
virtual ~UIPBstream()=default
Destructor.
virtual std::ios_base::fmtflags flags() const override
Return current stream flags. Dummy for parallel stream, returns 0.
label storedRecvBufPos_
Receive position in buffer data, if ony If there is no external location for recvBufPos_.
virtual void rewind() override
Rewind the receive stream position so that it may be read again.
virtual Istream & read(token &) override
Return next token from stream.
const int fromProcNo_
Source rank for the data.
virtual bool endRawRead() override
End of low-level raw binary read.
void print(Ostream &os) const override
Print stream description to Ostream.
label remaining() const noexcept
The number of characters remaining in the get buffer.
const int tag_
Message tag for communication.
virtual std::ios_base::fmtflags flags(std::ios_base::fmtflags) override
Set stream flags, return old stream flags. Dummy for parallel stream, returns 0.
const int comm_
The communicator index.
virtual bool beginRawRead() override
Start of low-level raw binary read.
label messageSize_
The message size, read on bufferIPCrecv or set directly.
UIPstreamBase(const UPstream::commsTypes commsType, const int fromProcNo, DynamicList< char > &receiveBuf, label &receiveBufPosition, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, const bool clearAtEnd=false, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Construct given process index to read from using the given attached receive buffer,...
const bool clearAtEnd_
Clear the receive buffer on termination (in the destructor).
virtual ~UIPstreamBase()
Destructor. Optionally clears external receive buffer.
DynamicList< char > & recvBuf_
Reference to the receive buffer data.
virtual Istream & readRaw(char *data, std::streamsize count) override
Low-level raw binary read. Reading into a null pointer behaves like a forward seek of count character...
label & recvBufPos_
Reference to the receive position in buffer data.
static std::streamsize read(const UPstream::commsTypes commsType, const int fromProcNo, Type *buffer, std::streamsize count, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, UPstream::Request *req=nullptr)
Receive buffer contents (contiguous types) from given processor.
static std::streamsize read(const UPstream::commsTypes commsType, const int fromProcNo, SubList< Type > buffer, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, UPstream::Request *req=nullptr)
Receive into SubList storage from given processor.
static std::streamsize read(UPstream::Request &req, const int fromProcNo, Type *buffer, std::streamsize count, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Read buffer contents (non-blocking) from given processor.
static std::streamsize read(UPstream::Request &req, const int fromProcNo, SubList< Type > buffer, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Receive into SubList storage (non-blocking) from given processor.
static std::streamsize read(UPstream::Request &req, const int fromProcNo, UList< Type > &buffer, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Receive into UList storage (non-blocking) from given processor.
virtual ~UIPstream()=default
Destructor.
UIPstream(const UPstream::commsTypes commsType, const int fromProcNo, DynamicList< char > &receiveBuf, label &receiveBufPosition, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, const bool clearAtEnd=false, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Construct given process index to read from using the given attached receive buffer,...
static std::streamsize read(const UPstream::commsTypes commsType, const int fromProcNo, UList< Type > &buffer, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, UPstream::Request *req=nullptr)
Receive into UList storage from given processor.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
An opaque wrapper for MPI_Request with a vendor-independent representation without any <mpi....
Wrapper for internally indexed communicator label. Always invokes UPstream::allocateCommunicatorCompo...
commsTypes
Communications types.
static int & msgType() noexcept
Message tag of standard messages.
commsTypes commsType() const noexcept
Get the communications type of the stream.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
UPstream(const commsTypes commsType) noexcept
Construct for given communication type.
A token holds an item read from Istream.
A class for handling words, derived from Foam::string.
OBJstream os(runTime.globalPath()/outputName)
bool read(const char *buf, int32_t &val)
Same as readInt32.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)