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
111 const char*
const __restrict__ buf = &recvBuf_[recvBufPos_];
112 char*
const __restrict__
output =
reinterpret_cast<char*
>(data);
114 for (
size_t i = 0; i <
count; ++i)
120 recvBufPos_ +=
count;
125 inline Foam::Istream& Foam::UIPstreamBase::readString(std::string& str)
135 str.assign(&recvBuf_[recvBufPos_], len);
153 const int fromProcNo,
155 label& receiveBufPosition,
158 const bool clearAtEnd,
164 fromProcNo_(fromProcNo),
168 storedRecvBufPos_(0),
169 clearAtEnd_(clearAtEnd),
170 recvBuf_(receiveBuf),
171 recvBufPos_(receiveBufPosition)
180 const int fromProcNo,
186 fromProcNo_(fromProcNo),
188 comm_(buffers.comm()),
190 storedRecvBufPos_(0),
191 clearAtEnd_(buffers.allowClearRecv()),
192 recvBuf_(buffers.accessRecvBuffer(fromProcNo)),
193 recvBufPos_(buffers.accessRecvPosition(fromProcNo))
202 <<
"PstreamBuffers::finishedSends() never called." <<
endl 203 <<
"Please call PstreamBuffers::finishedSends() after doing" 204 <<
" all your sends (using UOPstream) and before doing any" 224 messageSize_(receiveBuf.size()),
225 storedRecvBufPos_(0),
232 recvBufPos_(storedRecvBufPos_)
243 if (clearAtEnd_ && eof())
247 Pout<<
"UIPstreamBase Destructor : tag:" << tag_
248 <<
" fromProcNo:" << fromProcNo_
249 <<
" clearing receive buffer of size " 251 <<
" messageSize_:" << messageSize_ <<
endl;
253 recvBuf_.clearStorage();
307 t.lineNumber(this->lineNumber());
333 case token::tokenType::WORD :
334 case token::tokenType::DIRECTIVE :
357 case token::tokenType::STRING :
358 case token::tokenType::EXPRESSION :
359 case token::tokenType::VARIABLE :
360 case token::tokenType::VERBATIM :
376 case token::tokenType::LABEL :
391 case token::tokenType::FLOAT :
406 case token::tokenType::DOUBLE :
440 c = recvBuf_[recvBufPos_];
449 return readString(str);
455 return readString(str);
511 <<
"stream format not binary" 540 if (recvBuf_.empty() || !messageSize_)
549 os <<
"Reading from processor " << fromProcNo_
550 <<
" using communicator " << comm_
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.
UIPstreamBase(const UPstream::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.
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)
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)...
tokenType
Enumeration defining the types of token.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label & recvBufPos_
Reference to the receive position in buffer data.
Begin list [isseparator].
Assignment/equals [isseparator].
int messageSize_
The message size, read on bufferIPCrecv or set directly.
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. Reading into a null pointer behaves like a forward seek of count character...
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.