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"
20 template <
unsigned int dim>
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 grid_sm<dim,void> & 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";}
71 template <
unsigned int dim>
96 inline static void pw3() {}
111 inline static void pw5() {}
114 template<
unsigned int dim,
typename stl_type>
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);
137 stl_code.adjust_offset(i,idr,grid_base);
161 template<
unsigned int dim,
typename stencil,
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);
254 if ((
long int)
id >
gk_stop.get(i))
258 size_t idr = this->
gk.get(i) -
gk_start.get(i);
260 id = this->
gk.get(i+1);
261 this->
gk.set_d(i+1,
id+1);
296 for (
unsigned int i = 0 ; i < dim ; i++)
329 for (
unsigned int i = 0 ; i < dim ; i++)
367 for (
unsigned int i = 0 ; i < dim ; i++)
410 for (
unsigned int i = 0 ; i < dim ; i++)
438 for (
unsigned int i = 0 ; i < dim ; i++)
440 if (start[i] > stop[i])
460 if (initialized ==
false)
461 {std::cerr <<
"Error: " << __FILE__ << __LINE__ <<
" using unitialized iterator" <<
"\n";}
466 size_t id = this->
gk.get(0);
467 this->
gk.set_d(0,
id+1);
484 if (initialized ==
false)
485 {std::cerr <<
"Error: " << __FILE__ << __LINE__ <<
" using unitialized iterator" <<
"\n";}
488 for (
size_t i = 0 ; i < nsteps ; i++)
506 if (initialized ==
false)
507 {std::cerr <<
"Error: " << __FILE__ << __LINE__ <<
" using unitialized iterator" <<
"\n";}
510 if (this->
gk.get(dim-1) <=
gk_stop.get(dim-1))
529 if (initialized ==
false)
530 {std::cerr <<
"Error: " << __FILE__ << __LINE__ <<
" using unitialized iterator" <<
"\n";}
559 for (
unsigned int i = 0 ; i < dim ; i++)
591 for (
size_t i = 0 ; i < dim ; i++)
630 template<
unsigned int tot_add>
633 this->
stl_code.template private_sum<tot_add>();
663 template<
typename warn>
void private_adjust(size_t tot_add)
Sum a template constant.
Declaration print_warning_on_adjustment.
grid_key_dx_iterator_sub(const grid_sm< dim, T > &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>
grid_key_dx_iterator_sub(const grid_sm< dim, T > &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< dim, stencil, warn > & operator++()
Get the next element.
static void pw4(size_t i, const grid_key_dx< dim > &gk_stop, const grid_sm< dim, void > &grid_base)
print warning type4
grid_key_dx_iterator_sub< dim, stencil, warn > & operator+=(int nsteps)
increment the operator by more than one
grid_key_dx is the key to access any element in the grid
void reinitialize(const grid_key_dx_iterator< dim > &key)
Reinitialize the grid_key_dx_iterator.
size_t getVolume()
Get the volume spanned by this sub-grid iterator.
size_t size() const
Return the size of the grid.
grid_key_dx_iterator_sub(const grid_sm< dim, T > &g, const size_t m)
Constructor require a grid grid<dim,T>
const grid_key_dx< dim > & getStop() const
Stop point.
grid_key_dx_iterator_sub()
Default constructor.
grid_key_dx_iterator_sub(const grid_sm< dim, T > &g, const size_t(&start)[dim], const size_t(&stop)[dim])
Constructor require a grid grid<dim,T>
grid_key_dx_iterator< 0 > & operator++()
Next point.
const grid_sm< dim, void > & getGridInfo() const
Return the grid information related to this grid.
void calc_stencil_offset(const grid_key_dx< dim > &start_p)
Calculate the stencil offset.
static void pw4(size_t i, const grid_key_dx< dim > &gk_stop, const grid_sm< dim, void > &grid_base)
print warning type4
static void pw5()
print warning type5
mem_id get(size_t i) const
Get the i index.
void reset()
Reset the iterator.
void Initialize()
Initialize gk.
static void pw2(size_t i, const grid_key_dx< dim > &gk_start)
print warning type2
void private_sum()
Sum a template constant.
grid_sm< dim, void > grid_base
grid base where we are iterating
grid_key_dx_iterator_sub(const grid_key_dx< dim >(&stencil_pnt)[stencil::nsp])
Constructor.
static void pw3()
print warning type3
bool isNext()
Is there a next point.
const grid_key_dx< dim > & get() const
Get the actual key.
static void pw5()
print warning type5
static void pw3()
print warning type3
size_t getVolume()
return the volume
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
grid_key_dx< dim > gk
Actual key.
grid_key_dx_iterator_sub(const grid_key_dx_iterator_sub< dim, stencil > &g_s_it)
Constructor from another grid_key_dx_iterator_sub.
Declaration grid_key_dx_iterator_sub.
grid_key_dx< dim > gk_start
start point
grid_key_dx< dim > gk_stop
stop point
void set_d(size_t i, mem_id id)
Set the i index.
T getVolumeKey() const
Get the volume spanned by the Box P1 and P2 interpreted as grid key.
void reset()
Reset the iterator (it restart from the beginning)
bool isNext()
Check if there is the next element.
void post_increment()
After incremented we have to check we did not overflo any dimension and in case adjust the dimensions...
const grid_key_dx< dim > & getStart() const
Starting point.
void reinitialize(const grid_key_dx_iterator_sub< dim > &g_s_it)
Reinitialize the iterator.
static void pw1(size_t i, const grid_key_dx< dim > &gk_start)
print warning type1