OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
CellNNIteratorRuntimeM.hpp
1/*
2 * CellNNIteratorRuntimeM.hpp
3 *
4 * Created on: Jan 26, 2017
5 * Author: i-bird
6 */
7
8#ifndef OPENFPM_DATA_SRC_NN_CELLLIST_CELLNNITERATORRUNTIMEM_HPP_
9#define OPENFPM_DATA_SRC_NN_CELLLIST_CELLNNITERATORRUNTIMEM_HPP_
10
11
25template<unsigned int dim, typename Cell, unsigned int sh_byte, unsigned int impl>
26class CellNNIteratorM<dim,Cell,sh_byte,RUNTIME,impl> : public CellNNIterator<dim,Cell,RUNTIME,impl>
27{
28 typedef boost::low_bits_mask_t<sizeof(size_t)*8-sh_byte> mask_low;
29
30public:
31
41 CellNNIteratorM(size_t cell, const long int * NNc, size_t NNc_size, Cell & cl)
42 :CellNNIterator<dim,Cell,RUNTIME,impl>(cell,NNc,NNc_size,cl)
43 {}
44
45
51 inline size_t getP()
52 {
53 return CellNNIterator<dim,Cell,RUNTIME,impl>::get() & mask_low::sig_bits_fast;
54 }
55
61 inline size_t getV()
62 {
64 }
65};
66
67
84template<unsigned int dim, typename Cell, unsigned int sh_byte, unsigned int impl>
85class CellNNIteratorSymM<dim,Cell,sh_byte,RUNTIME,impl> : public CellNNIterator<dim,Cell,RUNTIME,impl>
86{
87 typedef boost::low_bits_mask_t<sizeof(size_t)*8-sh_byte> mask_low;
88
90 size_t pp;
91
93 size_t p;
94
95 const typename Cell::internal_vector_pos_type & pos;
96
99
103 inline void selectValid()
104 {
105 if (this->NNc[this->NNc_id] == 0)
106 {
107 while (this->start_id < this->stop_id)
108 {
109 size_t q = this->cl.get_lin(this->start_id);
110 for (long int i = dim-1 ; i >= 0 ; i--)
111 {
112 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])
113 return;
114 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])
115 goto next;
116 }
117 if (q >> (sizeof(size_t)*8-sh_byte) != pp) return;
118 if ((q & mask_low::sig_bits_fast) >= p) return;
119next:
120 this->start_id++;
121 }
122
124 }
125 else
126 {
128 }
129 }
130
131public:
132
143 size_t pp,
144 size_t p,
145 const long int * NNc,
146 size_t NNc_size,
147 Cell & cl,
148 const typename Cell::internal_vector_pos_type & pos,
150 :CellNNIterator<dim,Cell,RUNTIME,impl>(cell,NNc,NNc_size,cl),pp(pp),p(p),pos(pos),ps(ps)
151 {}
152
153
159 inline size_t getP()
160 {
161 return CellNNIterator<dim,Cell,RUNTIME,impl>::get() & mask_low::sig_bits_fast;
162 }
163
169 inline size_t getV()
170 {
172 }
173
180 {
181 this->start_id++;
182
183 selectValid();
184
185 return *this;
186 }
187};
188
189
190#endif /* OPENFPM_DATA_SRC_NN_CELLLIST_CELLNNITERATORRUNTIMEM_HPP_ */
CellNNIteratorM(size_t cell, const long int *NNc, size_t NNc_size, Cell &cl)
Cell NN iterator.
Iterator for the neighborhood of the cell structures.
size_t getV()
Get the value of the cell.
CellNNIteratorSymM< dim, Cell, sh_byte, RUNTIME, impl > & operator++()
take the next element
const openfpm::vector< pos_v< typename Cell::internal_vector_pos_type > > & ps
Position of the particles in the phases.
CellNNIteratorSymM(size_t cell, size_t pp, size_t p, const long int *NNc, size_t NNc_size, Cell &cl, const typename Cell::internal_vector_pos_type &pos, const openfpm::vector< pos_v< typename Cell::internal_vector_pos_type > > &ps)
Cell NN iterator.
Iterator for the neighborhood of the cell structures.
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.
size_t p
index of the particle p
size_t pp
phase of particle p
size_t getV()
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.