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_ */
pos_v
Structure that contain a reference to a vector of particles.
Definition: CellList_util.hpp:20
CellNNIteratorSymM
Iterator for the neighborhood of the cell structures.
Definition: CellNNIteratorM.hpp:30
CellNNIteratorSymM< dim, Cell, sh_byte, RUNTIME >::getV
size_t getV()
Get the value of the cell.
Definition: CellNNIteratorRuntimeM.hpp:167
CellNNIterator::cell
const long int cell
Center cell, or cell for witch we are searching the NN-cell.
Definition: CellNNIterator.hpp:47
CellNNIteratorM
Iterator for the neighborhood of the cell structures.
Definition: CellNNIteratorM.hpp:147
CellNNIteratorSymM< dim, Cell, sh_byte, RUNTIME >::ps
const openfpm::vector< pos_v< typename Cell::internal_vector_pos_type > > & ps
Position of the particles in the phases.
Definition: CellNNIteratorRuntimeM.hpp:96
CellNNIterator::stop_id
const Cell::Mem_type_type::local_index_type * stop_id
stop id to read the end of the cell
Definition: CellNNIterator.hpp:41
CellNNIteratorSymM< dim, Cell, sh_byte, RUNTIME >::selectValid
void selectValid()
Definition: CellNNIteratorRuntimeM.hpp:101
CellNNIteratorSymM::pp
size_t pp
phase of particle p
Definition: CellNNIteratorM.hpp:35
CellNNIteratorSymM< dim, Cell, sh_byte, RUNTIME >
Symmetric iterator for the neighborhood of the cell structures.
Definition: CellNNIteratorRuntimeM.hpp:83
CellNNIteratorSymM< dim, Cell, sh_byte, RUNTIME >::CellNNIteratorSymM
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.
Definition: CellNNIteratorRuntimeM.hpp:140
CellNNIteratorSymM::p
size_t p
index of the particle p
Definition: CellNNIteratorM.hpp:38
CellNNIterator::NNc
const NNc_array< dim, NNc_size > & NNc
NN cell id.
Definition: CellNNIterator.hpp:56
CellNNIteratorSymM< dim, Cell, sh_byte, RUNTIME >::pp
size_t pp
phase of the particle p
Definition: CellNNIteratorRuntimeM.hpp:88
CellNNIteratorM< dim, Cell, sh_byte, RUNTIME >::getV
size_t getV()
Get the value of the cell.
Definition: CellNNIteratorRuntimeM.hpp:60
openfpm::vector
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:203
CellNNIterator
Iterator for the neighborhood of the cell structures.
Definition: CellNNIterator.hpp:33
CellNNIteratorSymM< dim, Cell, sh_byte, RUNTIME >::operator++
CellNNIteratorSymM< dim, Cell, sh_byte, RUNTIME > & operator++()
take the next element
Definition: CellNNIteratorRuntimeM.hpp:177
CellNNIterator::start_id
const Cell::Mem_type_type::local_index_type * start_id
actual element id
Definition: CellNNIterator.hpp:38
CellNNIterator::NNc_id
size_t NNc_id
Actual NNc_id;.
Definition: CellNNIterator.hpp:44
CellNNIterator::cl
Cell & cl
Cell list.
Definition: CellNNIterator.hpp:53
CellNNIteratorSymM< dim, Cell, sh_byte, RUNTIME >::p
size_t p
index of the particle p
Definition: CellNNIteratorRuntimeM.hpp:91
CellNNIteratorM< dim, Cell, sh_byte, RUNTIME >::getP
size_t getP()
Get the value of the cell.
Definition: CellNNIteratorRuntimeM.hpp:50
CellNNIteratorSymM::pos
const Cell::internal_vector_pos_type & pos
Position of the particles p.
Definition: CellNNIteratorM.hpp:41
CellNNIteratorSymM::ps
const openfpm::vector< pos_v< typename Cell::internal_vector_pos_type > > & ps
Position of the particle p.
Definition: CellNNIteratorM.hpp:44
CellNNIteratorSymM< dim, Cell, sh_byte, RUNTIME >::getP
size_t getP()
Get the value of the cell.
Definition: CellNNIteratorRuntimeM.hpp:157
CellNNIteratorSymM::selectValid
void selectValid()
Definition: CellNNIteratorM.hpp:49
CellNNIteratorM< dim, Cell, sh_byte, RUNTIME >::CellNNIteratorM
CellNNIteratorM(size_t cell, const long int *NNc, size_t NNc_size, Cell &cl)
Cell NN iterator.
Definition: CellNNIteratorRuntimeM.hpp:40