OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
ParticleItCRS_Cells.hpp
1/*
2 * CellListIterator_CRS.hpp
3 *
4 * Created on: Nov 14, 2016
5 * Author: i-bird
6 */
7
8#ifndef OPENFPM_DATA_SRC_NN_CELLLIST_PARTICLEITCRS_CELLS_HPP_
9#define OPENFPM_DATA_SRC_NN_CELLLIST_PARTICLEITCRS_CELLS_HPP_
10
11#include "CellNNIterator.hpp"
12#include "CellList_util.hpp"
13#include "NN/CellList/NNc_array.hpp"
14
20template<unsigned int dim>
21struct subsub
22{
25
28};
29
35template<unsigned int dim>
37{
39 size_t subsub;
40
43};
44
52template<unsigned int dim,typename CellListType, typename vector_pos_type> class ParticleItCRS_Cells
53{
54private:
55
57 const typename CellListType::Mem_type_type::loc_index * start;
58
60 const typename CellListType::Mem_type_type::loc_index * stop;
61
63 size_t cid;
64
66 const long int * NNc;
67
69 long int NNc_size;
70
74
77
80
82 //
83 // * * *
84 // x *
85 //
86 const NNc_array<dim,openfpm::math::pow(3,dim)/2+1> & NNc_sym;
87
89 CellListType & cli;
90
96 {
97 while (start == stop)
98 {
99 cid++;
100
101 size_t s_cell;
102 if (dom_or_anom == 0)
103 {
104 if (cid >= dom_cell.size())
105 {
106 dom_or_anom = 1;
107 cid = 0;
108
109 // Terminate if we do not have anom cell
110 if (anom_dom_cell.size() == 0)
111 {
112 dom_or_anom = 2;
113 return;
114 }
115
116 s_cell = anom_dom_cell.get(cid).subsub;
117 }
118 else
119 s_cell = dom_cell.get(cid);
120 }
121 else
122 {
123 if (cid >= anom_dom_cell.size())
124 {
125 dom_or_anom = 2;
126 return;
127 }
128
129 s_cell = anom_dom_cell.get(cid).subsub;
130 }
131
132 // Get the starting particle
133 start = &cli.getStartId(s_cell);
134
135 // Get the stop particle
136 stop = &cli.getStopId(s_cell);
137 }
138 }
139
140public:
141
151 ParticleItCRS_Cells(CellListType & cli,
154 const NNc_array<dim,openfpm::math::pow(3,dim)/2+1> & NNc_sym)
156 {
157 size_t s_cell;
158 if (dom_cell.size() != 0)
159 s_cell = dom_cell.get(0);
160 else if (anom_dom_cell.size() != 0)
161 {
162 s_cell = anom_dom_cell.get(0).subsub;
163 dom_or_anom = 1;
164 }
165 else
166 {
167 dom_or_anom = 2;
168
169 start = NULL;
170 stop = NULL;
171
172 return;
173 }
174
175 // Get the starting particle
176 start = &cli.getStartId(s_cell);
177
178 // Get the stop particle
179 stop = &cli.getStopId(s_cell);
180
181 selectValid();
182 }
183
190 {
191 ++start;
192
193 selectValid();
194
195 return *this;
196 }
197
203 bool isNext()
204 {
205 return dom_or_anom != 2;
206 }
207
213 size_t get()
214 {
215 return *start;
216 }
217
218
234 typename CellListType::SymNNIterator getNNIteratorCSR(const vector_pos_type & v) const
235 {
236 if (dom_or_anom == 0)
237 {return typename CellListType::SymNNIterator(dom_cell.get(cid),*start,NNc_sym.getPointer(),openfpm::math::pow(3,dim)/2+1,cli,v);}
238 else
239 {return typename CellListType::SymNNIterator(anom_dom_cell.get(cid).subsub,
240 *start,
241 &anom_dom_cell.get(cid).NN_subsub.get(0),
242 anom_dom_cell.get(cid).NN_subsub.size(),
243 cli,
244 v);}
245 }
246
262 typename CellListType::SymNNIterator getNNIteratorCSRM(const vector_pos_type & pos ,
264 {
265 if (dom_or_anom == 0)
266 return typename CellListType::SymNNIterator(dom_cell.get(cid),CellListType::getV(*start),CellListType::getP(*start),NNc_sym.getPointer(),openfpm::math::pow(3,dim)/2+1,cli,pos,v);
267 else
268 return typename CellListType::SymNNIterator(anom_dom_cell.get(cid).subsub,CellListType::getV(*start),CellListType::getP(*start),&anom_dom_cell.get(cid).NN_subsub.get(0),anom_dom_cell.get(cid).NN_subsub.size(),cli,pos,v);
269 }
270};
271
272
273#endif /* OPENFPM_DATA_SRC_NN_CELLLIST_PARTICLEITCRS_CELLS_HPP_ */
const long int * getPointer() const
return the pointer to the array
This iterator iterate across the particles of a Cell-list following the Cell structure.
CellListType::SymNNIterator getNNIteratorCSRM(const vector_pos_type &pos, const openfpm::vector< pos_v< vector_pos_type > > &v) const
Get the neighborhood iterator according to the CRS scheme Multi-phase case.
void selectValid()
Adjust the counters to reach a valid particle element.
const openfpm::vector< size_t > & dom_cell
List of all the domain cells.
const CellListType::Mem_type_type::loc_index * start
starting position
CellListType::SymNNIterator getNNIteratorCSR(const vector_pos_type &v) const
Get the neighborhood iterator according to the CRS scheme.
bool isNext()
Return true if there is the next particle.
CellListType & cli
Celllist type.
const openfpm::vector< subsub_lin< dim > > & anom_dom_cell
List of all anomalous domain cells with neighborhood.
const CellListType::Mem_type_type::loc_index * stop
stop position
ParticleItCRS_Cells(CellListType &cli, const openfpm::vector< size_t > &dom_cell, const openfpm::vector< subsub_lin< dim > > &anom_dom_cell, const NNc_array< dim, openfpm::math::pow(3, dim)/2+1 > &NNc_sym)
Initialize the iterator.
const NNc_array< dim, openfpm::math::pow(3, dim)/2+1 > & NNc_sym
The array contain the neighborhood of the cell-id in case of symmetric interaction.
ParticleItCRS_Cells & operator++()
Increment to the next particle.
const long int * NNc
Neighborhood.
long int NNc_size
Neighborhood size.
size_t get()
Get the actual particle id.
grid_key_dx is the key to access any element in the grid
Definition grid_key.hpp:19
Implementation of 1-D std::vector like structure.
size_t size()
Stub size.
Structure that contain a reference to a vector of particles.
Linearized version of subsub.
openfpm::vector< long int > NN_subsub
Neighborhood of each sub-sub-domains (indicate the relative position compared to subsub)
size_t subsub
sub-sub-domain
sub-sub-domain
grid_key_dx< dim > subsub
sub-sub-domain
openfpm::vector< grid_key_dx< dim > > NN_subsub
Neighborhood of each sub-sub-domains.