8#ifndef OPENFPM_DATA_SRC_SPARSEGRID_SPARSEGRID_ITERATOR_HPP_
9#define OPENFPM_DATA_SRC_SPARSEGRID_SPARSEGRID_ITERATOR_HPP_
58template<
unsigned int n_ele>
59inline void fill_mask(
short unsigned int (& mask_it)[n_ele],
60 const unsigned char (& mask)[n_ele],
65 for (
size_t i = 0 ; i < n_ele ; i++)
69 mask_it[mask_nele] = i;
79template<
unsigned int dim,
unsigned int n_ele>
80inline void fill_mask_box(
short unsigned int (& mask_it)[n_ele],
81 const unsigned char (& mask)[n_ele],
88 for (
size_t i = 0 ; i < n_ele ; i++)
92 bool is_inside =
true;
94 for (
size_t j = 0 ; j < dim ; j++)
96 if (loc_grid[
id].get(j) < (
long int)bx.
getLow(j) ||
97 loc_grid[
id].get(j) > (
long int)bx.
getHigh(j))
105 if (is_inside ==
true && (mask[i] & 1))
107 mask_it[mask_nele] = id;
119template<
unsigned int n_ele>
133template<
unsigned int dim>
147template<
unsigned dim,
unsigned int n_ele>
150 const static int cnk_pos = 0;
151 const static int cnk_nele = 1;
152 const static int cnk_mask = 2;
196 while (
mask_nele == 0 && chunk_id < header_inf->size())
202 for (
size_t i = 0 ; i < dim ; i++)
238 const size_t (&
sz_cnk)[dim])
242 for (
size_t i = 0 ; i < dim ; i++)
244 this->sz_cnk[i] =
sz_cnk[i];
272 for (
size_t i = 0 ; i < dim ; i++)
290 if (chunk_id < header_inf->size())
310 for (
size_t i = 0 ; i < dim ; i++)
424template<
unsigned dim,
unsigned int n_ele>
457 while (
mask_nele == 0 && chunk_id < header_inf->size())
498 if (chunk_id < header_inf->size())
567 for (
size_t i = 0 ; i < dim ; i++)
This class represent an N-dimensional box.
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the box
__device__ __host__ bool Intersect(const Box< dim, T > &b, Box< dim, T > &b_out) const
Intersect.
__device__ __host__ T getHigh(int i) const
get the high interval of the box
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
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.
__device__ __host__ index_type get(index_type i) const
Get the i index.
Grid key sparse iterator on a sub-part of the domain.
const grid_key_dx< dim > & getStop() const
Return the stop point for the iteration.
const grid_key_dx< dim > & getStart() const
Return the starting point for the iteration.
size_t private_get_mask_it_pnt() const
Return the private member mask_it_pnt.
grid_key_sparse_dx_iterator_sub()
Default constructor.
size_t chunk_id
point to the actual chunk
Box< dim, size_t > bx
Sub-grid box.
const openfpm::vector< mheader< n_ele > > * header_mask
It store the information of each chunk mask.
const grid_key_dx< dim >(* private_get_lin_id_pos() const)[n_ele]
Return the private member lin_id_pos.
const grid_key_dx< dim >(* lin_id_pos)[n_ele]
linearized id to position in coordinates conversion
const short unsigned int(& private_get_mask_it() const)[n_ele]
Return the private member mask_it.
size_t private_get_mask_nele() const
Return the private member mask_nele.
size_t mask_it_pnt
Actual point in mask it.
grid_key_dx< dim > start
Starting point.
const openfpm::vector< cheader< dim > > * private_get_header_inf() const
Return the private member header.
const openfpm::vector< cheader< dim > > * header_inf
it store the information of each chunk
grid_key_sparse_lin_dx getKeyF()
Return the actual point linearized.
size_t mask_nele
Number of points in mask_it.
bool isNext()
Return true if there is a next grid point.
const openfpm::vector< mheader< n_ele > > * private_get_header_mask() const
Return the private member header.
size_t private_get_chunk_id() const
Return the private member chunk_id.
grid_key_dx< dim > get() const
Return the position of the actual point in coordinates.
void reinitialize(const grid_key_sparse_dx_iterator_sub< dim, n_ele > &g_s_it)
Reinitialize the iterator.
void SelectValidAndFill_mask_it()
Everytime we move to a new chunk we calculate on which indexes we have to iterate.
size_t sz_cnk[dim]
Chunk size.
short unsigned int mask_it[n_ele]
set of index in the chunk on which we have to iterate
grid_key_dx< dim > stop
Stop point.
Grid key sparse iterator.
grid_key_sparse_lin_dx getKeyF()
Return the actual point.
const grid_key_dx< dim >(* lin_id_pos)[n_ele]
linearized id to position in coordinates conversion
bool isNext()
Return true if there is a next grid point.
const openfpm::vector< mheader< n_ele > > * header_mask
It store the information of each chunk.
size_t mask_it_pnt
Actual point in mask it.
grid_key_sparse_dx_iterator()
Default constructor.
size_t chunk_id
point to the actual chunk
grid_key_dx< dim > get() const
Return the position of the actual point in coordinates.
void SelectValidAndFill_mask_it()
Everytime we move to a new chunk we calculate on which indexes we have to iterate.
void reinitialize(const grid_key_sparse_dx_iterator_sub< dim, n_ele > &g_s_it)
Reinitialize the iterator.
int mask_nele
Number of points in mask_it.
short unsigned int mask_it[n_ele]
set of index in the chunk on which we have to iterate
const openfpm::vector< cheader< dim > > * header_inf
It store the information of each chunk.
void reinitialize(const grid_key_sparse_dx_iterator< dim, n_ele > &g_s_it)
Reinitialize the iterator.
It store the position in space of the sparse grid.
size_t getPos() const
Return the linearized position in the chunk.
size_t lin_id
linearized id
size_t getChunk() const
Return the chunk id.
Implementation of 1-D std::vector like structure.