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

Detailed Description

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

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);

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 >:

Public Member Functions

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

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 More...
 

Private Attributes

grid_sm< dim, void > grid_base
 information of the grid where this iterator iterate
 

Constructor & Destructor Documentation

template<unsigned int dim, typename stencil = no_stencil>
grid_key_dx_iterator< dim, stencil >::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.

template<unsigned int dim, typename stencil = no_stencil>
grid_key_dx_iterator< dim, stencil >::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.

template<unsigned int dim, typename stencil = no_stencil>
template<typename T >
grid_key_dx_iterator< dim, stencil >::grid_key_dx_iterator ( const grid_sm< dim, T > &  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.

template<unsigned int dim, typename stencil = no_stencil>
grid_key_dx_iterator< dim, stencil >::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.

template<unsigned int dim, typename stencil = no_stencil>
template<typename T >
grid_key_dx_iterator< dim, stencil >::grid_key_dx_iterator ( const grid_sm< dim, T > &  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

template<unsigned int dim, typename stencil = no_stencil>
void grid_key_dx_iterator< dim, stencil >::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.

template<unsigned int dim, typename stencil = no_stencil>
const grid_key_dx<dim>& grid_key_dx_iterator< dim, stencil >::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.

template<unsigned int dim, typename stencil = no_stencil>
size_t grid_key_dx_iterator< dim, stencil >::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.

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

Get the information about the grid.

Returns
the grid info

Definition at line 285 of file grid_key_dx_iterator.hpp.

template<unsigned int dim, typename stencil = no_stencil>
grid_key_dx<dim> grid_key_dx_iterator< dim, stencil >::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.

template<unsigned int dim, typename stencil = no_stencil>
template<unsigned int id>
size_t grid_key_dx_iterator< dim, stencil >::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.

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

Return the stop point of the iteration.

Definition at line 340 of file grid_key_dx_iterator.hpp.

template<unsigned int dim, typename stencil = no_stencil>
size_t grid_key_dx_iterator< dim, stencil >::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.

template<unsigned int dim, typename stencil = no_stencil>
bool grid_key_dx_iterator< dim, stencil >::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.

template<unsigned int dim, typename stencil = no_stencil>
grid_key_dx_iterator<dim,stencil>& grid_key_dx_iterator< dim, stencil >::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.

template<unsigned int dim, typename stencil = no_stencil>
grid_key_dx_iterator<dim> grid_key_dx_iterator< dim, stencil >::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.

template<unsigned int dim, typename stencil = no_stencil>
void grid_key_dx_iterator< dim, stencil >::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.

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

Reset the iterator (it restart from the beginning)

Definition at line 293 of file grid_key_dx_iterator.hpp.

template<unsigned int dim, typename stencil = no_stencil>
void grid_key_dx_iterator< dim, stencil >::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

template<unsigned int dim, typename stencil = no_stencil>
stencil grid_key_dx_iterator< dim, stencil >::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: