43#ifndef Foam_UOPstream_H
44#define Foam_UOPstream_H
69 inline void prepareBuffer(
const size_t count,
const size_t align);
73 inline void writeToBuffer(
const T& val);
77 inline void writeToBuffer
85 inline void putChar(
const char c);
88 inline void putString(
const char* str,
const size_t len);
91 inline void putString(
const std::string& str);
126 const bool sendAtDestruct =
true,
152 virtual std::ios_base::fmtflags
flags()
const override
154 return std::ios_base::fmtflags(0);
159 virtual std::ios_base::fmtflags
flags(std::ios_base::fmtflags)
override
161 return std::ios_base::fmtflags(0);
172 virtual bool write(
const token& tok)
override;
182 const bool quoted=
true
193 virtual Ostream&
write(
const std::string& str)
override;
217 std::streamsize count
224 std::streamsize count
239 virtual void indent()
override
246 virtual void flush()
override
250 virtual void endl()
override
255 virtual char fill()
const override
261 virtual char fill(
const char)
override
267 virtual int width()
const override
274 virtual int width(
const int)
override
287 virtual int precision(
const int)
override
319 bool bufferIPCsend();
336 const bool sendAtDestruct =
true,
376 std::streamsize count,
388 inline static bool write
394 std::streamsize count,
402 inline static bool write
416 inline static bool write
430 inline static bool write
443 inline static bool write
471 bool bufferIPCsend();
484 const bool sendAtDestruct =
true,
508 #include "UOPstream.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 Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual Ostream & writeQuoted(const char *str, std::streamsize len, const bool quoted=true)=0
Write character/string content, with/without surrounding quotes.
Ostream(const Ostream &)=default
Copy construct.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
A non-owning sub-view of a List (allocated or unallocated storage).
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Output inter-processor communications stream using MPI broadcast - operating on external buffer.
UOPBstream(DynamicList< char > &sendBuf, const int communicator=UPstream::worldComm, const bool sendAtDestruct=true, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Construct with attached send buffer, optional communication characteristics and IO format.
static void send(Foam::zero, int communicator, int root=0)
Broadcast a zero value (buffer) size that can be matched by the UIPBstream constructor.
virtual ~UOPBstream()
Destructor, usually sends buffer on destruct.
Base class for output inter-processor communications stream (ie, parallel streams)....
virtual int precision() const override
Get precision of output field.
virtual std::ios_base::fmtflags flags() const override
Return current stream flags. Dummy for parallel stream, returns 0.
virtual int width(const int) override
Set width of output field.
DynamicList< char > & sendBuf_
Reference to the send buffer data.
virtual ~UOPstreamBase()
Destructor.
virtual void indent() override
Add indentation characters.
const int toProcNo_
Destination rank for the data.
virtual Ostream & writeQuoted(const char *str, std::streamsize len, const bool quoted=true) override
Write character/string content, with/without surrounding quotes.
bool sendAtDestruct_
Call bufferIPCsend on termination (in the destructor).
void print(Ostream &os) const override
Print stream description to Ostream.
const int tag_
Message tag for communication.
virtual bool endRawWrite() override
End marker for low-level raw binary output.
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 int width() const override
Get width of output field.
UOPstreamBase(const UPstream::commsTypes commsType, const int toProcNo, DynamicList< char > &sendBuf, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, const bool sendAtDestruct=true, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Construct given process index to write to using the given attached send buffer, optional communicatio...
virtual Ostream & writeRaw(const char *data, std::streamsize count) override
Low-level raw binary output.
virtual bool beginRawWrite(std::streamsize count) override
Begin marker for low-level raw binary output.
virtual char fill() const override
Get the current padding character.
virtual void rewind()
Rewind the send buffer for overwriting.
virtual int precision(const int) override
Set precision of output field.
virtual char fill(const char) override
Set padding character for formatted field up to field width.
virtual bool write(const token &tok) override
Write token to stream or otherwise handle it.
virtual void flush() override
Flush stream.
virtual void endl() override
Add newline and flush stream.
Output inter-processor communications stream using MPI send/recv etc. - operating on external buffer.
static bool write(const UPstream::commsTypes commsType, const int toProcNo, const Type *buffer, std::streamsize count, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, UPstream::Request *req=nullptr, const UPstream::sendModes sendMode=UPstream::sendModes::normal)
Write buffer contents (contiguous types only) to given processor.
static bool write(const UPstream::commsTypes commsType, const int toProcNo, const UList< Type > &buffer, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, UPstream::Request *req=nullptr, const UPstream::sendModes sendMode=UPstream::sendModes::normal)
Send UList contiguous contents to given processor.
static bool write(UPstream::Request &req, const int toProcNo, const UList< Type > &buffer, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, const UPstream::sendModes sendMode=UPstream::sendModes::normal)
Send UList contiguous contents (non-blocking) to given processor.
static bool write(const UPstream::commsTypes commsType, const int toProcNo, const SubList< Type > buffer, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, UPstream::Request *req=nullptr, const UPstream::sendModes sendMode=UPstream::sendModes::normal)
Send SubList contiguous contents to given processor.
virtual ~UOPstream()
Destructor, usually sends buffer on destruct.
UOPstream(const UPstream::commsTypes commsType, const int toProcNo, DynamicList< char > &sendBuf, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, const bool sendAtDestruct=true, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Construct given process index to write to using the given attached send buffer, optional communicatio...
static bool write(UPstream::Request &req, const int toProcNo, const SubList< Type > buffer, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, const UPstream::sendModes sendMode=UPstream::sendModes::normal)
Send SubList contiguous contents (non-blocking) to given processor.
static bool write(UPstream::Request &req, const int toProcNo, const Type *buffer, std::streamsize count, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, const UPstream::sendModes sendMode=UPstream::sendModes::normal)
Write buffer contents (contiguous types only) to given processor.
bool send()
Send buffer contents now and not in destructor [advanced usage]. Returns true on success.
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.
sendModes
Different MPI-send modes (ignored for commsTypes::buffered).
@ normal
(MPI_Send, MPI_Isend)
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.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
OBJstream os(runTime.globalPath()/outputName)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)