40inline static label
byteAlign(
const label
pos,
const size_t align)
45 ? (align + ((
pos - 1) & ~(align - 1)))
55inline void Foam::UOPstreamBase::prepareBuffer
78inline void Foam::UOPstreamBase::writeToBuffer(
const T& val)
80 writeToBuffer(&val,
sizeof(
T),
sizeof(
T));
84inline void Foam::UOPstreamBase::writeToBuffer
96 prepareBuffer(count, align);
99 const label
pos = sendBuf_.size();
102 sendBuf_.resize(
pos + count);
104 char*
const __restrict__ buf = (sendBuf_.data() +
pos);
105 const char*
const __restrict__ input =
reinterpret_cast<const char*
>(data);
107 for (
size_t i = 0; i <
count; ++i)
114inline void Foam::UOPstreamBase::putChar(
const char c)
116 if (!sendBuf_.capacity())
118 sendBuf_.setCapacity(1024);
120 sendBuf_.push_back(c);
124inline void Foam::UOPstreamBase::putString
131 writeToBuffer(str, len, 1);
135inline void Foam::UOPstreamBase::putString(
const std::string& str)
137 putString(str.data(), str.size());
149 const int communicator,
150 const bool sendAtDestruct,
159 sendAtDestruct_(sendAtDestruct),
173 comm_(buffers.comm()),
174 sendAtDestruct_(buffers.commsType() !=
UPstream::commsTypes::nonBlocking),
193 sendAtDestruct_(false),
291 if (nonWhiteChars.size() == 1)
293 return write(nonWhiteChars[0]);
295 else if (nonWhiteChars.size())
373 std::streamsize count
379 <<
"stream format not binary"
384 writeToBuffer(data, count, 8);
393 std::streamsize count
400 writeToBuffer(data, count, 1);
411 <<
"stream format not binary"
417 prepareBuffer(count, 8);
444 os <<
"Writing to processor " << toProcNo_
445 <<
" from processor " << myProcNo() <<
" in communicator " << comm_
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
streamFormat format() const noexcept
Get the current stream format.
streamFormat
Data format (ascii | binary | coherent).
void setGood() noexcept
Set stream state to be good.
void setOpened() noexcept
Set stream opened.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Ostream(const Ostream &)=default
Copy construct.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
DynamicList< char > & sendBuf_
Reference to the send buffer data.
virtual ~UOPstreamBase()
Destructor.
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.
const int comm_
The communicator index.
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 void rewind()
Rewind the send buffer for overwriting.
virtual bool write(const token &tok) override
Write token to stream or otherwise handle it.
Wrapper for internally indexed communicator label. Always invokes UPstream::allocateCommunicatorCompo...
Inter-processor communications stream.
static constexpr int commSelf() noexcept
Communicator within the current rank only.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
commsTypes
Communications types.
static int & msgType() noexcept
Message tag of standard messages.
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
commsTypes commsType() const noexcept
Get the communications type of the stream.
UPstream(const commsTypes commsType) noexcept
Construct for given communication type.
static StringType validate(const std::string &str)
Return a valid String from the given string.
A token holds an item read from Istream.
@ DOUBLE
double (double-precision) type
@ FLAG
stream flag (1-byte bitmask)
@ UNSIGNED_INTEGER_32
uint32 type
@ CHAR_DATA
String-variant: plain character content.
@ FLOAT
float (single-precision) type
@ UNSIGNED_INTEGER_64
uint64 type
@ STRING
Foam::string (usually double-quoted).
const string & stringToken() const
Return const reference to the string contents.
int flagToken() const
Return flag bitmask value.
tokenType type() const noexcept
Return the token type.
const word & wordToken() const
Return const reference to the word contents.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
dimensionedScalar pos(const dimensionedScalar &ds)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr bool isspace(char c) noexcept
Test for whitespace (C-locale only).
Ostream & endl(Ostream &os)
Add newline and flush stream.
static label byteAlign(const label pos, const size_t align)
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
word format(conversionProperties.get< word >("format"))