FreeFOAM The Cross-Platform CFD Toolkit
OPstream Class Reference

Output inter-processor communications stream. More...

#include <OpenFOAM/OPstream.H>


Detailed Description

Output inter-processor communications stream.

Source files

Definition at line 53 of file OPstream.H.

+ Inheritance diagram for OPstream:
+ Collaboration diagram for OPstream:

List of all members.

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.
Ostreamwrite (const token &)
 Write next token to stream.
Ostreamwrite (const char)
 Write character.
Ostreamwrite (const char *)
 Write character string.
Ostreamwrite (const word &)
 Write word.
Ostreamwrite (const string &)
 Write string.
OstreamwriteQuoted (const std::string &, const bool quoted=true)
 Write std::string surrounded by quotes.
Ostreamwrite (const label)
 Write label.
Ostreamwrite (const floatScalar)
 Write floatScalar.
Ostreamwrite (const doubleScalar)
 Write doubleScalar.
Ostreamwrite (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.
- Public Member Functions inherited from Pstream
 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 ()
- Public Member Functions inherited from Ostream
 Ostream (streamFormat format=ASCII, versionNumber version=currentVersion, compressionType compression=UNCOMPRESSED)
 Set stream status.
virtual ~Ostream ()
 Destructor.
virtual Ostreamwrite (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.
OstreamwriteKeyword (const keyType &)
 Write the keyword followed by an appropriate indentation.
Ostreamoperator() () const
 Return a non-const reference to const Ostream.
- Public Member Functions inherited from IOstream
 IOstream (streamFormat format, versionNumber version, compressionType compression=UNCOMPRESSED)
 Construct setting format and version.
virtual ~IOstream ()
virtual const fileNamename () const
 Return the name of the stream.
virtual fileNamename ()
 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< IOstreaminfo () 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 Public Member Functions inherited from Pstream
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_
- Protected Attributes inherited from Pstream
commsTypes commsType_
 Communications type of this stream.
List< char > buf_
 Transfer buffer.
int bufPosition_
 Current buffer read/write location.
- Protected Attributes inherited from Ostream
unsigned short indentLevel_
 Current indent level.
- Protected Attributes inherited from IOstream
label lineNumber_

Additional Inherited Members

- Static Public Attributes inherited from Pstream
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.
- Protected Member Functions inherited from Pstream
void enlargeBuffer (size_t count)
 Increase the size of the transfer buffer.
- Static Protected Attributes inherited from Ostream
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.

Constructor & Destructor Documentation

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.


Member Function Documentation

ios_base::fmtflags flags ( ) const
inlinevirtual

Return flags of output stream.

Implements IOstream.

Definition at line 118 of file OPstream.H.

static bool write ( const commsTypes  commsType,
const int  toProcNo,
const char *  buf,
const std::streamsize  bufSize 
)
inlinestatic
static void waitRequests ( )
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().

static bool finishedRequest ( const label  i)
inlinestatic

Non-blocking writes: has request i finished?

Definition at line 145 of file OPstream.H.

References OPstreamImpl::finishedRequest().

Foam::Ostream & write ( const token )
virtual

Write next token to stream.

Implements Ostream.

Definition at line 125 of file OPstream.C.

References notImplemented.

Foam::Ostream & write ( const char  c)
virtual

Write character.

Implements Ostream.

Definition at line 133 of file OPstream.C.

References Foam::isspace().

Foam::Ostream & write ( const char *  str)
virtual

Write character string.

Implements Ostream.

Definition at line 144 of file OPstream.C.

Foam::Ostream & write ( const word str)
virtual

Write word.

Implements Ostream.

Definition at line 163 of file OPstream.C.

References token::WORD.

Foam::Ostream & write ( const string str)
virtual

Write string.

Implements Ostream.

Definition at line 175 of file OPstream.C.

References token::STRING.

Foam::Ostream & writeQuoted ( const std::string &  str,
const bool  quoted = true 
)
virtual

Write std::string surrounded by quotes.

Optional write without quotes.

Implements Ostream.

Definition at line 187 of file OPstream.C.

References token::STRING.

Foam::Ostream & write ( const label  val)
virtual

Write label.

Implements Ostream.

Definition at line 199 of file OPstream.C.

References token::LABEL.

Foam::Ostream & write ( const floatScalar  val)
virtual

Write floatScalar.

Implements Ostream.

Definition at line 207 of file OPstream.C.

References token::FLOAT_SCALAR.

Foam::Ostream & write ( const doubleScalar  val)
virtual

Write doubleScalar.

Implements Ostream.

Definition at line 215 of file OPstream.C.

References token::DOUBLE_SCALAR.

Foam::Ostream & write ( const char *  data,
std::streamsize  count 
)
virtual

Write binary block.

Implements Ostream.

Definition at line 223 of file OPstream.C.

References Foam::abort(), Foam::FatalError, FatalErrorIn, and format().

void indent ( )
inlinevirtual

Add indentation characters.

Implements Ostream.

Definition at line 186 of file OPstream.H.

void flush ( )
inlinevirtual

Flush stream.

Implements Ostream.

Definition at line 193 of file OPstream.H.

void endl ( )
inlinevirtual

Add newline and flush stream.

Implements Ostream.

Definition at line 197 of file OPstream.H.

int width ( ) const
inlinevirtual

Get width of output field.

Implements Ostream.

Definition at line 201 of file OPstream.H.

int width ( const int  )
inlinevirtual

Set width of output field (and return old width)

Implements Ostream.

Definition at line 207 of file OPstream.H.

int precision ( ) const
inlinevirtual

Get precision of output field.

Implements Ostream.

Definition at line 213 of file OPstream.H.

int precision ( const int  )
inlinevirtual

Set precision of output field (and return old precision)

Implements Ostream.

Definition at line 219 of file OPstream.H.

ios_base::fmtflags flags ( const ios_base::fmtflags  )
inline

Set flags of stream.

Definition at line 228 of file OPstream.H.

void print ( Ostream os) const
virtual

Print description of IOstream to Ostream.

Reimplemented from IOstream.

Definition at line 41 of file PstreamsPrint.C.

References Foam::endl().


Member Data Documentation

int toProcNo_
protected

Definition at line 88 of file OPstream.H.


The documentation for this class was generated from the following files: