Loading...
Searching...
No Matches
Public Member Functions | List of all members
bitpit::DataLBInterface< Impl > Class Template Reference

Base class for data communications. More...

#include <DataLBInterface.hpp>

Inheritance diagram for bitpit::DataLBInterface< Impl >:
Inheritance graph
[legend]

Public Member Functions

void assign (uint32_t stride, uint32_t length)
 
size_t fixedSize () const
 
template<class Buffer >
void gather (Buffer &buff, const uint32_t e)
 
void move (const uint32_t from, const uint32_t to)
 
void resize (uint32_t newSize)
 
void resizeGhost (uint32_t newSize)
 
template<class Buffer >
void scatter (Buffer &buff, const uint32_t e)
 
void shrink ()
 
size_t size (const uint32_t e) const
 

Detailed Description

template<class Impl>
class bitpit::DataLBInterface< Impl >

Base class for data communications.

Date
09/sep/2015
Authors
Edoardo Lombardi
Marco Cisternino
License
This version of PABLO is released under the LGPL License.

This class is the base class used to implement the user interface to data communications for load balance.

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 for load balance 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 and move them in a communication buffer.

Examples
PABLO_example_00007.cpp.

Definition at line 70 of file DataLBInterface.hpp.

Constructor & Destructor Documentation

◆ DataLBInterface()

template<class Impl >
bitpit::DataLBInterface< Impl >::DataLBInterface ( )
inlineprotected

Definition at line 28 of file DataLBInterface.tpp.

Member Function Documentation

◆ assign()

template<class Impl >
void bitpit::DataLBInterface< Impl >::assign ( uint32_t stride,
uint32_t length )
inline

Its user specification extracts contiguous element from a data container. This method is used during the very first load balance where the grid from being serial becomes parallel. From the initial serial container, which is the same on every process, this method takes the data relatives to the process sub-domain, storing them in the same resized parallel local container.

Parameters
[in]strideThe location where the process has to start reading from
[in]lengthThe length of the data container the process has to read

Definition at line 109 of file DataLBInterface.tpp.

◆ fixedSize()

template<class Impl >
size_t bitpit::DataLBInterface< Impl >::fixedSize ( ) const
inline

Its user specification computes the same data size for every element in the grid.

Returns
The size of the data for every element

Definition at line 43 of file DataLBInterface.tpp.

◆ gather()

template<class Impl >
template<class Buffer >
void bitpit::DataLBInterface< Impl >::gather ( Buffer & buff,
const uint32_t e )
inline

Its user specification writes the e element data to be communicated during the load balance in the buffer.

The user has to use the buffer buff as an output binary stream. A stream operator (<<) is provided to allocate any single element datum in the communication buffer, as follow

buff << userdatum

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,

buff << userdata[e]
Parameters
[in]buffOutput communication buffer
[in]eThe element local index

Definition at line 75 of file DataLBInterface.tpp.

◆ move()

template<class Impl >
void bitpit::DataLBInterface< Impl >::move ( const uint32_t from,
const uint32_t to )
inline

Its user specification moves the data from the "from" element to the "to" element

Parameters
[in]fromElement local index from.
[in]toElement local index to.

Definition at line 52 of file DataLBInterface.tpp.

◆ resize()

template<class Impl >
void bitpit::DataLBInterface< Impl >::resize ( uint32_t newSize)
inline

Its user specification resizes the element data container to the newSize value.

Parameters
[in]newSizeThe new size of the user data container

Definition at line 117 of file DataLBInterface.tpp.

◆ resizeGhost()

template<class Impl >
void bitpit::DataLBInterface< Impl >::resizeGhost ( uint32_t newSize)
inline

Its user specification resizes the ghost element data container to the newSize value.

Parameters
[in]newSizeThe new size of the user ghost data container

Definition at line 125 of file DataLBInterface.tpp.

◆ scatter()

template<class Impl >
template<class Buffer >
void bitpit::DataLBInterface< Impl >::scatter ( Buffer & buff,
const uint32_t e )
inline

Its user specification reads the e element data from the communication buffer and store them in the user data container.

The user has to use the buffer buff as an input binary stream. A stream operator (>>) is provided to read any single element datum from the communication buffer, as follow

buff >> userdatum

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,

buff >> userdata[e]
Parameters
[in]buffInput communication buffer
[in]eThe element local index

Definition at line 98 of file DataLBInterface.tpp.

◆ shrink()

template<class Impl >
void bitpit::DataLBInterface< Impl >::shrink ( )
inline

Its user specification reduces the capacity of the container to its size for those containers which has different values for capacity and size. If the user container has no capacity concept, nothing has to be done.

Definition at line 133 of file DataLBInterface.tpp.

◆ size()

template<class Impl >
size_t bitpit::DataLBInterface< Impl >::size ( const uint32_t e) const
inline

Its user specification computes the specific size of data for an element.

Parameters
[in]eThe element local index.
Returns
the size of the data for the e element

Definition at line 35 of file DataLBInterface.tpp.


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