OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
CellNNIteratorM.hpp
1/*
2 * CellNNIteratorM.hpp
3 *
4 * Created on: Jun 23, 2016
5 * Author: i-bird
6 */
7
8#ifndef OPENFPM_DATA_SRC_NN_CELLLIST_CELLNNITERATORM_HPP_
9#define OPENFPM_DATA_SRC_NN_CELLLIST_CELLNNITERATORM_HPP_
10
11
12#include "util/mathutil.hpp"
13#include <boost/integer/integer_mask.hpp>
14#include "CellList_util.hpp"
15#include "CellNNIterator.hpp"
16
30template<unsigned int dim, typename Cell, unsigned int sh_byte, int NNc_size, unsigned int impl>
31class CellNNIteratorSymM : public CellNNIterator<dim,Cell,NNc_size,impl>
32{
33 typedef boost::low_bits_mask_t<sizeof(size_t)*8-sh_byte> mask_low;
34
36 size_t pp;
37
39 size_t p;
40
42 const typename Cell::internal_vector_pos_type & pos;
43
46
50 inline void selectValid()
51 {
52 if (this->NNc[this->NNc_id] == 0)
53 {
54 while (this->start_id < this->stop_id)
55 {
56 size_t q = this->cl.get_lin(this->start_id);
57 for (long int i = dim-1 ; i >= 0 ; i--)
58 {
59 if (pos.template get<0>(p)[i] < ps.get(q >> (sizeof(size_t)*8-sh_byte)).pos.template get<0>(q & mask_low::sig_bits_fast)[i])
60 return;
61 else if (pos.template get<0>(p)[i] > ps.get(q >> (sizeof(size_t)*8-sh_byte)).pos.template get<0>(q & mask_low::sig_bits_fast)[i])
62 goto next;
63 }
64 if (q >> (sizeof(size_t)*8-sh_byte) != pp) return;
65 if ((q & mask_low::sig_bits_fast) >= p) return;
66next:
67 this->start_id++;
68 }
69
71 }
72 else
73 {
75 }
76 }
77
78public:
79
90 size_t pp,
91 size_t p,
93 Cell & cl,
94 const typename Cell::internal_vector_pos_type & pos,
96 :CellNNIterator<dim,Cell,NNc_size,impl>(cell,NNc,cl),pp(pp),p(p),pos(pos),ps(ps)
97 {
99 }
100
101
107 inline size_t getP()
108 {
109 return CellNNIterator<dim,Cell,NNc_size,impl>::get() & mask_low::sig_bits_fast;
110 }
111
117 inline size_t getV()
118 {
120 }
121
128 {
129 this->start_id++;
130
131 selectValid();
132
133 return *this;
134 }
135};
136
149template<unsigned int dim, typename Cell, unsigned int sh_byte, int NNc_size, unsigned int impl> class CellNNIteratorM : public CellNNIterator<dim,Cell,NNc_size,impl>
150{
151 typedef boost::low_bits_mask_t<sizeof(size_t)*8-sh_byte> mask_low;
152
153public:
154
165 :CellNNIterator<dim,Cell,NNc_size,impl>(cell,NNc,cl)
166 {}
167
168
174 inline size_t getP()
175 {
176 return CellNNIterator<dim,Cell,NNc_size,impl>::get() & mask_low::sig_bits_fast;
177 }
178
184 inline size_t getV()
185 {
187 }
188};
189
197template<typename Cell, unsigned int sh_byte> class CellIteratorM : public CellIterator<Cell>
198{
199
200 typedef boost::low_bits_mask_t<sizeof(size_t)*8-sh_byte> mask_low;
201
202public:
203
210 CellIteratorM(const size_t cell, Cell & cl)
211 :CellIterator<Cell>(cell,cl)
212 {}
213
219 inline size_t getP()
220 {
221 return CellIterator<Cell>::get() & mask_low::sig_bits_fast;
222 }
223
229 inline size_t getV()
230 {
231 return (CellIterator<Cell>::get()) >> (sizeof(size_t)*8-sh_byte);
232 }
233};
234
235#include "CellNNIteratorRuntimeM.hpp"
236
237#endif /* OPENFPM_DATA_SRC_NN_CELLLIST_CELLNNITERATORM_HPP_ */
it iterate through the elements of a cell
size_t getP()
Get the value of the cell.
CellIteratorM(const size_t cell, Cell &cl)
Cell iterator.
size_t getV()
Get the value of the cell.
it iterate through the elements of a cell
Cell & cl
Cell list.
const long int cell
selected cell
Iterator for the neighborhood of the cell structures.
CellNNIteratorM(size_t cell, const NNc_array< dim, NNc_size > &NNc, Cell &cl)
Cell NN iterator.
size_t getP()
Get the value of the cell.
size_t getV()
Get the value of the cell.
Iterator for the neighborhood of the cell structures.
CellNNIteratorSymM< dim, Cell, sh_byte, NNc_size, impl > & operator++()
take the next element
const Cell::internal_vector_pos_type & pos
Position of the particles p.
const openfpm::vector< pos_v< typename Cell::internal_vector_pos_type > > & ps
Position of the particle p.
CellNNIteratorSymM(size_t cell, size_t pp, size_t p, const NNc_array< dim, NNc_size > &NNc, Cell &cl, const typename Cell::internal_vector_pos_type &pos, const typename openfpm::vector< pos_v< typename Cell::internal_vector_pos_type > > &ps)
Cell NN iterator.
size_t p
index of the particle p
size_t pp
phase of particle p
size_t getV()
Get the value of the cell.
size_t getP()
Get the value of the cell.
Iterator for the neighborhood of the cell structures.
Cell & cl
Cell list.
const Cell::Mem_type_type::local_index_type * start_id
actual element id
size_t NNc_id
Actual NNc_id;.
const long int cell
Center cell, or cell for witch we are searching the NN-cell.
const NNc_array< dim, NNc_size > & NNc
NN cell id.
const Cell::Mem_type_type::local_index_type * stop_id
stop id to read the end of the cell
Implementation of 1-D std::vector like structure.
Structure that contain a reference to a vector of particles.