OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
grid_dist_amr_key_iterator.hpp
1/*
2 * grid_amr_dist_key_iterator.hpp
3 *
4 * Created on: Sep 22, 2017
5 * Author: i-bird
6 */
7
8#ifndef SRC_AMR_GRID_DIST_AMR_KEY_ITERATOR_HPP_
9#define SRC_AMR_GRID_DIST_AMR_KEY_ITERATOR_HPP_
10
11#include "Vector/map_vector.hpp"
12#include "Grid/Iterators/grid_dist_id_iterator.hpp"
13#include "grid_dist_amr_key.hpp"
14
15template<unsigned int dim, typename device_grid, typename device_sub_it, typename it_type = grid_dist_iterator<dim,device_grid,device_sub_it,FREE>>
17{
20
22 struct actual_it
23 {
24 it_type & it;
25 };
26
28 it_type * a_it;
29
31 size_t g_c;
32
33
34
39 {
40 // When the grid has size 0 potentially all the other informations are garbage
41 while (g_c < git.size() && git.get(g_c).isNext() == false ) g_c++;
42
43 // get the next grid iterator
44 if (g_c < git.size())
45 {
46 a_it = &git.get(g_c);
47 }
48 }
49
50public:
51
58 :git(git),g_c(0)
59 {
60 a_it = &git.get(0);
61
63 }
64
65
68 {
69 }
70
71
78 {
79 ++(*a_it);
80
81 // check if a_it is at the end
82
83 if (a_it->isNext() == true)
84 {return *this;}
85 else
86 {
87 // switch to the new iterator
88 g_c++;
89
91 }
92
93 return *this;
94 }
95
101 inline bool isNext()
102 {
103 return g_c < git.size();
104 }
105
111 {
112 return grid_dist_amr_key<dim>(g_c,a_it->get());
113 }
114
121 {
122 return git.get(g_c).getGKey(a_it->get());
123 }
124
129 inline size_t getLvl() const
130 {
131 return g_c;
132 }
133};
134
135
136#endif /* SRC_AMR_GRID_DIST_AMR_KEY_ITERATOR_HPP_ */
openfpm::vector< it_type > & git
Array of grid iterators.
grid_dist_amr_key_iterator< dim, device_grid, device_sub_it, it_type > & operator++()
Get the next element.
grid_key_dx< dim > getGKey()
Return the actual global grid position in the AMR struct in global coordinates.
grid_dist_amr_key_iterator(openfpm::vector< it_type > &git)
Constructor.
bool isNext()
Is there a next point.
size_t getLvl() const
Return the level at which we are.
void selectValidGrid()
from g_c increment g_c until you find a valid grid
grid_dist_amr_key< dim > get()
Return the actual AMR grid iterator point.
it_type * a_it
Actual distributed grid iterator.
Amr grid distributed key.
grid_key_dx is the key to access any element in the grid
Definition grid_key.hpp:19
__device__ __host__ index_type get(index_type i) const
Get the i index.
Definition grid_key.hpp:503
Implementation of 1-D std::vector like structure.