ESyS-Particle
4.0.1
|
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>
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 () |
![]() | |
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 |
Message buffer for sending and receiving packed data. Data types are not checked. The implementation has been derived from the old CVarMPIBuffer class.
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.
comm | the MPI communicator |
s | the initial size of the buffer |
References m_buffersize, m_dbl_increment, m_pack_pos, and m_unpack_pos.
|
virtual |
Destructor. Free buffer.
|
virtual |
Append an integer to the buffer. If necessary, the buffer is enlarged.
Implements TML_PackedMessageInterface.
References grow(), m_buffersize, and m_pack_pos.
Referenced by append().
|
virtual |
Append a double to the buffer. If necessary, the buffer is enlarged.
Implements TML_PackedMessageInterface.
References grow(), m_buffersize, m_dbl_increment, and m_pack_pos.
|
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.
Implements TML_PackedMessageInterface.
References grow(), m_buffersize, and m_pack_pos.
|
virtual |
Append a Vec3 to the message buffer. Calls append(double) per element
Implements TML_PackedMessageInterface.
References append().
|
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().
|
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().
|
protected |
Grows the buffer to a given size. If the buffer is already larger that the given size, nothing is done. Used by receiveFrom.
size | size to which the buffer is grown |
References m_buffersize, and m_pack_pos.
Referenced by grow().
|
virtual |
Pop a boolean value of the buffer. Booleans are transported as int (0/1)
Implements TML_PackedMessageInterface.
References pop_int().
|
virtual |
Pops a double from the buffer.
Implements TML_PackedMessageInterface.
References m_buffersize, and m_unpack_pos.
Referenced by pop_vec3().
|
virtual |
pop a C-array of doubles from a buffer. Faster than doing multiple pop_double operations
dbl | the array |
ndb | the number of doubles to be popped |
Implements TML_PackedMessageInterface.
References m_buffersize, and m_unpack_pos.
|
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.
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().
|
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.
Implements TML_PackedMessageInterface.
References m_buffersize, and m_unpack_pos.
|
virtual |
Pop a Vec3 of the buffer. Calls pop_double per element
Implements TML_PackedMessageInterface.
References pop_double().