FreeFOAM The Cross-Platform CFD Toolkit
Pstream Class Reference

Inter-processor communications stream. More...

#include <OpenFOAM/Pstream.H>


Detailed Description

+ Inheritance diagram for Pstream:
+ Collaboration diagram for Pstream:

List of all members.

Classes

class  commsStruct
 Structure for communicating between processors. More...

Public Member Functions

 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 ()

Static Public Member Functions

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.

Static Public Attributes

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

void enlargeBuffer (size_t count)
 Increase the size of the transfer buffer.

Protected Attributes

commsTypes commsType_
 Communications type of this stream.
List< char > buf_
 Transfer buffer.
int bufPosition_
 Current buffer read/write location.

Additional Inherited Members

- Public Types inherited from PstreamBase
enum  commsTypes { blocking, scheduled, nonBlocking }
 Types of communications. More...

Constructor & Destructor Documentation

Pstream ( const commsTypes  commsType,
const label  bufSize = 0 
)
inline

Construct given optional buffer size.

Definition at line 247 of file Pstream.H.

References Pstream::buf_, and List< T >::setSize().


Member Function Documentation

void enlargeBuffer ( size_t  count)
inlineprotected

Increase the size of the transfer buffer.

Definition at line 524 of file Pstream.H.

References Pstream::buf_, Foam::max(), List< T >::setSize(), and List< T >::size().

ClassName ( "Pstream"  )
static void addValidParOptions ( HashTable< string > &  validParOptions)
inlinestatic

Add the valid option this type of communications library.

adds/requires on the command line

Definition at line 266 of file Pstream.H.

References PstreamImpl::addValidParOptions().

static bool init ( int &  argc,
char **&  argv 
)
inlinestatic

Initialisation function called from main.

Spawns slave processes and initialises inter-communication

Definition at line 273 of file Pstream.H.

References PstreamImpl::init().

Referenced by ParRunControl::runPar().

static bool parRun ( )
inlinestatic

Is this a parallel run?

Definition at line 279 of file Pstream.H.

Referenced by error::abort(), IOerror::abort(), autoLayerDriver::addLayers(), autoHexMeshDriver::autoHexMeshDriver(), meshRefinement::balance(), processorPolyPatch::calcGeometry(), probes::checkFieldTypes(), polyBoundaryMesh::checkParallelSync(), Pstream::combineGather(), Pstream::combineScatter(), processorFvPatch::coupled(), processorPointPatch::coupled(), processorPointPatchField< Type >::coupled(), globalPointPatch::coupled(), processorFvsPatchField< Type >::coupled(), processorFvPatchField< Type >::coupled(), processorFvPatch::delta(), refinementHistory::distribute(), fvMeshDistribute::distribute(), autoLayerDriver::doLayers(), autoRefineDriver::doRefine(), processorFvPatchField< Type >::evaluate(), error::exit(), IOerror::exit(), sampledSurfaces::expire(), distributedTriSurfaceMesh::findNearest(), Pstream::gather(), Pstream::gatherList(), distributedTriSurfaceMesh::getField(), syncTools::getMasterEdges(), syncTools::getMasterFaces(), syncTools::getMasterPoints(), distributedTriSurfaceMesh::getNormal(), distributedTriSurfaceMesh::getRegion(), processorFvPatchField< Type >::initEvaluate(), processorPolyPatch::initGeometry(), processorPolyPatch::initOrder(), processorPointPatchField< Type >::initSwapAdd(), processorPolyPatch::initUpdateMesh(), Pstream::listCombineGather(), Pstream::listCombineScatter(), LUscalarMatrix::LUscalarMatrix(), processorFvPatch::makeDeltaCoeffs(), fieldValue::makeFile(), fieldMinMax::makeFile(), forces::makeFile(), processorFvPatch::makeWeights(), Pstream::mapCombineGather(), Pstream::mapCombineScatter(), polyBoundaryMesh::neighbourEdges(), processorPolyPatch::order(), sampledSurfaces::read(), regIOobject::readIfModified(), Time::readModifiedObjects(), mpiPstreamImpl::reduce(), referredCellList::referMolecules(), sampledSets::sampledSets(), sampledSurfaces::sampledSurfaces(), Pstream::scatter(), Pstream::scatterList(), Time::setControls(), fvMeshSubset::setLargeCellSubset(), LUscalarMatrix::solve(), processorPointPatchField< Type >::swapAdd(), faceSet::sync(), syncTools::syncBoundaryFaceList(), syncTools::syncEdgeList(), syncTools::syncEdgeMap(), syncTools::syncFaceList(), syncTools::syncPointList(), syncTools::syncPointMap(), sampledSurfaces::update(), processorPolyPatch::updateMesh(), and globalMeshData::updateMesh().

static int masterNo ( )
inlinestatic
static const List<int>& procIDs ( )
inlinestatic

Process IDs.

Definition at line 309 of file Pstream.H.

static int procID ( int  procNo)
inlinestatic

Process ID of given process index.

Definition at line 315 of file Pstream.H.

Referenced by mpiPstreamImpl::reduce().

static int firstSlave ( )
inlinestatic
static int lastSlave ( )
inlinestatic
static int msgType ( )
inlinestatic

Message tag of standard messages.

Definition at line 345 of file Pstream.H.

Referenced by mpiPstreamImpl::reduce().

commsTypes commsType ( ) const
inline

Get the communications type of the stream.

Definition at line 351 of file Pstream.H.

