OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
grid_sm< N, T > Class Template Reference

Declaration grid_sm. More...

Detailed Description

template<unsigned int N, typename T>
class grid_sm< N, T >

Declaration grid_sm.

class that store the information of the grid like number of point on each direction and define the index linearization by stride

Parameters
Ndimensionality
Ttype of object is going to store the grid

Definition at line 71 of file grid_sm.hpp.

#include <grid_sm.hpp>

Public Member Functions

const Box< N, size_t > & getBox () const
 Return the box enclosing the grid. More...
 
const Box< N, size_t > getBoxKey () const
 Return the box enclosing the grid. More...
 
void setDimensions (const size_t(&dims)[N])
 Reset the dimension of the grid. More...
 
 grid_sm ()
 Default constructor. More...
 
template<typename S >
 grid_sm (const grid_sm< N, S > &g)
 construct a grid from another grid More...
 
size_t totalSize (const size_t sz)
 
size_t totalSize (const size_t(&sz)[N])
 
 grid_sm (const size_t &sz)
 Construct a grid of a specified size. More...
 
 grid_sm (const size_t(&sz)[N])
 Construct a grid of a specified size. More...
 
template<typename check = NoCheck>
mem_id LinId (const grid_key_dx< N > &gk, const char sum_id[N]) const
 Linearization of the grid_key_dx with a specified shift. More...
 
template<typename check = NoCheck>
mem_id LinId (const grid_key_dx< N > &gk, const char sum_id[N], const size_t(&bc)[N]) const
 Linearization of the grid_key_dx with a specified shift. More...
 
mem_id LinIdPtr (size_t *k) const
 Linearization of the set of indexes. More...
 
mem_id LinId (const size_t(&k)[N]) const
 Linearization of the grid_key_dx. More...
 
mem_id LinId (const grid_key_dx< N > &gk) const
 Linearization of the grid_key_dx. More...
 
template<typename a , typename... lT>
mem_id Lin (a v, lT...t) const
 linearize an arbitrary set of index More...
 
template<typename a >
mem_id Lin (a v) const
 Linearize a set of index.
 
grid_key_dx< N > InvLinId (mem_id id) const
 Construct. More...
 
template<unsigned int dim, unsigned int p>
mem_id LinId (const grid_key_d< dim, p > &gk) const
 Linearization of the grid_key_d. More...
 
mem_id LinId (mem_id *id) const
 Linearization of an array of mem_id (long int) More...
 
 ~grid_sm ()
 Destructor.
 
size_t size () const
 Return the size of the grid. More...
 
grid_sm< N, T > & operator= (const grid_sm< N, T > &g)
 Copy the grid from another grid. More...
 
bool operator== (const grid_sm< N, T > &g)
 Check if the two grid_sm are the same. More...
 
bool operator!= (const grid_sm< N, T > &g)
 Check if the two grid_sm are the same. More...
 
size_t size_s (unsigned int i) const
 
size_t size (unsigned int i) const
 
const size_t(& getSize () const)[N]
 Return the size of the grid as an array. More...
 
grid_key_dx_iterator_sub< N > getSubIterator (grid_key_dx< N > &start, grid_key_dx< N > &stop) const
 Return a sub-grid iterator. More...
 
void swap (grid_sm< N, T > &g)
 swap the grid_sm informations More...
 
std::string toString () const
 Produce a string from the object. More...
 

Private Member Functions

void Initialize (const size_t sz)
 Initialize the basic structure. More...
 
void Initialize (const size_t(&sz)[N])
 Initialize the basic structure. More...
 
void Initialize ()
 Initialize the basic structure. More...
 

Private Attributes

Box< N, size_t > box
 Box enclosing the grid.
 
size_t size_tot
 total number of the elements in the grid
 
size_t sz [N]
 size of the grid
 
size_t sz_s [N]
 size of the grid on each stride (used for linearization)
 

Friends

template<unsigned int, typename >
class grid_sm
 It simply mean that all the classes grid are friend of all its specialization.
 

Constructor & Destructor Documentation

template<unsigned int N, typename T>
grid_sm< N, T >::grid_sm ( )
inline

Default constructor.

It produce a grid of size 0 on each dimension

Definition at line 241 of file grid_sm.hpp.

template<unsigned int N, typename T>
template<typename S >
grid_sm< N, T >::grid_sm ( const grid_sm< N, S > &  g)
inline

construct a grid from another grid

Parameters
ggrid info

