OpenFPM  5.2.0
Project that contain the implementation of distributed structures
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 "NN/CellList/CellList_util.hpp"
15 #include "NN/CellList/CellNNIterator.hpp"
16 
29 template<unsigned int dim, typename Cell, unsigned int sh_byte, int NNc_size>
30 class CellNNIteratorSymM : public CellNNIterator<dim,Cell,NNc_size>
31 {
32  typedef boost::low_bits_mask_t<sizeof(size_t)*8-sh_byte> mask_low;
33 
35  size_t pp;
36 
38  size_t p;
39 
41  const typename Cell::internal_vector_pos_type & pos;
42 
45 
49  inline void selectValid()
50  {
51  if (this->NNc[this->NNc_id] == 0)
52  {
53  while (this->start_id < this->stop_id)
54  {
55  size_t q = this->cl.get_lin(this->start_id);
56  for (long int i = dim-1 ; i >= 0 ; i--)
57  {
58  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])
59  return;
60  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])
61  goto next;
62  }
63  if (q >> (sizeof(size_t)*8-sh_byte) != pp) return;
64  if ((q & mask_low::sig_bits_fast) >= p) return;
65 next:
66  this->start_id++;
67  }
68 
70  }
71  else
72  {
74  }
75  }
76 
77 public:
78 
89  size_t pp,
90  size_t p,
92  Cell & cl,
93  const typename Cell::internal_vector_pos_type & pos,
95  :CellNNIterator<dim,Cell,NNc_size>(cell,NNc,cl),pp(pp),p(p),pos(pos),ps(ps)
96  {
97  selectValid();
98  }
99 
100 
106  inline size_t getP()
107  {
108  return CellNNIterator<dim,Cell,NNc_size>::get() & mask_low::sig_bits_fast;
109  }
110 
116  inline size_t getV()
117  {
118  return (CellNNIterator<dim,Cell,NNc_size>::get()) >> (sizeof(size_t)*8-sh_byte);
119  }
120 
127  {
128  this->start_id++;
129 
130  selectValid();
131 
132  return *this;
133  }
134 };
135 
147 template<unsigned int dim, typename Cell, unsigned int sh_byte, int NNc_size> class CellNNIteratorM : public CellNNIterator<dim,Cell,NNc_size>
148 {
149  typedef boost::low_bits_mask_t<sizeof(size_t)*8-sh_byte> mask_low;
150 
151 public:
152 
163  :CellNNIterator<dim,Cell,NNc_size>(cell,NNc,cl)
164  {}
165 
166 
172  inline size_t getP()
173  {
174  return CellNNIterator<dim,Cell,NNc_size>::get() & mask_low::sig_bits_fast;
175  }
176 
182  inline size_t getV()
183  {
184  return (CellNNIterator<dim,Cell,NNc_size>::get()) >> (sizeof(size_t)*8-sh_byte);
185  }
186 };
187 
195 template<typename Cell, unsigned int sh_byte> class CellIteratorM : public CellIterator<Cell>
196 {
197 
198  typedef boost::low_bits_mask_t<sizeof(size_t)*8-sh_byte> mask_low;
199 
200 public:
201 
208  CellIteratorM(const size_t cell, Cell & cl)
209  :CellIterator<Cell>(cell,cl)
210  {}
211 
217  inline size_t getP()
218  {
219  return CellIterator<Cell>::get() & mask_low::sig_bits_fast;
220  }
221 
227  inline size_t getV()
228  {
229  return (CellIterator<Cell>::get()) >> (sizeof(size_t)*8-sh_byte);
230  }
231 };
232 
233 #include "NN/CellList/multiphase/CellNNIteratorRuntimeM.hpp"
234 
235 #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.
size_t getV()
Get the value of the cell.
size_t getP()
Get the value of the cell.
CellNNIteratorM(size_t cell, const NNc_array< dim, NNc_size > &NNc, Cell &cl)
Cell NN iterator.
Iterator for the neighborhood of the cell structures.
const Cell::internal_vector_pos_type & pos
Position of the particles p.
size_t getV()
Get the value of the cell.
size_t p
index of the particle p
size_t getP()
Get the value of the cell.
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.
CellNNIteratorSymM< dim, Cell, sh_byte, NNc_size > & operator++()
take the next element
size_t pp
phase of particle p
const openfpm::vector< pos_v< typename Cell::internal_vector_pos_type > > & ps
Position of the particle p.
Iterator for the neighborhood of the cell structures.
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
size_t NNc_id
Actual NNc_id;.
const Cell::Mem_type_type::local_index_type * start_id
actual element id
const long int cell
Center cell, or cell for witch we are searching the NN-cell.
Cell & cl
Cell list.
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:204
Structure that contain a reference to a vector of particles.