40 inline static label
byteAlign(
const label
pos,
const size_t align)
45 ? (align + ((
pos - 1) & ~(align - 1)))
55 inline void Foam::UOPstreamBase::prepareBuffer
78 inline void Foam::UOPstreamBase::writeToBuffer(
const T& val)
80 writeToBuffer(&val,
sizeof(
T),
sizeof(
T));
84 inline void Foam::UOPstreamBase::writeToBuffer
96 prepareBuffer(
count, align);
99 const label
pos = sendBuf_.size();
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)
114 inline void Foam::UOPstreamBase::putChar(
const char c)
116 if (!sendBuf_.capacity())
118 sendBuf_.setCapacity(1024);
120 sendBuf_.push_back(
c);
124 inline void Foam::UOPstreamBase::putString
131 writeToBuffer(str, len, 1);
135 inline void Foam::UOPstreamBase::putString(
const std::string& str)
137 putString(str.data(), str.size());
150 const bool sendAtDestruct,
159 sendAtDestruct_(sendAtDestruct),
173 comm_(buffers.comm()),
174 sendAtDestruct_(buffers.commsType() !=
UPstream::commsTypes::nonBlocking),
175 sendBuf_(buffers.accessSendBuffer(toProcNo))
193 sendAtDestruct_(false),
216 case token::tokenType::FLAG :
218 putChar(token::tokenType::FLAG);
225 case token::tokenType::WORD :
226 case token::tokenType::DIRECTIVE :
235 case token::tokenType::STRING :
236 case token::tokenType::EXPRESSION :
237 case token::tokenType::VARIABLE :
238 case token::tokenType::VERBATIM :
239 case token::tokenType::CHAR_DATA :
275 putChar(token::tokenType::STRING);
279 putChar(token::tokenType::WORD);
289 const word nonWhiteChars(string::validate<word>(str));
291 if (nonWhiteChars.size() == 1)
293 return write(nonWhiteChars[0]);
295 else if (nonWhiteChars.size())
306 putChar(token::tokenType::WORD);
315 putChar(token::tokenType::STRING);
324 putChar(token::tokenType::LABEL);
332 putChar(token::tokenType::LABEL);
340 putChar(token::tokenType::FLOAT);
348 putChar(token::tokenType::DOUBLE);
357 std::streamsize
count 363 <<
"stream format not binary" 377 std::streamsize
count 384 writeToBuffer(data,
count, 1);
395 <<
"stream format not binary" 401 prepareBuffer(
count, 8);
428 os <<
"Writing to processor " << toProcNo_
429 <<
" from processor " << myProcNo() <<
" in communicator " << comm_
void size(const label n)
Older name for setAddressableSize.
static label byteAlign(const label pos, const size_t align)
commsTypes
Communications types.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual Ostream & writeRaw(const char *data, std::streamsize count) override
Low-level raw binary output.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
const word & wordToken() const
Return const reference to the word contents.
A token holds an item read from Istream.
void resize(const label len)
Alter addressable list size, allocating new space if required while recovering old content...
Ostream & endl(Ostream &os)
Add newline and flush stream.
tokenType type() const noexcept
Return the token type.
virtual bool beginRawWrite(std::streamsize count) override
Begin marker for low-level raw binary output.
int flagToken() const
Return flag bitmask value.
dimensionedScalar pos(const dimensionedScalar &ds)
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
UOPstreamBase(const UPstream::commsTypes commsType, const int toProcNo, DynamicList< char > &sendBuf, const int tag=UPstream::msgType(), const label comm=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 Istream & input(Istream &is, IntRange< T > &range)
DynamicList< char > & sendBuf_
Reference to the send buffer data.
virtual void rewind()
Rewind the send buffer for overwriting.
errorManip< error > abort(error &err)
void reserve(const label len)
Reserve allocation space for at least this size, allocating new space if required and retaining old c...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
OBJstream os(runTime.globalPath()/outputName)
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
const string & stringToken() const
Return const reference to the string contents.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
virtual Ostream & writeQuoted(const char *str, std::streamsize len, const bool quoted=true) override
Write character/string content, with/without surrounding quotes.
virtual ~UOPstreamBase()
Destructor.
word format(conversionProperties.get< word >("format"))
void print(Ostream &os) const override
Print stream description to Ostream.
const dimensionedScalar c
Speed of light in a vacuum.
bool isspace(char c) noexcept
Test for whitespace (C-locale)
streamFormat
Data format (ascii | binary)
void setOpened() noexcept
Set stream opened.
void setGood() noexcept
Set stream state to be good.
virtual bool write(const token &tok) override
Write token to stream or otherwise handle it.
Inter-processor communications stream.