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(1000);
124 inline void Foam::UOPstreamBase::putString(
const std::string& str)
126 const size_t len = str.size();
128 writeToBuffer(str.data(), len, 1);
136 const commsTypes commsType,
141 const bool sendAtDestruct,
151 sendAtDestruct_(sendAtDestruct)
163 sendBuf_(buffers.sendBuf_[toProcNo]),
165 comm_(buffers.comm()),
166 sendAtDestruct_(buffers.commsType() !=
UPstream::commsTypes::nonBlocking)
187 case token::tokenType::FLAG :
189 putChar(token::tokenType::FLAG);
196 case token::tokenType::WORD :
197 case token::tokenType::DIRECTIVE :
206 case token::tokenType::STRING :
207 case token::tokenType::EXPRESSION :
208 case token::tokenType::VARIABLE :
209 case token::tokenType::VERBATIM :
238 const word nonWhiteChars(string::validate<word>(str));
240 if (nonWhiteChars.size() == 1)
242 return write(nonWhiteChars[0]);
244 else if (nonWhiteChars.size())
255 putChar(token::tokenType::WORD);
264 putChar(token::tokenType::STRING);
273 const std::string& str,
279 putChar(token::tokenType::STRING);
283 putChar(token::tokenType::WORD);
293 putChar(token::tokenType::LABEL);
301 putChar(token::tokenType::LABEL);
309 putChar(token::tokenType::FLOAT);
317 putChar(token::tokenType::DOUBLE);
326 std::streamsize
count 332 <<
"stream format not binary" 346 std::streamsize
count 364 <<
"stream format not binary" 370 prepareBuffer(
count, 8);
397 os <<
"Writing from processor " << toProcNo_
398 <<
" to processor " << myProcNo() <<
" in communicator " << comm_
void size(const label n)
Older name for setAddressableSize.
static label byteAlign(const label pos, const size_t align)
virtual bool write(const token &tok)
Write token to stream or otherwise handle it.
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.
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.
UOPstreamBase(const 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...
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.
virtual bool beginRawWrite(std::streamsize count)
Begin marker for low-level raw binary output.
void print(Ostream &os) const
Print stream description to Ostream.
static Istream & input(Istream &is, IntRange< T > &range)
virtual Ostream & writeQuoted(const std::string &str, const bool quoted=true)
Write std::string surrounded by quotes.
DynamicList< char > & sendBuf_
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)
Database for solution data, solver performance and other reduced data.
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 ~UOPstreamBase()
Destructor.
word format(conversionProperties.get< word >("format"))
virtual Ostream & writeRaw(const char *data, std::streamsize count)
Low-level raw binary output.
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.
Inter-processor communications stream.