Output inter-processor communications stream. More...
#include <OpenFOAM/OPstream.H>
Output inter-processor communications stream.
Definition at line 53 of file OPstream.H.
Public Member Functions | |
OPstream (const commsTypes commsType, const int toProcNo, const label bufSize=0, streamFormat format=BINARY, versionNumber version=currentVersion) | |
Construct given process index to send to and optional buffer size,. | |
~OPstream () | |
ios_base::fmtflags | flags () const |
Return flags of output stream. | |
Ostream & | write (const token &) |
Write next token to stream. | |
Ostream & | write (const char) |
Write character. | |
Ostream & | write (const char *) |
Write character string. | |
Ostream & | write (const word &) |
Write word. | |
Ostream & | write (const string &) |
Write string. | |
Ostream & | writeQuoted (const std::string &, const bool quoted=true) |
Write std::string surrounded by quotes. | |
Ostream & | write (const label) |
Write label. | |
Ostream & | write (const floatScalar) |
Write floatScalar. | |
Ostream & | write (const doubleScalar) |
Write doubleScalar. | |
Ostream & | write (const char *, std::streamsize) |
Write binary block. | |
void | indent () |
Add indentation characters. | |
void | flush () |
Flush stream. | |
void | endl () |
Add newline and flush stream. | |
int | width () const |
Get width of output field. | |
int | width (const int) |
Set width of output field (and return old width) | |
int | precision () const |
Get precision of output field. | |
int | precision (const int) |
Set precision of output field (and return old precision) | |
ios_base::fmtflags | flags (const ios_base::fmtflags) |
Set flags of stream. | |
void | print (Ostream &) const |
Print description of IOstream to Ostream. | |
![]() | |
ClassName ("Pstream") | |
Pstream (const commsTypes commsType, const label bufSize=0) | |
Construct given optional buffer size. | |
commsTypes | commsType () const |
Get the communications type of the stream. | |
commsTypes | commsType (const commsTypes ct) |
Set the communications type of the stream. | |
friend | void::Foam::reduce (scalar &Value, const sumOp< scalar > &bop) |
friend | void::Foam::PstreamImpl::initCommunicationSchedule () |
![]() | |
Ostream (streamFormat format=ASCII, versionNumber version=currentVersion, compressionType compression=UNCOMPRESSED) | |
Set stream status. | |
virtual | ~Ostream () |
Destructor. | |
virtual Ostream & | write (const keyType &) |
Write keyType. | |
unsigned short | indentLevel () const |
Return indent level. | |
unsigned short & | indentLevel () |
Access to indent level. | |
void | incrIndent () |
Incrememt the indent level. | |
void | decrIndent () |
Decrememt the indent level. | |
Ostream & | writeKeyword (const keyType &) |
Write the keyword followed by an appropriate indentation. | |
Ostream & | operator() () const |
Return a non-const reference to const Ostream. | |
![]() | |
IOstream (streamFormat format, versionNumber version, compressionType compression=UNCOMPRESSED) | |
Construct setting format and version. | |
virtual | ~IOstream () |
virtual const fileName & | name () const |
Return the name of the stream. | |
virtual fileName & | name () |
Return non-const access to the name of the stream. | |
virtual bool | check (const char *operation) const |
Check IOstream status for given operation. | |
void | fatalCheck (const char *operation) const |
Check IOstream status for given operation. | |
bool | opened () const |
Return true if stream has been opened. | |
bool | closed () const |
Return true if stream is closed. | |
bool | good () const |
Return true if next operation might succeed. | |
bool | eof () const |
Return true if end of input seen. | |
bool | fail () const |
Return true if next operation will fail. | |
bool | bad () const |
Return true if stream is corrupted. | |
operator void * () const | |
Return non-zero if the stream has not failed. | |
bool | operator! () const |
Return true if the stream has failed. | |
streamFormat | format () const |
Return current stream format. | |
streamFormat | format (const streamFormat fmt) |
Set the stream format. | |
streamFormat | format (const word &fmt) |
Set the stream format from word. | |
versionNumber | version () const |
Return the stream version. | |
versionNumber | version (const versionNumber ver) |
Set the stream version. | |
compressionType | compression () const |
Return the stream compression. | |
compressionType | compression (const compressionType cmp) |
Set the stream compression. | |
compressionType | compression (const word &cmp) |
Set the stream compression from word. | |
label | lineNumber () const |
Return current stream line number. | |
label & | lineNumber () |
Return current stream line number. | |
label | lineNumber (const label ln) |
Set the stream line number. | |
void | setEof () |
Set stream to have reached eof. | |
void | setFail () |
Set stream to have failed. | |
void | setBad () |
Set stream to be bad. | |
virtual ios::fmtflags | flags (const ios::fmtflags f)=0 |
Set flags of stream. | |
ios::fmtflags | setf (const ios::fmtflags f) |
Set flags of stream. | |
ios::fmtflags | setf (const ios::fmtflags f, const ios::fmtflags mask) |
Set flags of given field of stream. | |
void | unsetf (const ios::fmtflags uf) |
Unset flags of stream. | |
void | print (Ostream &, const int streamState) const |
Check given stream state bits. | |
InfoProxy< IOstream > | info () const |
Return info proxy. |
Static Public Member Functions | |
static bool | write (const commsTypes commsType, const int toProcNo, const char *buf, const std::streamsize bufSize) |
Write given buffer to given processor. | |
static void | waitRequests () |
Non-blocking writes: wait until all have finished. | |
static bool | finishedRequest (const label i) |
Non-blocking writes: has request i finished? | |
![]() | |
static void | addValidParOptions (HashTable< string > &validParOptions) |
Add the valid option this type of communications library. | |
static bool | init (int &argc, char **&argv) |
Initialisation function called from main. | |
static bool | parRun () |
Is this a parallel run? | |
static label | nProcs () |
Number of processes in parallel run. | |
static bool | master () |
Am I the master process. | |
static int | masterNo () |
Process index of the master. | |
static int | myProcNo () |
Number of this process (starting from masterNo() = 0) | |
static const List< int > & | procIDs () |
Process IDs. | |
static int | procID (int procNo) |
Process ID of given process index. | |
static int | firstSlave () |
Process index of first slave. | |
static int | lastSlave () |
Process index of last slave. | |
static const List< commsStruct > & | linearCommunication () |
Communication schedule for linear all-to-master (proc 0) | |
static const List< commsStruct > & | treeCommunication () |
Communication schedule for tree all-to-master (proc 0) | |
static int | msgType () |
Message tag of standard messages. | |
static void | exit (int errnum=1) |
Exit program. | |
static void | abort () |
Abort program. | |
template<class T , class BinaryOp > | |
static void | gather (const List< commsStruct > &comms, T &Value, const BinaryOp &bop) |
Gather data. Apply bop to combine Value. | |
template<class T , class BinaryOp > | |
static void | gather (T &Value, const BinaryOp &bop) |
Like above but switches between linear/tree communication. | |
template<class T > | |
static void | scatter (const List< commsStruct > &comms, T &Value) |
Scatter data. Distribute without modification. Reverse of gather. | |
template<class T > | |
static void | scatter (T &Value) |
Like above but switches between linear/tree communication. | |
template<class T , class CombineOp > | |
static void | combineGather (const List< commsStruct > &comms, T &Value, const CombineOp &cop) |
template<class T , class CombineOp > | |
static void | combineGather (T &Value, const CombineOp &cop) |
Like above but switches between linear/tree communication. | |
template<class T > | |
static void | combineScatter (const List< commsStruct > &comms, T &Value) |
Scatter data. Reverse of combineGather. | |
template<class T > | |
static void | combineScatter (T &Value) |
Like above but switches between linear/tree communication. | |
template<class T , class CombineOp > | |
static void | listCombineGather (const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop) |
template<class T , class CombineOp > | |
static void | listCombineGather (List< T > &Value, const CombineOp &cop) |
Like above but switches between linear/tree communication. | |
template<class T > | |
static void | listCombineScatter (const List< commsStruct > &comms, List< T > &Value) |
Scatter data. Reverse of combineGather. | |
template<class T > | |
static void | listCombineScatter (List< T > &Value) |
Like above but switches between linear/tree communication. | |
template<class Container , class CombineOp > | |
static void | mapCombineGather (const List< commsStruct > &comms, Container &Values, const CombineOp &cop) |
template<class Container , class CombineOp > | |
static void | mapCombineGather (Container &Values, const CombineOp &cop) |
Like above but switches between linear/tree communication. | |
template<class Container > | |
static void | mapCombineScatter (const List< commsStruct > &comms, Container &Values) |
Scatter data. Reverse of combineGather. | |
template<class Container > | |
static void | mapCombineScatter (Container &Values) |
Like above but switches between linear/tree communication. | |
template<class T > | |
static void | gatherList (const List< commsStruct > &comms, List< T > &Values) |
Gather data but keep individual values separate. | |
template<class T > | |
static void | gatherList (List< T > &Values) |
Like above but switches between linear/tree communication. | |
template<class T > | |
static void | scatterList (const List< commsStruct > &comms, List< T > &Values) |
Scatter data. Reverse of gatherList. | |
template<class T > | |
static void | scatterList (List< T > &Values) |
Like above but switches between linear/tree communication. |
Protected Attributes | |
int | toProcNo_ |
![]() | |
commsTypes | commsType_ |
Communications type of this stream. | |
List< char > | buf_ |
Transfer buffer. | |
int | bufPosition_ |
Current buffer read/write location. | |
![]() | |
unsigned short | indentLevel_ |
Current indent level. | |
![]() | |
label | lineNumber_ |
Additional Inherited Members | |
![]() | |
static const NamedEnum < commsTypes, 3 > | commsTypeNames |
static bool | floatTransfer |
Should compact transfer be used in which floats replace doubles. | |
static int | nProcsSimpleSum |
Number of processors at which the sum algorithm changes from linear. | |
static commsTypes | defaultCommsType |
Default commsType. | |
![]() | |
void | enlargeBuffer (size_t count) |
Increase the size of the transfer buffer. | |
![]() | |
static const unsigned short | indentSize_ = 4 |
Number of spaces per indent level. | |
static const unsigned short | entryIndentation_ = 16 |
Indentation of the entry from the start of the keyword. |
OPstream | ( | const commsTypes | commsType, |
const int | toProcNo, | ||
const label | bufSize = 0 , |
||
streamFormat | format = BINARY , |
||
versionNumber | version = currentVersion |
||
) |
Construct given process index to send to and optional buffer size,.
write format and IO version
Definition at line 95 of file OPstream.C.
~OPstream | ( | ) |
Definition at line 118 of file OPstream.C.
|
inlinevirtual |
|
inlinestatic |
Write given buffer to given processor.
Definition at line 128 of file OPstream.H.
References OPstreamImpl::write().
Referenced by Pstream::combineGather(), Pstream::combineScatter(), mapDistribute::compact(), Pstream::gather(), Pstream::gatherList(), processorPointPatchField< Type >::initSwapAdd(), Pstream::listCombineGather(), Pstream::listCombineScatter(), Pstream::scatter(), Pstream::scatterList(), LUscalarMatrix::solve(), and syncTools::syncBoundaryFaceList().
|
inlinestatic |
Non-blocking writes: wait until all have finished.
Definition at line 139 of file OPstream.H.
References OPstreamImpl::waitRequests().
Referenced by mapDistribute::compact(), and GeometricField< Type, PatchField, GeoMesh >::GeometricBoundaryField::evaluate().
|
inlinestatic |
Non-blocking writes: has request i finished?
Definition at line 145 of file OPstream.H.
References OPstreamImpl::finishedRequest().
|
virtual |
Write next token to stream.
Implements Ostream.
Definition at line 125 of file OPstream.C.
References notImplemented.
|
virtual |
Write character.
Implements Ostream.
Definition at line 133 of file OPstream.C.
References Foam::isspace().
|
virtual |
|
virtual |
|
virtual |
Write string.
Implements Ostream.
Definition at line 175 of file OPstream.C.
References token::STRING.
|
virtual |
Write std::string surrounded by quotes.
Optional write without quotes.
Implements Ostream.
Definition at line 187 of file OPstream.C.
References token::STRING.
|
virtual |
Write label.
Implements Ostream.
Definition at line 199 of file OPstream.C.
References token::LABEL.
|
virtual |
Write floatScalar.
Implements Ostream.
Definition at line 207 of file OPstream.C.
References token::FLOAT_SCALAR.
|
virtual |
Write doubleScalar.
Implements Ostream.
Definition at line 215 of file OPstream.C.
References token::DOUBLE_SCALAR.
|
virtual |
Write binary block.
Implements Ostream.
Definition at line 223 of file OPstream.C.
References Foam::abort(), Foam::FatalError, FatalErrorIn, and format().
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Set width of output field (and return old width)
Implements Ostream.
Definition at line 207 of file OPstream.H.
|
inlinevirtual |
|
inlinevirtual |
Set precision of output field (and return old precision)
Implements Ostream.
Definition at line 219 of file OPstream.H.
|
inline |
Set flags of stream.
Definition at line 228 of file OPstream.H.
|
virtual |
Print description of IOstream to Ostream.
Reimplemented from IOstream.
Definition at line 41 of file PstreamsPrint.C.
References Foam::endl().
|
protected |
Definition at line 88 of file OPstream.H.