48 inline static void processFlags(Istream& is,
int flagMask)
62 inline static label
byteAlign(
const label
pos,
const size_t align)
67 ? (align + ((
pos - 1) & ~(align - 1)))
77 inline void Foam::UIPstreamBase::checkEof()
86 inline void Foam::UIPstreamBase::prepareBuffer(
const size_t align)
88 recvBufPos_ =
byteAlign(recvBufPos_, align);
93 inline void Foam::UIPstreamBase::readFromBuffer(
T& val)
95 prepareBuffer(
sizeof(
T));
97 val =
reinterpret_cast<T&
>(recvBuf_[recvBufPos_]);
98 recvBufPos_ +=
sizeof(
T);
103 inline void Foam::UIPstreamBase::readFromBuffer
109 const char*
const __restrict__ buf = &recvBuf_[recvBufPos_];
110 char*
const __restrict__
output =
reinterpret_cast<char*
>(data);
112 for (
size_t i = 0; i <
count; ++i)
117 recvBufPos_ +=
count;
122 inline Foam::Istream& Foam::UIPstreamBase::readString(std::string& str)
132 str.assign(&recvBuf_[recvBufPos_], len);
149 const commsTypes commsType,
150 const int fromProcNo,
152 label& receiveBufPosition,
155 const bool clearAtEnd,
161 fromProcNo_(fromProcNo),
162 recvBuf_(receiveBuf),
163 recvBufPos_(receiveBufPosition),
166 clearAtEnd_(clearAtEnd),
176 const int fromProcNo,
182 fromProcNo_(fromProcNo),
183 recvBuf_(buffers.recvBuf_[fromProcNo]),
184 recvBufPos_(buffers.recvBufPos_[fromProcNo]),
186 comm_(buffers.comm()),
187 clearAtEnd_(buffers.allowClearRecv()),
197 <<
"PstreamBuffers::finishedSends() never called." <<
endl 198 <<
"Please call PstreamBuffers::finishedSends() after doing" 199 <<
" all your sends (using UOPstream) and before doing any" 212 if (clearAtEnd_ && eof())
216 Pout<<
"UIPstreamBase Destructor : tag:" << tag_
217 <<
" fromProcNo:" << fromProcNo_
218 <<
" clearing receive buffer of size " 220 <<
" messageSize_:" << messageSize_ <<
endl;
222 recvBuf_.clearStorage();
276 t.lineNumber(this->lineNumber());
302 case token::tokenType::WORD :
303 case token::tokenType::DIRECTIVE :
326 case token::tokenType::STRING :
327 case token::tokenType::EXPRESSION :
328 case token::tokenType::VARIABLE :
329 case token::tokenType::VERBATIM :
345 case token::tokenType::LABEL :
360 case token::tokenType::FLOAT :
375 case token::tokenType::DOUBLE :
409 c = recvBuf_[recvBufPos_];
418 return readString(str);
424 return readString(str);
480 <<
"stream format not binary" 509 if (recvBuf_.empty() || !messageSize_)
518 os <<
"Reading from processor " << fromProcNo_
519 <<
" using communicator " << comm_
520 <<
" and tag " << tag_
static void processFlags(Istream &is, int flagMask)
Subtract or start of negative number.
Begin block [isseparator].
static Foam::word charToWord(char c)
static label byteAlign(const label pos, const size_t align)
bool getBack(token &tok)
Get the put-back token if there is one.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual ~UIPstreamBase()
Destructor. Optionally clears external receive buffer.
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.
stream flag (1-byte bitmask)
Begin dimensions [isseparator].
bool beginRawRead()
Start of low-level raw binary read.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
UIPstreamBase(const commsTypes commsType, const int fromProcNo, DynamicList< char > &receiveBuf, label &receiveBufPosition, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, const bool clearAtEnd=false, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Construct given process index to read from using the given attached receive buffer, optional communication characteristics and IO format.
tokenType
Enumeration defining the types of token.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Begin list [isseparator].
Assignment/equals [isseparator].
End dimensions [isseparator].
bool read(const char *buf, int32_t &val)
Same as readInt32.
dimensionedScalar pos(const dimensionedScalar &ds)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Istream & read(token &t)
Return next token from stream.
"scheduled" : (MPI_Send, MPI_Recv)
A class for handling words, derived from Foam::string.
punctuationToken
Standard punctuation tokens (a character)
static autoPtr< compound > New(const word &type, Istream &is)
Construct compound from Istream.
errorManip< error > abort(error &err)
commsTypes commsType() const noexcept
Get the communications type of the stream.
int debug
Static debugging option.
static bool isCompound(const word &name)
Test if name is a known (registered) compound type.
OBJstream os(runTime.globalPath()/outputName)
Database for solution data, solver performance and other reduced data.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
bool finished() const noexcept
True if finishedSends() or finishedNeighbourSends() has been called.
word format(conversionProperties.get< word >("format"))
const dimensionedScalar c
Speed of light in a vacuum.
streamFormat
Data format (ascii | binary)
Istream & readRaw(char *data, std::streamsize count)
Low-level raw binary read.
static Ostream & output(Ostream &os, const IntRange< T > &range)
void setOpened() noexcept
Set stream opened.
void setEof() noexcept
Set stream state as reached 'eof'.
void print(Ostream &os) const
Print stream description to Ostream.
void setGood() noexcept
Set stream state to be good.
virtual void rewind()
Rewind the receive stream position so that it may be read again.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Inter-processor communications stream.