ESyS-Particle  4.0.1
Public Member Functions | Protected Member Functions | Protected Attributes
TML_Packed_Message Class Reference

Message buffer for sending and receiving packed data. Data types are not checked. The implementation has been derived from the old CVarMPIBuffer class. More...

#include <packed_message.h>

Inheritance diagram for TML_Packed_Message:
Inheritance graph
[legend]
Collaboration diagram for TML_Packed_Message:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TML_Packed_Message (MPI_Comm, unsigned int size=64)
virtual ~TML_Packed_Message ()
char * buffer ()
int size ()
virtual void begin_pack ()
virtual void begin_unpack ()
virtual void append (int)
virtual void append (double)
virtual void append (const string &)
virtual void append (const Vec3 &)
virtual void append (bool)
virtual int pop_int ()
virtual double pop_double ()
virtual void pop_doubles (double *, int)
virtual string pop_string ()
virtual Vec3 pop_vec3 ()
virtual bool pop_bool ()
- Public Member Functions inherited from TML_PackedMessageInterface
template<typename T >
void pack (const T &)
template<typename T >
void unpack (T &)
template<>
void pack (const Vec3 &v)
template<>
void unpack (Vec3 &v)
template<>
void pack (const CAdhesiveFriction &I)
template<>
void unpack (CAdhesiveFriction &I)
template<>
void pack (const BCorner2DInteraction &I)
template<>
void unpack (BCorner2DInteraction &I)
template<>
void pack (const BEdge2DInteraction &I)
template<>
void unpack (BEdge2DInteraction &I)
template<>
void pack (const CBondedInteraction &I)
template<>
void unpack (CBondedInteraction &I)
template<>
void pack (const BTriangleInteraction &I)
template<>
void unpack (BTriangleInteraction &I)
template<>
void pack (const CCappedBondedInteraction &I)
template<>
void unpack (CCappedBondedInteraction &I)
template<>
void pack (const CFractalFriction &I)
template<>
void unpack (CFractalFriction &I)
template<>
void pack (const CFrictionInteraction &I)
template<>
void unpack (CFrictionInteraction &I)
template<>
void pack (const CHertzianViscoElasticFrictionInteraction &I)
template<>
void unpack (CHertzianViscoElasticFrictionInteraction &I)
template<>
void pack (const MeshNodeData &d)
template<>
void unpack (MeshNodeData &d)
template<>
void pack (const MeshTriData &d)
template<>
void unpack (MeshTriData &d)
template<>
void pack (const MeshNodeData2D &d)
template<>
void unpack (MeshNodeData2D &d)
template<>
void pack (const MeshEdgeData2D &d)
template<>
void unpack (MeshEdgeData2D &d)
template<>
void pack (const CParticle &p)
template<>
void unpack (CParticle &p)
template<>
void pack (const CRotBondedInteraction &I)
template<>
void unpack (CRotBondedInteraction &I)
template<>
void pack (const CRotFrictionInteraction &I)
template<>
void unpack (CRotFrictionInteraction &I)
template<>
void pack (const CRotParticle &p)
template<>
void unpack (CRotParticle &p)
template<>
void pack (const CRotParticleVi &p)
template<>
void unpack (CRotParticleVi &p)
template<>
void pack (const CRotThermBondedInteraction &I)
template<>
void unpack (CRotThermBondedInteraction &I)
template<>
void pack (const CRotThermFrictionInteraction &I)
template<>
void unpack (CRotThermFrictionInteraction &I)
template<>
void pack (const CRotThermParticle &p)
template<>
void unpack (CRotThermParticle &p)
template<>
void pack (const CShortBondedInteraction &I)
template<>
void unpack (CShortBondedInteraction &I)
template<>
void pack (const CVWFriction &I)
template<>
void unpack (CVWFriction &I)
template<>
void pack (const CBasicParticle &p)
template<>
void unpack (CBasicParticle &p)
template<>
void pack (const int &i)
template<>
void unpack (int &i)
template<>
void pack (const double &d)
template<>
void unpack (double &d)
template<typename T1 , typename T2 >
void unpack (pair< T1, T2 > &p)
template<>
void pack (const pair< int, double > &p)
template<>
void unpack (pair< int, double > &p)

Protected Member Functions

void grow ()
void growTo (int)

Protected Attributes

MPI_Comm m_comm
char * m_buffer
int m_buffersize
 the size of the buffer
int m_pack_pos
 the current end of the content
int m_unpack_pos
 the current pos for unpacking
int m_int_increment
int m_dbl_increment
 the "packing size" of int/double

Detailed Description

Message buffer for sending and receiving packed data. Data types are not checked. The implementation has been derived from the old CVarMPIBuffer class.


Constructor & Destructor Documentation

TML_Packed_Message::TML_Packed_Message ( MPI_Comm  comm,
unsigned int  s = 64 
)

