OpenFPM_data  0.1.0
Project that contain the implementation and interfaces for basic structure like vectors, grids, graph ... .
 All Data Structures Namespaces Functions Variables Typedefs Friends
grid_sm< N, T > Class Template Reference

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

Detailed Description

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

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 69 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...
 
void setDimensions (std::vector< size_t > &dims)
 Reset the dimension of the grid. More...
 
void setDimensions (const size_t(&dims)[N])
 Reset the dimension of the grid. More...
 
bool isLinearizeLinear ()
 Is linearize additive. 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)[N])
 
size_t totalSize (const std::vector< size_t > &sz)
 
 grid_sm (std::vector< 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...
 
 grid_sm (std::vector< size_t > &&sz)
 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 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
 
std::vector< size_t > getVectorSize ()
 Return the size of the grid as an std::vector. More...
 
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...
 

Private Member Functions

size_t mulLin (size_t a, size_t b)
 It multiplicate two number and return the result. More...
 
void Initialize (std::vector< 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 242 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

construct a grid from another grid, type can be different

Definition at line 254 of file grid_sm.hpp.

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

Construct a grid of a specified size.

Construct a grid of a specified size

Parameters
szis an std::vector that contain the size of the grid on each dimension

Definition at line 304 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 318 of file grid_sm.hpp.

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

Construct a grid of a specified size.

Construct a grid of a specified size

Parameters
szis an std::vector that contain the size of the grid on each dimension

Definition at line 332 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.

Definition at line 194 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 674 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 687 of file grid_sm.hpp.

template<unsigned int N, typename T>
std::vector<size_t> grid_sm< N, T >::getVectorSize ( )
inline

Return the size of the grid as an std::vector.

Returns
get the size of the grid as an std::vector

Definition at line 657 of file grid_sm.hpp.

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

Initialize the basic structure.

Initialize the basic structure

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

Definition at line 118 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 142 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 483 of file grid_sm.hpp.

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

Is linearize additive.

Is linearize a linear function, in this case for stride return true because linearize respect the property

Linearize(key1 + key2) = Linearize(key1) + Linearize(key2)

Definition at line 231 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 457 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 354 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 421 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 441 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 509 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 530 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 401 of file grid_sm.hpp.

template<unsigned int N, typename T>
size_t grid_sm< N, T >::mulLin ( size_t  a,
size_t  b 
)
inlineprivate

It multiplicate two number and return the result.

It multiplicate two number and return the result, mainly used for LinId

Parameters
aoperand 1
boperand 2

Definition at line 104 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 617 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 563 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 585 of file grid_sm.hpp.

template<unsigned int N, typename T>
void grid_sm< N, T >::setDimensions ( std::vector< size_t > &  dims)
inline

Reset the dimension of the grid.

Parameters
dimsstd::vector that store on each dimension the size of the grid

Definition at line 205 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 216 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 552 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 647 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 633 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 697 of file grid_sm.hpp.


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