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 const word& compoundType,
82 return tok.readCompoundToken(compoundType, is);
90 inline void Foam::UIPstreamBase::checkEof()
99 inline void Foam::UIPstreamBase::prepareBuffer(
const size_t align)
101 recvBufPos_ =
byteAlign(recvBufPos_, align);
106 inline void Foam::UIPstreamBase::readFromBuffer(
T& val)
108 prepareBuffer(
sizeof(
T));
110 val =
reinterpret_cast<T&
>(recvBuf_[recvBufPos_]);
111 recvBufPos_ +=
sizeof(
T);
116 inline void Foam::UIPstreamBase::readFromBuffer
124 const char*
const __restrict__ buf = &recvBuf_[recvBufPos_];
125 char*
const __restrict__
output =
reinterpret_cast<char*
>(data);
127 for (
size_t i = 0; i <
count; ++i)
133 recvBufPos_ +=
count;
138 inline Foam::Istream& Foam::UIPstreamBase::readString(std::string& str)
148 str.assign(&recvBuf_[recvBufPos_], len);
166 const int fromProcNo,
168 label& receiveBufPosition,
170 const int communicator,
171 const bool clearAtEnd,
177 fromProcNo_(fromProcNo),
181 storedRecvBufPos_(0),
182 clearAtEnd_(clearAtEnd),
183 recvBuf_(receiveBuf),
184 recvBufPos_(receiveBufPosition)
193 const int fromProcNo,
199 fromProcNo_(fromProcNo),
201 comm_(buffers.comm()),
203 storedRecvBufPos_(0),
204 clearAtEnd_(buffers.allowClearRecv()),
205 recvBuf_(buffers.accessRecvBuffer(fromProcNo)),
206 recvBufPos_(buffers.accessRecvPosition(fromProcNo))
215 <<
"PstreamBuffers::finishedSends() never called." <<
endl 216 <<
"Please call PstreamBuffers::finishedSends() after doing" 217 <<
" all your sends (using UOPstream) and before doing any" 237 messageSize_(receiveBuf.size()),
238 storedRecvBufPos_(0),
245 recvBufPos_(storedRecvBufPos_)
256 if (clearAtEnd_ && eof())
260 Perr<<
"UIPstreamBase Destructor : tag:" << tag_
261 <<
" fromProcNo:" << fromProcNo_
262 <<
" clearing receive buffer of size " 264 <<
" messageSize_:" << messageSize_ <<
endl;
266 recvBuf_.clearStorage();
292 t.lineNumber(this->lineNumber());
349 case token::tokenType::WORD :
350 case token::tokenType::DIRECTIVE :
373 case token::tokenType::STRING :
374 case token::tokenType::EXPRESSION :
375 case token::tokenType::VARIABLE :
376 case token::tokenType::VERBATIM :
377 case token::tokenType::CHAR_DATA :
393 case token::tokenType::LABEL :
408 case token::tokenType::FLOAT :
423 case token::tokenType::DOUBLE :
457 c = recvBuf_[recvBufPos_];
466 return readString(str);
472 return readString(str);
504 readRaw(data,
count);
518 readFromBuffer(data,
count);
528 <<
"stream format not binary" 553 if (messageSize_ && (recvBufPos_ < recvBuf_.size()))
555 return (recvBuf_.size() - recvBufPos_);
569 if (recvBuf_.empty() || !messageSize_)
578 os <<
"Reading from processor " << fromProcNo_
579 <<
" using communicator " << comm_
static void processFlags(Istream &is, int flagMask)
Subtract or start of negative number.
static bool isCompound(const word &compoundType)
True if a known (registered) compound type.
Begin block [isseparator].
static Foam::word charToWord(char c)
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
static label byteAlign(const label pos, const size_t align)
bool getBack(token &tok)
Retrieve 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.
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.
stream flag (1-byte bitmask)
virtual bool beginRawRead() override
Start of low-level raw binary read.
Begin dimensions [isseparator].
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
tokenType
Enumeration defining the types of token.
Ostream & endl(Ostream &os)
Add newline and flush stream.
UIPstreamBase(const UPstream::commsTypes commsType, const int fromProcNo, DynamicList< char > &receiveBuf, label &receiveBufPosition, const int tag=UPstream::msgType(), const int communicator=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.
label & recvBufPos_
Reference to the receive position in buffer data.
Begin list [isseparator].
Assignment/equals [isseparator].
End dimensions [isseparator].
bool read(const char *buf, int32_t &val)
Same as readInt32.
void print(Ostream &os) const override
Print stream description to Ostream.
label messageSize_
The message size, read on bufferIPCrecv or set directly.
dimensionedScalar pos(const dimensionedScalar &ds)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
"scheduled" (MPI standard) : (MPI_Send, MPI_Recv)
A class for handling words, derived from Foam::string.
virtual Istream & readRaw(char *data, std::streamsize count) override
Low-level raw binary read. Reading into a null pointer behaves like a forward seek of count character...
punctuationToken
Standard punctuation tokens (a character)
static bool readCompoundToken(token &tok, const word &compoundType, Istream &is)
errorManip< error > abort(error &err)
commsTypes commsType() const noexcept
Get the communications type of the stream.
label remaining() const noexcept
The number of characters remaining in the get buffer.
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
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"))
virtual void rewind() override
Rewind the receive stream position so that it may be read again.
const dimensionedScalar c
Speed of light in a vacuum.
streamFormat
Data format (ascii | binary)
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 setGood() noexcept
Set stream state to be good.
Inter-processor communications stream.
virtual Istream & read(token &) override
Return next token from stream.