8 #ifndef SRC_GRID_GRID_DIST_ID_ITERATOR_SUB_HPP_ 9 #define SRC_GRID_GRID_DIST_ID_ITERATOR_SUB_HPP_ 21 template<
unsigned int dim,
typename device_gr
id>
43 decltype(device_grid::type_of_subiterator())
a_it;
64 for (
size_t i = 0 ; i < dim ; i++)
69 start_c.set_d(i,
gdb_ext.get(
g_c).Dbox.getP1().get(i));
76 stop_c.set_d(i,
gdb_ext.get(
g_c).Dbox.getP2().get(i));
77 else if (
stop.
get(i) >= start_p)
105 a_it.reinitialize(
gList.get(
g_c).getIterator(start_c,stop_c));
106 if (
a_it.isNext() ==
false) {
g_c++;}
142 if (reinitialize ==
true)
182 if (
a_it.isNext() ==
true)
231 size_t sub_id = k.getSub();
236 k_glob = k_glob +
gdb_ext.get(sub_id).origin;
280 return gdb_ext.get(i).DBox.getLow(i);
293 return gdb_ext.get(i).GDBox.getHigh(i);
300 #define WHILE_M(grid,stencil) auto & ginfo = grid.getLocalGridsInfo();\ 301 for (size_t s = 0 ; s < grid.getN_loc_grid() ; s++)\ 303 auto it = grid.get_loc_grid_iterator_stencil(s,stencil);\ 305 int lo[3] = {(int)ginfo.get(s).Dbox.getLow(0),(int)ginfo.get(s).Dbox.getLow(1),(int)ginfo.get(s).Dbox.getLow(2)};\ 306 int hi[3] = {(int)ginfo.get(s).Dbox.getHigh(0),(int)ginfo.get(s).Dbox.getHigh(1),(int)ginfo.get(s).Dbox.getHigh(2)};\ 308 int uhi[3] = {(int)ginfo.get(s).GDbox.getHigh(0),(int)ginfo.get(s).GDbox.getHigh(1),(int)ginfo.get(s).GDbox.getHigh(2)};\ 311 int sxsy = (uhi[0]+1)*(uhi[1]+1); 313 #define ITERATE_3D_M(n_pt) int i = lo[2];\ 314 for ( ; i <= hi[2] ; i+=1)\ 317 for ( ; j <= hi[1] ; j+=1)\ 320 for ( ; k <= hi[0] ; k+=n_pt)\ 324 #define GET_GRID_M(grid) grid.get_loc_grid(s); 327 #define END_LOOP_M(n_pt) it.private_sum<n_pt>();\ 329 it.private_adjust( - k + sx + lo[0]);\ 331 it.private_adjust(- j*sx + sxsy + lo[1]*sx);\ grid_dist_iterator_sub(const grid_dist_iterator_sub< dim, device_grid > &tmp, bool reinitialize=true)
Copy constructor.
grid_key_dx< dim > start
start key
decltype(device_grid::type_of_subiterator()) a_it
Actual iterator.
grid_key_dx< dim > stop
stop key
bool isNext()
Check if there is the next element.
size_t N_loc_grid()
Return the number of local grids.
__device__ __host__ index_type get(index_type i) const
Get the i index.
Grid key for a distributed grid.
grid_dist_iterator_sub< dim, device_grid > & operator++()
Get the next element.
grid_dist_iterator_sub(const grid_key_dx< dim > &start, const grid_key_dx< dim > &stop, const openfpm::vector< device_grid > &gk, const openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext)
Constructor of the distributed grid iterator.
bool compute_subset(size_t gc, grid_key_dx< dim > &start_c, grid_key_dx< dim > &stop_c)
compute the subset where it has to iterate
This structure store the Box that define the domain inside the Ghost + domain box.
size_t loc_grid_info_size(size_t i, size_t j)
Return the component j of the stop point (P2) of the domain part for the local grid i.
const openfpm::vector< device_grid > & gList
List of the grids we are going to iterate.
size_t g_c
grid list counter
grid_key_dx< dim > getGKey(const grid_dist_key_dx< dim > &k)
Convert a g_dist_key_dx into a global key.
grid_key_dx< dim > stop
stop point where iterate
Distributed grid iterator.
grid_dist_iterator_sub< dim, device_grid > & operator=(const grid_dist_iterator_sub< dim, device_grid > &tmp)
Copy operator=.
void selectValidGrid()
from g_c increment g_c until you find a valid grid
grid_key_dx< dim > start
start point where iterate
grid_dist_key_dx< dim, typename device_grid::base_key > get()
Get the actual key.
const openfpm::vector< GBoxes< device_grid::dims > > & gdb_ext
Extension of each grid: domain and ghost + domain.
size_t loc_grid_info_start(size_t i, size_t j)
Return the component j of the starting point (P1) of the domain part for the local grid i.