OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
grid_key_dx_iterator< dim, stencil, linearizer > Class Template Reference

Detailed Description

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
class grid_key_dx_iterator< dim, stencil, linearizer >

Grid key class iterator, iterate through the grid element

Template Parameters
dimdimensionality of the grid
stencilstencil type iterator
Note
if you have a grid you can get this object from getIterator()

Grid iterator declaration and usage

size_t count = 0;
// Subdivisions
size_t div[3] = {16,16,16};
// grid info
grid_sm<3,void> g_info(div);
// Create a grid iterator
// Iterate on all the elements
while (g_it.isNext())
{
grid_key_dx<3> key = g_it.get();
// set the grid key to zero without any reason ( to avoid warning compilations )
key.zero();
count++;
++g_it;
}
BOOST_REQUIRE_EQUAL(count, (size_t)16*16*16);
grid_key_dx is the key to access any element in the grid
Definition grid_key.hpp:19
void zero()
Set to zero the key.
Definition grid_key.hpp:170
__device__ __host__ index_type get(index_type i) const
Get the i index.
Definition grid_key.hpp:503
Declaration grid_sm.
Definition grid_sm.hpp:167

Definition at line 28 of file grid_key_dx_iterator.hpp.

#include <grid_key_dx_iterator.hpp>

+ Inheritance diagram for grid_key_dx_iterator< dim, stencil, linearizer >:

Public Member Functions

 grid_key_dx_iterator ()
 Default constructor.
 
 grid_key_dx_iterator (const grid_key_dx_iterator< dim > &g_it)
 Constructor from a grid_key_dx_iterator<dim>
 
template<typename grid_lin >
 grid_key_dx_iterator (const grid_lin &g, const grid_key_dx< dim >(&stencil_pnt)[stencil::nsp])
 Constructor require a grid_sm<dim,T>
 
 grid_key_dx_iterator (const grid_key_dx< dim >(&stencil_pnt)[stencil::nsp])
 Constructor.
 
 grid_key_dx_iterator (const linearizer &g)
 Constructor require a grid_sm<dim,T>
 
grid_key_dx_iterator< dim > operator= (const grid_key_dx_iterator< dim > &key_it)
 Constructor from another grid_key_dx_iterator.
 
grid_key_dx_iterator< dim, stencil, linearizer > & operator++ ()
 Get the next element.
 
void set (int d, size_t sz)
 Set the dimension.
 
template<unsigned int id>
size_t getStencil () const
 Get the actual position.
 
bool isNext ()
 Check if there is the next element.
 
const grid_key_dx< dim > & get () const
 Get the actual key.
 
void reinitialize (const grid_key_dx_iterator< dim > &key)
 Reinitialize the grid_key_dx_iterator.
 
const linearizer & getGridInfo () const
 Get the information about the grid.
 
void reset ()
 Reset the iterator (it restart from the beginning)
 
void calc_stencil_offset (const grid_key_dx< dim > &start_p)
 Calculate the stencil offset.
 
grid_key_dx< dim > getStart ()
 Return the starting point of the iteration.
 
grid_key_dx< dim > getStop ()
 Return the stop point of the iteration.
 
size_t getVolume ()
 Get the volume spanned by this sub-grid iterator.
 

Protected Attributes

grid_key_dx< dim > gk
 Actual key.
 
stencil stl_code
 

Private Member Functions

size_t get_gk (size_t i) const
 return the index i of the gk key
 

Private Attributes

linearizer grid_base
 information of the grid where this iterator iterate
 

Constructor & Destructor Documentation

◆ grid_key_dx_iterator() [1/5]

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
grid_key_dx_iterator< dim, stencil, linearizer >::grid_key_dx_iterator ( )
inline

Default constructor.

Warning
entremly unsafe Before use the iterator you have call reinitialize

Definition at line 69 of file grid_key_dx_iterator.hpp.

◆ grid_key_dx_iterator() [2/5]

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
grid_key_dx_iterator< dim, stencil, linearizer >::grid_key_dx_iterator ( const grid_key_dx_iterator< dim > &  g_it)
inline

Constructor from a grid_key_dx_iterator<dim>

Parameters
g_itgrid_key_dx_iterator<dim>

Initialize to 0 the index

Definition at line 80 of file grid_key_dx_iterator.hpp.

◆ grid_key_dx_iterator() [3/5]

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
template<typename grid_lin >
grid_key_dx_iterator< dim, stencil, linearizer >::grid_key_dx_iterator ( const grid_lin &  g,
const grid_key_dx< dim >(&)  stencil_pnt[stencil::nsp] 
)
inline

Constructor require a grid_sm<dim,T>

Parameters
ginfo of the grid on which iterate
stencil_pntstencil points

Definition at line 104 of file grid_key_dx_iterator.hpp.

◆ grid_key_dx_iterator() [4/5]

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
grid_key_dx_iterator< dim, stencil, linearizer >::grid_key_dx_iterator ( const grid_key_dx< dim >(&)  stencil_pnt[stencil::nsp])
inline

Constructor.

Using this constructor you must call reinitialize

Parameters
stencil_pntstencil points

Definition at line 128 of file grid_key_dx_iterator.hpp.

