OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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 166 of file grid_sm.hpp.

#include <grid_sm.hpp>

+ Inheritance diagram for grid_sm< N, T >:

Public Member Functions

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

Private Member Functions

__device__ __host__ void Initialize (const size_t sz)
 Initialize the basic structure.
 
__device__ __host__ void Initialize (const size_t(&sz)[N])
 Initialize the basic structure.
 
void Initialize ()
 Initialize the basic structure.
 
template<typename a , typename ... lT>
__device__ __host__ mem_id Lin_impl (a v, lT...t) const
 linearize an arbitrary set of index
 
template<typename a >
__device__ __host__ mem_id Lin_impl (a v) const
 Linearize a set of index.
 

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

◆ grid_sm() [1/5]

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 338 of file grid_sm.hpp.

◆ grid_sm() [2/5]

template<unsigned int N, typename T >
template<typename S >
__device__ __host__ 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 357 of file grid_sm.hpp.

◆ grid_sm() [3/5]

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

copy constructor

Parameters
ggrid info

construct a grid from another grid. As a copy constructor can't be template, the one above won't work for const grid_sm<N,S> & g, where S=T

Definition at line 376 of file grid_sm.hpp.

◆ grid_sm() [4/5]

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 424 of file grid_sm.hpp.

◆ grid_sm() [5/5]

template<unsigned int N, typename T >
__device__ __host__ 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 438 of file grid_sm.hpp.

◆ ~grid_sm()

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

Destructor.

Definition at line 648 of file grid_sm.hpp.

Member Function Documentation

◆ getBox()

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

Return the box enclosing the grid.

Returns
the box

Definition at line 294 of file grid_sm.hpp.

◆ getBoxKey()

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 308 of file grid_sm.hpp.

◆ getSize() [1/2]

template<unsigned int N, typename T >
__device__ __host__ 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 760 of file grid_sm.hpp.

◆ getSize() [2/2]

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

Returns the size of the grid in the passed array.

Returns
the size of the grid in the passed array

Definition at line 770 of file grid_sm.hpp.

◆ getSubIterator()

template<unsigned int N, typename T >
grid_key_dx_iterator_sub< N > grid_sm< N, T >::getSubIterator ( const grid_key_dx< N > &  start,
const 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 783 of file grid_sm.hpp.

◆ Initialize() [1/3]

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 248 of file grid_sm.hpp.

◆ Initialize() [2/3]

template<unsigned int N, typename T >
__device__ __host__ 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 189 of file grid_sm.hpp.

◆ Initialize() [3/3]

template<unsigned int N, typename T >
__device__ __host__ 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 220 of file grid_sm.hpp.

◆ InvLinId()

template<unsigned int N, typename T >
__device__ __host__ 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 609 of file grid_sm.hpp.

◆ Lin()

template<unsigned int N, typename T >
template<typename a , typename ... lT, typename enabler = typename std::enable_if<sizeof...(lT) == N-1>::type>
__device__ __host__ 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 596 of file grid_sm.hpp.

◆ Lin_impl() [1/2]

template<unsigned int N, typename T >
template<typename a >
__device__ __host__ mem_id grid_sm< N, T >::Lin_impl ( v) const
inlineprivate

Linearize a set of index.

Definition at line 281 of file grid_sm.hpp.

◆ Lin_impl() [2/2]

template<unsigned int N, typename T >
template<typename a , typename ... lT>
__device__ __host__ mem_id grid_sm< N, T >::Lin_impl ( v,
lT...  t 
) const
inlineprivate

linearize an arbitrary set of index

linearize an arbitrary set of index

Definition at line 275 of file grid_sm.hpp.

◆ LinId() [1/5]

template<unsigned int N, typename T >
template<typename ids_type >
__device__ __host__ mem_id grid_sm< N, T >::LinId ( const grid_key_dx< N, ids_type > &  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 578 of file grid_sm.hpp.

◆ LinId() [2/5]

template<unsigned int N, typename T >
template<typename check = NoCheck, typename ids_type >
mem_id grid_sm< N, T >::LinId ( const grid_key_dx< N, ids_type > &  gk,
const signed 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 454 of file grid_sm.hpp.

◆ LinId() [3/5]

template<unsigned int N, typename T >
template<typename check = NoCheck, typename ids_type >
mem_id grid_sm< N, T >::LinId ( const grid_key_dx< N, ids_type > &  gk,
const signed 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 490 of file grid_sm.hpp.

◆ LinId() [4/5]

template<unsigned int N, typename T >
__device__ __host__ 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 557 of file grid_sm.hpp.

◆ LinId() [5/5]

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 635 of file grid_sm.hpp.

◆ LinIdPtr()

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 537 of file grid_sm.hpp.

◆ operator!=()

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 720 of file grid_sm.hpp.

◆ operator=()

template<unsigned int N, typename T >
__device__ __host__ 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 668 of file grid_sm.hpp.

◆ operator==()

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 691 of file grid_sm.hpp.

◆ setDimensions()

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 326 of file grid_sm.hpp.

◆ size() [1/2]

template<unsigned int N, typename T >
__device__ __host__ 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 657 of file grid_sm.hpp.

◆ size() [2/2]

template<unsigned int N, typename T >
__device__ __host__ 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 750 of file grid_sm.hpp.

◆ size_s()

template<unsigned int N, typename T >
__device__ __host__ 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 736 of file grid_sm.hpp.

◆ swap()

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 829 of file grid_sm.hpp.

◆ toString()

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 852 of file grid_sm.hpp.

◆ totalSize() [1/2]

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

Definition at line 389 of file grid_sm.hpp.

◆ totalSize() [2/2]

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

Definition at line 403 of file grid_sm.hpp.

Friends And Related Symbol Documentation

◆ grid_sm

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

It simply mean that all the classes grid are friend of all its specialization.

Definition at line 863 of file grid_sm.hpp.

Field Documentation

◆ box

template<unsigned int N, typename T >
Box<N,size_t> grid_sm< N, T >::box
private

Box enclosing the grid.

Definition at line 169 of file grid_sm.hpp.

◆ size_tot

template<unsigned int N, typename T >
size_t grid_sm< N, T >::size_tot
private

total number of the elements in the grid

Definition at line 172 of file grid_sm.hpp.

◆ sz

template<unsigned int N, typename T >
size_t grid_sm< N, T >::sz[N]
private

size of the grid

Definition at line 175 of file grid_sm.hpp.

◆ sz_s

template<unsigned int N, typename T >
size_t grid_sm< N, T >::sz_s[N]
private

size of the grid on each stride (used for linearization)

Definition at line 178 of file grid_sm.hpp.


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