construct a grid from another grid, type can be different

Definition at line 259 of file grid_sm.hpp.

template<unsigned int N, typename T>
grid_sm< N, T >::grid_sm ( const size_t &  sz)
inline

Construct a grid of a specified size.

Construct a grid of a specified size

Parameters
szis an array that contain the size of the grid on each dimension

Definition at line 308 of file grid_sm.hpp.

template<unsigned int N, typename T>
grid_sm< N, T >::grid_sm ( const size_t(&)  sz[N])
inline

Construct a grid of a specified size.

Construct a grid of a specified size

Parameters
szis an array that contain the size of the grid on each dimension

Definition at line 322 of file grid_sm.hpp.

Member Function Documentation

template<unsigned int N, typename T>
const Box<N,size_t>& grid_sm< N, T >::getBox ( ) const
inline

Return the box enclosing the grid.

Returns
the box

Definition at line 197 of file grid_sm.hpp.

template<unsigned int N, typename T>
const Box<N,size_t> grid_sm< N, T >::getBoxKey ( ) const
inline

Return the box enclosing the grid.

While getBox return as P2 the size of the grid getBoxKey return the size - 1 equivalent to the maximum valid point that does not overflow the grid

Returns
the box

Definition at line 211 of file grid_sm.hpp.

template<unsigned int N, typename T>
const size_t(& grid_sm< N, T >::getSize ( ) )[N]
inline

Return the size of the grid as an array.

Returns
get the size of the grid as an array

Definition at line 677 of file grid_sm.hpp.

template<unsigned int N, typename T>
grid_key_dx_iterator_sub<N> grid_sm< N, T >::getSubIterator ( grid_key_dx< N > &  start,
grid_key_dx< N > &  stop 
) const
inline

Return a sub-grid iterator.

Return a sub-grid iterator, to iterate through the grid

Parameters
startstart point
stopstop point

Definition at line 690 of file grid_sm.hpp.

template<unsigned int N, typename T>
void grid_sm< N, T >::Initialize ( const size_t  sz)
inlineprivate

Initialize the basic structure.

Initialize the basic structure

Parameters
szvector that store the size of the grid on each dimensions

Initialize the basic structure for each dimension

Definition at line 110 of file grid_sm.hpp.

template<unsigned int N, typename T>
void grid_sm< N, T >::Initialize ( const size_t(&)  sz[N])
inlineprivate

Initialize the basic structure.

Initialize the basic structure

Parameters
szvector that store the size of the grid on each dimensions

Initialize the basic structure for each dimension

Definition at line 141 of file grid_sm.hpp.

template<unsigned int N, typename T>
void grid_sm< N, T >::Initialize ( )
inlineprivate

Initialize the basic structure.

Produce a grid of size 0 on each dimension

Initialize the basic structure for each dimension

Definition at line 169 of file grid_sm.hpp.

template<unsigned int N, typename T>
grid_key_dx<N> grid_sm< N, T >::InvLinId ( mem_id  id) const
inline

Construct.

inversion of the linearization of the grid_key_dx

Parameters
idof the object
Returns
key of the grid that id identify

Definition at line 503 of file grid_sm.hpp.

template<unsigned int N, typename T>
template<typename a , typename... lT>
mem_id grid_sm< N, T >::Lin ( v,
lT...  t 
) const
inline

linearize an arbitrary set of index

linearize an arbitrary set of index

Definition at line 477 of file grid_sm.hpp.

template<unsigned int N, typename T>
template<typename check = NoCheck>
mem_id grid_sm< N, T >::LinId ( const grid_key_dx< N > &  gk,
const char  sum_id[N] 
) const
inline

Linearization of the grid_key_dx with a specified shift.

Template Parameters
checkclass that check the linearization, if this check fail the function return -1
Parameters
gkgrid_key_dx to linearize
sum_idshift on each dimension
Returns
The linearization of the gk key shifted by c, or -1 if the check fail

Definition at line 337 of file grid_sm.hpp.

template<unsigned int N, typename T>
template<typename check = NoCheck>
mem_id grid_sm< N, T >::LinId ( const grid_key_dx< N > &  gk,
const char  sum_id[N],
const size_t(&)  bc[N] 
) const
inline

Linearization of the grid_key_dx with a specified shift.

Template Parameters
checkclass that check the linearization, if this check fail the function return -1
Parameters
gkgrid_key_dx to linearize
sum_idshift on each dimension
bcboundary conditions
Returns
The linearization of the gk key shifted by c, or -1 if the check fail