◆ grid_key_dx_iterator() [5/5]

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
grid_key_dx_iterator< dim, stencil, linearizer >::grid_key_dx_iterator ( const linearizer &  g)
inline

Constructor require a grid_sm<dim,T>

Parameters
ginfo of the grid on which iterate

Definition at line 138 of file grid_key_dx_iterator.hpp.

Member Function Documentation

◆ calc_stencil_offset()

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
void grid_key_dx_iterator< dim, stencil, linearizer >::calc_stencil_offset ( const grid_key_dx< dim > &  start_p)
inline

Calculate the stencil offset.

Parameters
start_pstarting point

Definition at line 317 of file grid_key_dx_iterator.hpp.

◆ get()

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
const grid_key_dx< dim > & grid_key_dx_iterator< dim, stencil, linearizer >::get ( ) const
inline

Get the actual key.

Get the actual key

Returns
the actual key

Definition at line 264 of file grid_key_dx_iterator.hpp.

◆ get_gk()

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
size_t grid_key_dx_iterator< dim, stencil, linearizer >::get_gk ( size_t  i) const
inlineprivate

return the index i of the gk key

Parameters
iindex to get
Returns
index value

Definition at line 47 of file grid_key_dx_iterator.hpp.

◆ getGridInfo()

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
const linearizer & grid_key_dx_iterator< dim, stencil, linearizer >::getGridInfo ( ) const
inline

Get the information about the grid.

Returns
the grid info

Definition at line 285 of file grid_key_dx_iterator.hpp.

◆ getStart()

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
grid_key_dx< dim > grid_key_dx_iterator< dim, stencil, linearizer >::getStart ( )
inline

Return the starting point of the iteration.

it is always the point (0,0) in 2D (0,0,0) in 3D ...

Definition at line 328 of file grid_key_dx_iterator.hpp.

◆ getStencil()

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
template<unsigned int id>
size_t grid_key_dx_iterator< dim, stencil, linearizer >::getStencil ( ) const
inline

Get the actual position.

Get the actual position

Returns
the actual key

Definition at line 231 of file grid_key_dx_iterator.hpp.

◆ getStop()

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
grid_key_dx< dim > grid_key_dx_iterator< dim, stencil, linearizer >::getStop ( )
inline

Return the stop point of the iteration.

Definition at line 340 of file grid_key_dx_iterator.hpp.

◆ getVolume()

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
size_t grid_key_dx_iterator< dim, stencil, linearizer >::getVolume ( )
inline

Get the volume spanned by this sub-grid iterator.

Returns
the volume

Definition at line 357 of file grid_key_dx_iterator.hpp.

◆ isNext()

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
bool grid_key_dx_iterator< dim, stencil, linearizer >::isNext ( )
inline

Check if there is the next element.

Check if there is the next element

Returns
true if there is the next, false otherwise

we did not reach the end of the grid

we reach the end of the grid

Definition at line 244 of file grid_key_dx_iterator.hpp.

◆ operator++()

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
grid_key_dx_iterator< dim, stencil, linearizer > & grid_key_dx_iterator< dim, stencil, linearizer >::operator++ ( )
inline

Get the next element.

Returns
the next grid_key

increment the first index

check the overflow of all the index with exception of the last dimensionality

Definition at line 173 of file grid_key_dx_iterator.hpp.

◆ operator=()

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
grid_key_dx_iterator< dim > grid_key_dx_iterator< dim, stencil, linearizer >::operator= ( const grid_key_dx_iterator< dim > &  key_it)
inline

Constructor from another grid_key_dx_iterator.

Parameters
key_itgrid_key_dx_iterator
Returns
itself

Initialize the index using key_it

Definition at line 155 of file grid_key_dx_iterator.hpp.

◆ reinitialize()

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
void grid_key_dx_iterator< dim, stencil, linearizer >::reinitialize ( const grid_key_dx_iterator< dim > &  key)
inline

Reinitialize the grid_key_dx_iterator.

Parameters
keyform

Definition at line 274 of file grid_key_dx_iterator.hpp.

◆ reset()

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
void grid_key_dx_iterator< dim, stencil, linearizer >::reset ( )
inline

Reset the iterator (it restart from the beginning)

Definition at line 293 of file grid_key_dx_iterator.hpp.

◆ set()

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
void grid_key_dx_iterator< dim, stencil, linearizer >::set ( int  d,
size_t  sz 
)
inline

Set the dimension.

Set the dimension

Parameters
dis the dimension
szset the counter to sz

Definition at line 217 of file grid_key_dx_iterator.hpp.

Field Documentation

◆ gk

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
grid_key_dx<dim> grid_key_dx_iterator< dim, stencil, linearizer >::gk
protected

Actual key.

Definition at line 55 of file grid_key_dx_iterator.hpp.

◆ grid_base

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
linearizer grid_key_dx_iterator< dim, stencil, linearizer >::grid_base
private

information of the grid where this iterator iterate

Definition at line 37 of file grid_key_dx_iterator.hpp.

◆ stl_code

template<unsigned int dim, typename stencil = no_stencil, typename linearizer = grid_sm<dim,void>>
stencil grid_key_dx_iterator< dim, stencil, linearizer >::stl_code
protected

Additional operation and information in case we do stencil operations

Definition at line 59 of file grid_key_dx_iterator.hpp.


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