References Pstream::commsType_.

commsTypes commsType ( const commsTypes  ct)
inline

Set the communications type of the stream.

Definition at line 357 of file Pstream.H.

References Pstream::commsType_.

static void exit ( int  errnum = 1)
inlinestatic

Exit program.

Definition at line 365 of file Pstream.H.

References PstreamImpl::exit().

Referenced by error::exit(), and IOerror::exit().

static void abort ( )
inlinestatic

Abort program.

Definition at line 371 of file Pstream.H.

References PstreamImpl::abort().

Referenced by error::abort(), IOerror::abort(), and Pstream::commsStruct::commsStruct().

void gather ( const List< commsStruct > &  comms,
T Value,
const BinaryOp &  bop 
)
static

Gather data. Apply bop to combine Value.

from different processors

Definition at line 45 of file gatherScatter.C.

References Pstream::commsStruct::above(), Pstream::commsStruct::below(), forAll, Pstream::myProcNo(), Pstream::parRun(), IPstream::read(), PstreamBase::scheduled, Foam::T(), and OPstream::write().

Referenced by Pstream::gather(), and Foam::reduce().

void gather ( T Value,
const BinaryOp &  bop 
)
static

Like above but switches between linear/tree communication.

Definition at line 104 of file gatherScatter.C.

References Pstream::gather(), Pstream::linearCommunication(), Pstream::nProcs(), Pstream::nProcsSimpleSum, and Pstream::treeCommunication().

void scatter ( T Value)
static

Like above but switches between linear/tree communication.

Definition at line 169 of file gatherScatter.C.

References Pstream::linearCommunication(), Pstream::nProcs(), Pstream::nProcsSimpleSum, Pstream::scatter(), and Pstream::treeCommunication().

void combineGather ( T Value,
const CombineOp &  cop 
)
static

Like above but switches between linear/tree communication.

Definition at line 130 of file combineGatherScatter.C.

References Pstream::combineGather(), Pstream::linearCommunication(), Pstream::nProcs(), Pstream::nProcsSimpleSum, and Pstream::treeCommunication().

void combineScatter ( const List< commsStruct > &  comms,
T Value 
)
static
void combineScatter ( T Value)
static

Like above but switches between linear/tree communication.

Definition at line 208 of file combineGatherScatter.C.

References Pstream::combineScatter(), Pstream::linearCommunication(), Pstream::nProcs(), Pstream::nProcsSimpleSum, and Pstream::treeCommunication().

void listCombineGather ( List< T > &  Value,
const CombineOp &  cop 
)
static

Like above but switches between linear/tree communication.

Definition at line 314 of file combineGatherScatter.C.

References Pstream::linearCommunication(), Pstream::listCombineGather(), Pstream::nProcs(), Pstream::nProcsSimpleSum, and Pstream::treeCommunication().

void listCombineScatter ( List< T > &  Value)
static

Like above but switches between linear/tree communication.

Definition at line 396 of file combineGatherScatter.C.

References Pstream::linearCommunication(), Pstream::listCombineScatter(), Pstream::nProcs(), Pstream::nProcsSimpleSum, and Pstream::treeCommunication().

void mapCombineGather ( const List< commsStruct > &  comms,
Container &  Values,
const CombineOp &  cop 
)
static
void mapCombineGather ( Container &  Values,
const CombineOp &  cop 
)
static

Like above but switches between linear/tree communication.

Definition at line 481 of file combineGatherScatter.C.

References Pstream::linearCommunication(), Pstream::mapCombineGather(), Pstream::nProcs(), Pstream::nProcsSimpleSum, and Pstream::treeCommunication().

void mapCombineScatter ( const List< commsStruct > &  comms,
Container &  Values 
)
static
void mapCombineScatter ( Container &  Values)
static

Like above but switches between linear/tree communication.

Definition at line 537 of file combineGatherScatter.C.

References Pstream::linearCommunication(), Pstream::mapCombineScatter(), Pstream::nProcs(), Pstream::nProcsSimpleSum, and Pstream::treeCommunication().

void gatherList ( List< T > &  Values)
static

Like above but switches between linear/tree communication.

Definition at line 180 of file gatherScatterList.C.

References Pstream::gatherList(), Pstream::linearCommunication(), Pstream::nProcs(), Pstream::nProcsSimpleSum, and Pstream::treeCommunication().

void scatterList ( List< T > &  Values)
static

Like above but switches between linear/tree communication.

Definition at line 305 of file gatherScatterList.C.

References Pstream::linearCommunication(), Pstream::nProcs(), Pstream::nProcsSimpleSum, Pstream::scatterList(), and Pstream::treeCommunication().

void::Foam::reduce ( scalar &  Value,
const sumOp< scalar > &  bop 
)
void::Foam::PstreamImpl::initCommunicationSchedule ( )

Member Data Documentation

commsTypes commsType_
protected

Communications type of this stream.

Definition at line 207 of file Pstream.H.

Referenced by Pstream::commsType().

List<char> buf_
protected

Transfer buffer.

Definition at line 210 of file Pstream.H.

Referenced by Pstream::enlargeBuffer(), and Pstream::Pstream().

int bufPosition_
protected

Current buffer read/write location.

Definition at line 213 of file Pstream.H.

bool floatTransfer
static

Should compact transfer be used in which floats replace doubles.

reducing the bandwidth requirement at the expense of some loss in accuracy

Definition at line 233 of file Pstream.H.

Referenced by argList::argList().


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