OpenFPM_pdata
1.1.0
Project that contain the implementation of distributed structures
All
Data Structures
Namespaces
Functions
Variables
Typedefs
Enumerations
Friends
Pages
CellListIterator.hpp
1
2
/*
3
* CellListIt.hpp
4
*
5
* Created on: May 18, 2016
6
* Author: Yaroslav Zaluzhnyi
7
*/
8
9
#ifndef OPENFPM_DATA_SRC_NN_CELLLIST_CELLLISTITERATOR_HPP_
10
#define OPENFPM_DATA_SRC_NN_CELLLIST_CELLLISTITERATOR_HPP_
11
12
template
<
typename
T>
13
class
ParticleIt_CellP
14
{
15
private
:
16
18
T &
NN
;
19
21
size_t
cell_count
;
22
24
size_t
p_count
;
25
26
30
inline
void
fp
()
31
{
32
++
p_count
;
33
34
const
auto
& SFCkeys =
NN
.getCellSFC().getKeys();
35
36
if
(
p_count
>=
NN
.getNelements(SFCkeys.get(
cell_count
)))
37
{
38
p_count
= 0;
39
++
cell_count
;
40
41
while
(
cell_count
< SFCkeys.size() &&
NN
.getNelements(SFCkeys.get(
cell_count
)) == 0)
42
++
cell_count
;
43
}
44
}
45
46
public
:
47
48
// Constructor
49
ParticleIt_CellP
(T &
NN
)
50
:NN(NN)
51
{
52
reset
();
53
}
54
55
// Destructor
56
~
ParticleIt_CellP
()
57
{
58
}
59
60
61
67
inline
ParticleIt_CellP
&
operator++
()
68
{
69
fp
();
70
while
(
isNext
() && this->
get
() >=
NN
.get_gm())
71
{
72
fp
();
73
}
74
75
return
*
this
;
76
}
77
78
84
inline
bool
isNext
()
85
{
86
if
(
cell_count
>=
NN
.getCellSFC().getKeys().size())
87
{
88
return
false
;
89
}
90
91
return
true
;
92
}
93
94
101
inline
size_t
get
()
102
{
103
auto
cell_id =
NN
.getCellSFC().getKeys().get(
cell_count
);
104
auto
p =
NN
.get(cell_id,
p_count
);
105
106
return
p;
107
}
108
112
void
reset
()
113
{
114
cell_count
= 0;
115
p_count
= -1;
116
117
this->
operator++
();
118
}
119
};
120
121
122
#endif
/* OPENFPM_DATA_SRC_NN_CELLLIST_CELLLISTITERATOR_HPP_ */
ParticleIt_CellP
Definition:
CellListIterator.hpp:13
ParticleIt_CellP::cell_count
size_t cell_count
Cells counter.
Definition:
CellListIterator.hpp:21
ParticleIt_CellP::NN
T & NN
Cell lisy.
Definition:
CellListIterator.hpp:18
ParticleIt_CellP::fp
void fp()
Handles incrementing of cells and particles counters.
Definition:
CellListIterator.hpp:30
ParticleIt_CellP::isNext
bool isNext()
Checks if there is a next element.
Definition:
CellListIterator.hpp:84
ParticleIt_CellP::reset
void reset()
Reset an iterator (set the counters to the first valid ones)
Definition:
CellListIterator.hpp:112
ParticleIt_CellP::p_count
size_t p_count
Particles counter.
Definition:
CellListIterator.hpp:24
ParticleIt_CellP::operator++
ParticleIt_CellP & operator++()
Get the next element.
Definition:
CellListIterator.hpp:67
openfpm_data
src
NN
CellList
CellListIterator.hpp
Generated by
1.8.6