Constructor. Allocates the buffer and sets the MPI communicator to be used for pack/unpack operations. If the initial buffer size is not given a buffer of initial size 64 is allocated.

Parameters:
commthe MPI communicator
sthe initial size of the buffer

References m_buffersize, m_dbl_increment, m_pack_pos, and m_unpack_pos.

TML_Packed_Message::~TML_Packed_Message ( )
virtual

Destructor. Free buffer.


Member Function Documentation

void TML_Packed_Message::append ( int  i)
virtual

Append an integer to the buffer. If necessary, the buffer is enlarged.

Warning:
currently does not check if there is enough free space to allocate larger buffer

Implements TML_PackedMessageInterface.

References grow(), m_buffersize, and m_pack_pos.

Referenced by append().

Here is the call graph for this function:

Here is the caller graph for this function:

void TML_Packed_Message::append ( double  d)
virtual

Append a double to the buffer. If necessary, the buffer is enlarged.

Warning:
currently does not check if there is enough free space to allocate larger buffer
See also:
grow()

Implements TML_PackedMessageInterface.

References grow(), m_buffersize, m_dbl_increment, and m_pack_pos.

Here is the call graph for this function:

void TML_Packed_Message::append ( const string &  str)
virtual

Append a STL string to the buffer. The string is internally handeled by packing the length frist and then the string. If necessary, the buffer is enlarged.

Warning:
currently does not check if there is enough free space to allocate larger buffer
See also:
grow()

Implements TML_PackedMessageInterface.

References grow(), m_buffersize, and m_pack_pos.

Here is the call graph for this function:

void TML_Packed_Message::append ( const Vec3 v)
virtual

Append a Vec3 to the message buffer. Calls append(double) per element

Implements TML_PackedMessageInterface.

References append().

Here is the call graph for this function:

void TML_Packed_Message::append ( bool  b)
virtual

Append a boolean to the message buffer. The bool gest transported as an int (1/0) because MPI doesn't have a native boolean type. Therefore calls append(int).

Implements TML_PackedMessageInterface.

References append().

Here is the call graph for this function:

void TML_Packed_Message::grow ( )
protected

Grows the buffer to twice its current size, thus guaranteeing that append works in amortized constant time.

References growTo(), and m_buffersize.

Referenced by append().

Here is the call graph for this function:

Here is the caller graph for this function:

void TML_Packed_Message::growTo ( int  size)
protected

Grows the buffer to a given size. If the buffer is already larger that the given size, nothing is done. Used by receiveFrom.

Parameters:
sizesize to which the buffer is grown

References m_buffersize, and m_pack_pos.

Referenced by grow().

Here is the caller graph for this function:

bool TML_Packed_Message::pop_bool ( )
virtual

Pop a boolean value of the buffer. Booleans are transported as int (0/1)

Implements TML_PackedMessageInterface.

References pop_int().

Here is the call graph for this function:

double TML_Packed_Message::pop_double ( )
virtual

Pops a double from the buffer.

Warning:
No check for underflow
Returns:
the double.
See also:
CMPIBuffer::pop_int()

Implements TML_PackedMessageInterface.

References m_buffersize, and m_unpack_pos.

Referenced by pop_vec3().

Here is the caller graph for this function:

void TML_Packed_Message::pop_doubles ( double *  dbl,
int  ndb 
)
virtual

pop a C-array of doubles from a buffer. Faster than doing multiple pop_double operations

Parameters:
dblthe array
ndbthe number of doubles to be popped
Warning:
No check for underflow

Implements TML_PackedMessageInterface.

References m_buffersize, and m_unpack_pos.

int TML_Packed_Message::pop_int ( )
virtual

Pops an integer from the buffer, i.e. it pops the last sizeof(MPI_INT) bytes of the buffer, interpreting them as an int.

Warning:
No check for underflow
Returns:
the int.

Implements TML_PackedMessageInterface.

References m_buffersize, and m_unpack_pos.

Referenced by pop_bool(), TML_Comm::receive_cont_packed(), TML_Comm::recv_broadcast_cont_packed(), TML_Comm::recv_scatter_packed(), TML_Comm::sendrecv_cont_packed(), and TML_Comm::sendrecv_cont_packed_replace().

Here is the caller graph for this function:

string TML_Packed_Message::pop_string ( )
virtual

Pops a string from the buffer. The first for bytes are interpreted as int, giving the length of the string (without terminating '\0'), the rest as the characters.

Warning:
no consistency check, i.e. it is not checked if the length is smaller than the buffersize.
Returns:
the double.
See also:
CMPISingle::pop_int()

Implements TML_PackedMessageInterface.

References m_buffersize, and m_unpack_pos.

Vec3 TML_Packed_Message::pop_vec3 ( )
virtual

Pop a Vec3 of the buffer. Calls pop_double per element

Implements TML_PackedMessageInterface.

References pop_double().

Here is the call graph for this function:


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