8#ifndef OPENFPM_DATA_SRC_GRID_ITERATORS_GRID_KEY_DX_ITERATOR_SUB_HPP_
9#define OPENFPM_DATA_SRC_GRID_ITERATORS_GRID_KEY_DX_ITERATOR_SUB_HPP_
11#include "grid_key_dx_iterator.hpp"
12#include "Grid/grid_key.hpp"
20template <
unsigned int dim,
typename linearizer>
30 inline static void pw1(
size_t i,
const grid_key_dx<dim> & gk_start) {std::cerr <<
"Warning: " << __FILE__ <<
":" << __LINE__ <<
" start with index smaller than zero x[" << i <<
"]=" << gk_start.
get(i) <<
"\n";}
38 inline static void pw2(
size_t i,
const grid_key_dx<dim> & gk_start) {std::cerr <<
"Warning: " << __FILE__ <<
":" << __LINE__ <<
" Cropping start point x[" << i <<
"]=" << gk_start.
get(i) <<
" to x[" << i <<
"]=0 \n" ;}
45 inline static void pw3() {std::cerr <<
"Warning: " << __FILE__ <<
":" << __LINE__ <<
" stop with smaller index than start \n";}
55 inline static void pw4(
size_t i,
const grid_key_dx<dim> & gk_stop,
const linearizer &
grid_base) {std::cerr <<
"Warning: " << __FILE__ <<
":" << __LINE__ <<
" stop index bigger than cell domain x[" << i <<
"]=" << gk_stop.
get(i) <<
" > " <<
grid_base.size(i) <<
"\n";}
61 inline static void pw5() {std::cerr <<
"Warning grid_key_dx_iterator_sub: " << __FILE__ <<
":" << __LINE__ <<
" the starting point is not smaller or equal than than the stop point in all the coordinates" <<
"\n";}
71template <
unsigned int dim,
typename linearizer>
96 inline static void pw3() {}
111 inline static void pw5() {}
114template<
unsigned int dim,
typename stl_type,
typename linearizer>
124 for ( ; i < dim-1 ; i++)
127 size_t id = gk.
get(i);
128 if ((
long int)
id > gk_stop.
get(i))
132 size_t idr = gk.
get(i) - gk_start.
get(i);
161template<
unsigned int dim,
typename stencil,
typename linearizer,
typename warn>
165 bool initialized =
false;
184 for (
size_t i = 0 ; i < dim ; i++)
229 for (
unsigned int i = 0 ; i < dim ; i++)
250 for ( ; i < dim-1 ; i++)
253 size_t id = this->
gk.
get(i);
260 id = this->
gk.
get(i+1);
296 for (
unsigned int i = 0 ; i < dim ; i++)
331 for (
unsigned int i = 0 ; i < dim ; i++)
368 for (
unsigned int i = 0 ; i < dim ; i++)
411 for (
unsigned int i = 0 ; i < dim ; i++)
432 const size_t (& start)[dim],
433 const size_t (& stop)[dim])
440 for (
unsigned int i = 0 ; i < dim ; i++)
442 if (start[i] > stop[i])
462 if (initialized ==
false)
463 {std::cerr <<
"Error: " << __FILE__ << __LINE__ <<
" using unitialized iterator" <<
"\n";}
468 size_t id = this->
gk.
get(0);
488 if (initialized ==
false)
489 {std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using unitialized iterator" <<
"\n";}
492 for (
size_t i = 0 ; i < nsteps ; i++)
510 if (initialized ==
false)
511 {std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" using unitialized iterator" <<
"\n";}
533 if (initialized ==
false)
534 {std::cerr <<
"Error: " << __FILE__ << __LINE__ <<
" using unitialized iterator" <<
"\n";}
562 for (
unsigned int i = 0 ; i < dim ; i++)
594 for (
size_t i = 0 ; i < dim ; i++)
633 template<
unsigned int tot_add>
636 this->
stl_code.template private_sum<tot_add>();
646 this->
stl_code.private_adjust(tot_add);
655 this->gk_stop.
set_d(dim-1,0);
658 this->initialized =
true;
679template<
typename warn>
T getVolumeKey() const
Get the volume spanned by the Box P1 and P2 interpreted as grid key.
static void pw1(size_t i, const grid_key_dx< dim > &gk_start)
print warning type1
static void pw2(size_t i, const grid_key_dx< dim > &gk_start)
print warning type2
static void pw5()
print warning type5
static void pw3()
print warning type3
static void pw4(size_t i, const grid_key_dx< dim > &gk_stop, const linearizer &grid_base)
print warning type4
bool isNext()
Is there a next point.
grid_key_dx_iterator< 0 > & operator++()
Next point.
void reset()
Reset the iterator.
size_t getVolume()
return the volume
Declaration grid_key_dx_iterator_sub.
grid_key_dx< dim > get() const
Return the actual grid key iterator.
void private_sum()
Sum a template constant.
void private_adjust(size_t tot_add)
Sum a template constant.
bool isNext()
Check if there is the next element.
grid_key_dx_iterator_sub(const linearizer &g, const size_t m)
Constructor require a grid grid<dim,T>
void reinitialize(const grid_key_dx_iterator_sub< dim > &g_s_it)
Reinitialize the iterator.
const grid_key_dx< dim > & getStart() const
Starting point.
grid_key_dx< dim > gk_start
start point
size_t getVolume()
Get the volume spanned by this sub-grid iterator.
grid_key_dx_iterator_sub(const linearizer &g, const grid_key_dx< dim > &start, const grid_key_dx< dim > &stop)
Constructor require a grid grid<dim,T>
grid_key_dx_iterator_sub()
Default constructor.
grid_key_dx_iterator_sub(const linearizer &g, const size_t(&start)[dim], const size_t(&stop)[dim])
Constructor require a grid grid<dim,T>
grid_key_dx_iterator_sub(const linearizer &g, const grid_key_dx< dim > &start, const grid_key_dx< dim > &stop, const grid_key_dx< dim >(&stencil_pnt)[stencil::nsp])
Constructor require a grid grid<dim,T>
const grid_key_dx< dim > & getStop() const
Stop point.
linearizer grid_base
grid base where we are iterating
void Initialize()
Initialize gk.
grid_key_dx_iterator_sub(const grid_key_dx< dim >(&stencil_pnt)[stencil::nsp])
Constructor.
grid_key_dx< dim > gk_stop
stop point
void post_increment()
After incremented we have to check we did not overflo any dimension and in case adjust the dimensions...
const linearizer & getGridInfo() const
Return the grid information related to this grid.
void reset()
Reset the iterator (it restart from the beginning)
grid_key_dx_iterator_sub(const grid_key_dx_iterator_sub< dim, stencil, linearizer > &g_s_it)
Constructor from another grid_key_dx_iterator_sub.
grid_key_dx_iterator_sub< dim, stencil, warn > & operator+=(int nsteps)
increment the operator by more than one
grid_key_dx_iterator_sub< dim, stencil, linearizer, warn > & operator++()
Get the next element.
void reinitialize(const grid_key_dx_iterator< dim > &key)
Reinitialize the grid_key_dx_iterator.
const grid_key_dx< dim > & get() const
Get the actual key.
grid_key_dx< dim > gk
Actual key.
void calc_stencil_offset(const grid_key_dx< dim > &start_p)
Calculate the stencil offset.
grid_key_dx is the key to access any element in the grid
__device__ __host__ void set_d(index_type i, index_type id)
Set the i index.
const long int(& get_k() const)[dim]
Return the internal k structure.
__device__ __host__ index_type get(index_type i) const
Get the i index.
Declaration print_warning_on_adjustment.
static void pw5()
print warning type5
static void pw4(size_t i, const grid_key_dx< dim > &gk_stop, const linearizer &grid_base)
print warning type4
static void pw2(size_t i, const grid_key_dx< dim > &gk_start)
print warning type2
static void pw1(size_t i, const grid_key_dx< dim > &gk_start)
print warning type1
static void pw3()
print warning type3