OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
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 
25 template<unsigned int dim, typename Cell, unsigned int sh_byte, unsigned int impl>
26 class 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 
30 public:
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  {
63  return (CellNNIterator<dim,Cell,RUNTIME,impl>::get()) >> (sizeof(size_t)*8-sh_byte);
64  }
65 };
66 
67 
84 template<unsigned int dim, typename Cell, unsigned int sh_byte, unsigned int impl>
85 class 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 
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;
119 next:
120  this->start_id++;
121  }
122 
124  }
125  else
126  {
128  }
129  }
130 
131 public:
132 
143  size_t pp,
144  size_t p,
145  const long int * NNc,
146  size_t NNc_size,
147  Cell & cl,
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  {
171  return (CellNNIterator<dim,Cell,RUNTIME,impl>::get()) >> (sizeof(size_t)*8-sh_byte);
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_ */
CellNNIteratorSymM< dim, Cell, sh_byte, RUNTIME, impl > & operator++()
take the next element
const long int cell
Center cell, or cell for witch we are searching the NN-cell.
Iterator for the neighborhood of the cell structures.
const openfpm::vector< pos_v< dim, typename Cell::stype > > & ps
Position of the particles in the phases.
const Cell::Mem_type_type::loc_index * stop_id
stop id to read the end of the cell
Iterator for the neighborhood of the cell structures.
const openfpm::vector< Point< dim, typename Cell::stype > > & pos
Position of the particles p.
const Cell::Mem_type_type::loc_index & get()
Get the value of the cell.
This class implement the point shape in an N-dimensional space.
Definition: Point.hpp:22
const openfpm::vector< pos_v< dim, typename Cell::stype > > & ps
Position of the particle p.
Structure that contain a reference to a vector of particles.
CellNNIteratorSymM(size_t cell, size_t pp, size_t p, const long int *NNc, size_t NNc_size, Cell &cl, const openfpm::vector< Point< dim, typename Cell::stype >> &pos, const openfpm::vector< pos_v< dim, typename Cell::stype >> &ps)
Cell NN iterator.
size_t p
index of the particle p
const NNc_array< dim, NNc_size > & NNc
NN cell id.
Symmetric iterator for the neighborhood of the cell structures.
size_t pp
phase of particle p
size_t NNc_id
Actual NNc_id;.
const Cell::Mem_type_type::loc_index * start_id
actual element id
void selectValid()
Select non-empty cell.
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:61
Iterator for the neighborhood of the cell structures.
Cell & cl
Cell list.
CellNNIteratorM(size_t cell, const long int *NNc, size_t NNc_size, Cell &cl)
Cell NN iterator.