OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
ParticleIt_Cells.hpp
1/*
2 * ParticleIt_Cells.hpp
3 *
4 * Created on: Mar 5, 2017
5 * Author: i-bird
6 */
7
8#ifndef OPENFPM_DATA_SRC_NN_CELLLIST_PARTICLEIT_CELLS_HPP_
9#define OPENFPM_DATA_SRC_NN_CELLLIST_PARTICLEIT_CELLS_HPP_
10
18template<unsigned int dim,typename CellListType> class ParticleIt_Cells
19{
20private:
21
23 const size_t * start;
24
26 const size_t * stop;
27
29 size_t cid;
30
33
35 CellListType & cli;
36
38 size_t g_m;
39
45 {
46 while (start == stop)
47 {
48 cid++;
49
50 size_t s_cell;
51 if (cid >= dom_cell.size())
52 return;
53 else
54 s_cell = dom_cell.get(cid);
55
56 // Get the starting particle
57 start = &cli.getStartId(s_cell);
58
59 // Get the stop particle
60 stop = &cli.getStopId(s_cell);
61 }
62 }
63
64public:
65
73 ParticleIt_Cells(CellListType & cli,
75 size_t g_m)
77 {
78 size_t s_cell;
79 if (dom_cell.size() != 0)
80 s_cell = dom_cell.get(0);
81 else
82 {
83 cid = 1;
84 start = NULL;
85 stop = NULL;
86
87 return;
88 }
89
90 // Get the starting particle
91 start = &cli.getStartId(s_cell);
92
93 // Get the stop particle
94 stop = &cli.getStopId(s_cell);
95
97
98 while (*start >= g_m)
99 {
100 ++start;
101 selectValid();
102 }
103 }
104
111 {
112 ++start;
113 selectValid();
114
115 while (*start >= g_m)
116 {
117 ++start;
118 selectValid();
119 }
120
121 return *this;
122 }
123
129 bool isNext()
130 {
131 return cid < dom_cell.size();
132 }
133
139 size_t get()
140 {
141 return *start;
142 }
143};
144
145
146#endif /* OPENFPM_DATA_SRC_NN_CELLLIST_PARTICLEIT_CELLS_HPP_ */
This iterator iterate across the particles of a Cell-list following the Cell structure.
bool isNext()
Return true if there is the next particle.
const size_t * stop
stop position
CellListType & cli
Celllist type.
size_t get()
Get the actual particle id.
void selectValid()
Adjust the counters to reach a valid particle element.
ParticleIt_Cells(CellListType &cli, const openfpm::vector< size_t > &dom_cell, size_t g_m)
Initialize the iterator.
size_t g_m
Ghost marker.
ParticleIt_Cells & operator++()
Increment to the next particle.
const size_t * start
starting position
const openfpm::vector< size_t > & dom_cell
List of all the domain cells.
size_t cid
Actual cell.
Implementation of 1-D std::vector like structure.
size_t size()
Stub size.