OpenFPM  5.2.0
Project that contain the implementation of distributed structures
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 
24 template<unsigned int dim, typename Cell, unsigned int sh_byte>
25 class CellNNIteratorM<dim,Cell,sh_byte,RUNTIME> : public CellNNIterator<dim,Cell,RUNTIME>
26 {
27  typedef boost::low_bits_mask_t<sizeof(size_t)*8-sh_byte> mask_low;
28 
29 public:
30 
40  CellNNIteratorM(size_t cell, const long int * NNc, size_t NNc_size, Cell & cl)
41  :CellNNIterator<dim,Cell,RUNTIME>(cell,NNc,NNc_size,cl)
42  {}
43 
44 
50  inline size_t getP()
51  {
52  return CellNNIterator<dim,Cell,RUNTIME>::get() & mask_low::sig_bits_fast;
53  }
54 
60  inline size_t getV()
61  {
62  return (CellNNIterator<dim,Cell,RUNTIME>::get()) >> (sizeof(size_t)*8-sh_byte);
63  }
64 };
65 
66 
82 template<unsigned int dim, typename Cell, unsigned int sh_byte>
83 class CellNNIteratorSymM<dim,Cell,sh_byte,RUNTIME> : public CellNNIterator<dim,Cell,RUNTIME>
84 {
85  typedef boost::low_bits_mask_t<sizeof(size_t)*8-sh_byte> mask_low;
86 
88  size_t pp;
89 
91  size_t p;
92 
93  const typename Cell::internal_vector_pos_type & pos;
94 
97 
101  inline void selectValid()
102  {
103  if (this->NNc[this->NNc_id] == 0)
104  {
105  while (this->start_id < this->stop_id)
106  {
107  size_t q = this->cl.get_lin(this->start_id);
108  for (long int i = dim-1 ; i >= 0 ; i--)
109  {
110  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])
111  return;
112  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])
113  goto next;
114  }
115  if (q >> (sizeof(size_t)*8-sh_byte) != pp) return;
116  if ((q & mask_low::sig_bits_fast) >= p) return;
117 next:
118  this->start_id++;
119  }
120 
122  }
123  else
124  {
126  }
127  }
128 
129 public:
130 
141  size_t pp,
142  size_t p,
143  const long int * NNc,
144  size_t NNc_size,
145  Cell & cl,
146  const typename Cell::internal_vector_pos_type & pos,
148  :CellNNIterator<dim,Cell,RUNTIME>(cell,NNc,NNc_size,cl),pp(pp),p(p),pos(pos),ps(ps)
149  {}
150 
151 
157  inline size_t getP()
158  {
159  return CellNNIterator<dim,Cell,RUNTIME>::get() & mask_low::sig_bits_fast;
160  }
161 
167  inline size_t getV()
168  {
169  return (CellNNIterator<dim,Cell,RUNTIME>::get()) >> (sizeof(size_t)*8-sh_byte);
170  }
171 
178  {
179  this->start_id++;
180 
181  selectValid();
182 
183  return *this;
184  }
185 };
186 
187 
188 #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.
Symmetric iterator for the neighborhood of the cell structures.
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.
CellNNIteratorSymM< dim, Cell, sh_byte, RUNTIME > & operator++()
take the next element
Iterator for the neighborhood of the cell structures.
const Cell::internal_vector_pos_type & pos
Position of the particles p.
size_t p
index of the particle p
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.