Base class for data communications. More...
#include "Class_Data_Comm_Interface.hpp"
Public Member Functions | |
size_t | fixedSize () const |
template<class Buffer > | |
void | gather (Buffer &buff, const uint32_t e) |
template<class Buffer > | |
void | scatter (Buffer &buff, const uint32_t e) |
size_t | size (const uint32_t e) const |
Base class for data communications.
This class is the base class used to implement the user interface to data communications.
The Curiously Recurrent Template Pattern is exploited to achieve the interface. By this way the interface is based on static polymorphism with no extra cost at runtime.
The user has to implement his communication classes by deriving them from this class. The mechanism implies that the derived class derives from a template base class and that the template parameter is the derived class itself, as follow class Derived : public Base<Derived>{...}
The user has to implement all the methods of the base class in his derived class. These user's methods will really do the job.
An example of user derived class can be found, here,in test folder for the case of a double datum for each grid element.
Easily speaking, only the user knows his data and through the interface specialization he states the size of element data, how to write/read them in a communication buffer. Any MPI compatible POD datum can be written and read in the communication buffer.
Definition at line 38 of file Class_Data_Comm_Interface.hpp.
size_t Class_Data_Comm_Interface< Impl >::fixedSize | ( | ) | const |
Its user specification computes the same data size for every element in the grid.
Definition at line 10 of file Class_Data_Comm_Interface.tpp.
void Class_Data_Comm_Interface< Impl >::gather | ( | Buffer & | buff, |
const uint32_t | e | ||
) |
Its user specification writes the e element data to be communicated in the buffer.
The user has not to care about the buffer but a char buffer is available in PABLO, Class_Comm_Buffer. This class has an important method, Class_Comm_Buffer::write.
This method has to be used to allocate any single element datum in the communication buffer, as follow
where userdatum can be any MPI compatible POD variable associated to the e element.
In case of a vector of double, called userdata, to store data,
[in] | buff | Template communication buffer |
[in] | e | The element local index |
Definition at line 17 of file Class_Data_Comm_Interface.tpp.
void Class_Data_Comm_Interface< Impl >::scatter | ( | Buffer & | buff, |
const uint32_t | e | ||
) |
Its user specification reads the e element data from the communication buffer and store them in the ghost user data container.
The user has not to care about the buffer but a char buffer is available in PABLO, Class_Comm_Buffer. This class has an important method, Class_Comm_Buffer::read.
This method has to be used to read any single element datum from the communication buffer, as follow
where userdatum can be any MPI compatible POD variable associated to the e element.
In case of a vector of double, called userdata, to store data,
[in] | buff | Template communication buffer |
[in] | e | The element local index |
Definition at line 23 of file Class_Data_Comm_Interface.tpp.
size_t Class_Data_Comm_Interface< Impl >::size | ( | const uint32_t | e | ) | const |
Its user specification computes the specific size of data for an element.
[in] | e | Element local index. |
Definition at line 5 of file Class_Data_Comm_Interface.tpp.