Definition at line 372 of file grid_sm.hpp.

template<unsigned int N, typename T>
mem_id grid_sm< N, T >::LinId ( const size_t(&)  k[N]) const
inline

Linearization of the grid_key_dx.

Linearization of the grid_key_dx given a key, it spit out a number that is just the 1D linearization of the key. In this case is the linearization of N index

Parameters
kgrid key to access the element on the grid

Definition at line 439 of file grid_sm.hpp.

template<unsigned int N, typename T>
mem_id grid_sm< N, T >::LinId ( const grid_key_dx< N > &  gk) const
inline

Linearization of the grid_key_dx.

Linearization of the grid_key_dx given a key, it spit out a number that is just the 1D linearization of the key. In this case is the linearization of N index

Parameters
gkgrid key to access the element of the grid

Definition at line 460 of file grid_sm.hpp.

template<unsigned int N, typename T>
template<unsigned int dim, unsigned int p>
mem_id grid_sm< N, T >::LinId ( const grid_key_d< dim, p > &  gk) const
inline

Linearization of the grid_key_d.

Linearization of the grid_key_d given a key, it spit out a number that is just the 1D linearization of the key. In this case is the linearization of N index

Parameters
gkgrid key to access the element on a key
Returns
index of the memory

Definition at line 529 of file grid_sm.hpp.

template<unsigned int N, typename T>
mem_id grid_sm< N, T >::LinId ( mem_id *  id) const
inline

Linearization of an array of mem_id (long int)

Linearization of an array of mem_id, it spit out a number that is just the 1D linearization of the key. In this case is the linearization of N index

Parameters
idan array of mem_id index

Definition at line 550 of file grid_sm.hpp.

template<unsigned int N, typename T>
mem_id grid_sm< N, T >::LinIdPtr ( size_t *  k) const
inline

Linearization of the set of indexes.

Linearization of the set of indexes, it spit out a number that is just the 1D linearization. In this case is the linearization of N index

Parameters
kset of indexes to linearize

Definition at line 419 of file grid_sm.hpp.

template<unsigned int N, typename T>
bool grid_sm< N, T >::operator!= ( const grid_sm< N, T > &  g)
inline

Check if the two grid_sm are the same.

Parameters
gelement to check

Definition at line 637 of file grid_sm.hpp.

template<unsigned int N, typename T>
grid_sm<N,T>& grid_sm< N, T >::operator= ( const grid_sm< N, T > &  g)
inline

Copy the grid from another grid.

Parameters
ggrid from witch to copy

Definition at line 583 of file grid_sm.hpp.

template<unsigned int N, typename T>
bool grid_sm< N, T >::operator== ( const grid_sm< N, T > &  g)
inline

Check if the two grid_sm are the same.

Parameters
gelement to check
Returns
true if they are the same

Definition at line 605 of file grid_sm.hpp.

template<unsigned int N, typename T>
void grid_sm< N, T >::setDimensions ( const size_t(&)  dims[N])
inline

Reset the dimension of the grid.

Parameters
dimsstore on each dimension the size of the grid

Definition at line 229 of file grid_sm.hpp.

template<unsigned int N, typename T>
size_t grid_sm< N, T >::size ( ) const
inline

Return the size of the grid.

Return the size of the grid

Returns
the size of the grid

Definition at line 572 of file grid_sm.hpp.

template<unsigned int N, typename T>
size_t grid_sm< N, T >::size ( unsigned int  i) const
inline

Get the size of the grid on the direction i

Parameters
idirection
Returns
the size on the direction i

Definition at line 667 of file grid_sm.hpp.

template<unsigned int N, typename T>
size_t grid_sm< N, T >::size_s ( unsigned int  i) const
inline

Get the stride-size of the grid on the direction i

[Example] on a grid 16*16*16 it return 16,256

Parameters
idirection
Returns
the size on the direction i

Definition at line 653 of file grid_sm.hpp.

template<unsigned int N, typename T>
void grid_sm< N, T >::swap ( grid_sm< N, T > &  g)
inline

swap the grid_sm informations

Parameters
ggrid to swap

Definition at line 700 of file grid_sm.hpp.

template<unsigned int N, typename T>
std::string grid_sm< N, T >::toString ( ) const
inline

Produce a string from the object.

Returns
string

Definition at line 727 of file grid_sm.hpp.


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