OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
CellListM.hpp
1 /*
2  * CellListM.hpp
3  *
4  * Created on: Jun 23, 2016
5  * Author: i-bird
6  */
7 
8 #ifndef OPENFPM_DATA_SRC_NN_CELLLIST_CELLLISTM_HPP_
9 #define OPENFPM_DATA_SRC_NN_CELLLIST_CELLLISTM_HPP_
10 
11 #include "CellNNIteratorM.hpp"
12 #include "CellList.hpp"
13 
14 struct PV_cl
15 {
17  size_t ele;
19  size_t v;
20 };
21 
52 template<unsigned int dim, typename T, unsigned int sh_byte, typename CellBase=CellList<dim,T,Mem_fast<>,shift<dim, T>> >
53 class CellListM : public CellBase
54 {
56  typedef boost::high_bit_mask_t<sh_byte> mask_high;
57 
59  typedef boost::low_bits_mask_t<sizeof(size_t)*8-sh_byte> mask_low;
60 
61 public:
62 
65 
68  {};
69 
76  {
77  this->operator=(cell);
78  }
79 
86  {
87  this->operator=(cell);
88  }
89 
90 
100  CellListM(Box<dim,T> & box, const size_t (&div)[dim], Matrix<dim,T> mat, const size_t pad = 1, size_t slot=STARTING_NSLOT)
101  :CellBase(box,div,mat,pad,slot)
102  {}
103 
112  CellListM(Box<dim,T> & box, const size_t (&div)[dim], const size_t pad = 1, size_t slot=STARTING_NSLOT)
113  :CellBase(box,div,pad,slot)
114  {}
115 
116 
122  {}
123 
131  inline void addCell(size_t cell_id, size_t ele, size_t v_id)
132  {
133  size_t ele_k = ele | (v_id << (sizeof(size_t)*8-sh_byte));
134 
135  CellBase::addCell(cell_id,ele_k);
136  }
137 
145  inline void add(const T (& pos)[dim], size_t ele, size_t v_id)
146  {
147  // calculate the Cell id
148 
149  size_t cell_id = this->getCell(pos);
150  size_t ele_k = ele | (v_id << (sizeof(size_t)*8-sh_byte));
151 
152  // add the element to the cell
153 
154  CellBase::addCell(cell_id,ele_k);
155  }
156 
164  inline void add(const Point<dim,T> & pos, size_t ele, size_t v_id)
165  {
166  // calculate the Cell id
167 
168  size_t cell_id = this->getCell(pos);
169  size_t ele_k = ele | (v_id << (sizeof(size_t)*8-sh_byte));
170 
171  // add the element to the cell
172 
173  CellBase::addCell(cell_id,ele_k);
174  }
175 
183  static inline size_t getP(size_t ele)
184  {
185  return ele & mask_low::sig_bits_fast;
186  }
187 
195  static inline size_t getV(size_t ele)
196  {
197  return ele >> (sizeof(size_t)*8-sh_byte);
198  }
199 
210  inline size_t getP(size_t cell, size_t ele)
211  {
212  return CellBase::get(cell,ele) & mask_low::sig_bits_fast;
213  }
214 
225  inline size_t getV(size_t cell, size_t ele)
226  {
227  return (CellBase::get(cell,ele)) >> (sizeof(size_t)*8-sh_byte);
228  }
229 
236  {
237  CellBase::swap(*this);
238  }
239 
248  {
249  return CellBase::getIterator(cell);
250  }
251 
272  template<unsigned int impl=NO_CHECK> inline CellNNIteratorM<dim,CellListM<dim,T,sh_byte,CellBase>,sh_byte,FULL,impl> getNNIterator(size_t cell)
273  {
275 
276  return cln;
277  }
278 
279 
299  template<unsigned int impl> inline CellNNIteratorSymM<dim,CellListM<dim,T,sh_byte,CellBase>,sh_byte,SYM,impl>
300  getNNIteratorSym(size_t cell,
301  size_t pp,
302  size_t p,
305  {
307 
308  return cln;
309  }
310 
311 
320  {
321  CellBase::swap(clm);
322 
323  return *this;
324  }
325 
334  {
335  static_cast<CellBase *>(this)->operator=(*static_cast<const CellBase *>(&clm));
336 
337  return *this;
338  }
339 };
340 
341 #endif /* OPENFPM_DATA_SRC_NN_CELLLIST_CELLLISTM_HPP_ */
CellListM(CellListM< dim, T, sh_byte, CellBase > &&cell)
Copy constructor.
Definition: CellListM.hpp:85
boost::high_bit_mask_t< sh_byte > mask_high
Mask to get the high bits of a number.
Definition: CellListM.hpp:56
CellListM(Box< dim, T > &box, const size_t(&div)[dim], Matrix< dim, T > mat, const size_t pad=1, size_t slot=STARTING_NSLOT)
Cell list constructor.
Definition: CellListM.hpp:100
Iterator for the neighborhood of the cell structures.
CellListM(const CellListM< dim, T, sh_byte, CellBase > &cell)
Copy constructor.
Definition: CellListM.hpp:75
CellIterator< CellListM< dim, T, sh_byte, CellBase > > getIterator(size_t cell)
Get the Cell iterator.
Definition: CellListM.hpp:247
CellListM(Box< dim, T > &box, const size_t(&div)[dim], const size_t pad=1, size_t slot=STARTING_NSLOT)
Cell list constructor.
Definition: CellListM.hpp:112
size_t getP(size_t cell, size_t ele)
Get the element-id in the cell.
Definition: CellListM.hpp:210
CellListM< dim, T, sh_byte, CellBase > & operator=(const CellListM< dim, T, sh_byte, CellBase > &clm)
operator=
Definition: CellListM.hpp:333
Iterator for the neighborhood of the cell structures.
static size_t getP(size_t ele)
Convert an element in particle id.
Definition: CellListM.hpp:183
boost::low_bits_mask_t< sizeof(size_t)*8-sh_byte > mask_low
Mask to get the low bits of a number.
Definition: CellListM.hpp:59
size_t ele
particle id
Definition: CellListM.hpp:17
~CellListM()
Destructor.
Definition: CellListM.hpp:121
This class implement the point shape in an N-dimensional space.
Definition: Point.hpp:22
Structure that contain a reference to a vector of particles.
CellNNIteratorM< dim, CellListM< dim, T, sh_byte, CellBase >, sh_byte, FULL, impl > getNNIterator(size_t cell)
Get the Neighborhood iterator.
Definition: CellListM.hpp:272
void add(const Point< dim, T > &pos, size_t ele, size_t v_id)
Add an element in the cell list.
Definition: CellListM.hpp:164
CellNNIteratorSymM< dim, CellListM< dim, T, sh_byte, CellBase >, sh_byte, RUNTIME, NO_CHECK > SymNNIterator
Type of the iterator for the neighborhood.
Definition: CellListM.hpp:64
void swap(CellListM< dim, T, sh_byte, CellBase > &cl)
Swap the memory.
Definition: CellListM.hpp:235
CellNNIteratorSymM< dim, CellListM< dim, T, sh_byte, CellBase >, sh_byte, SYM, impl > getNNIteratorSym(size_t cell, size_t pp, size_t p, const openfpm::vector< Point< dim, typename CellBase::stype >> &pos, const openfpm::vector< pos_v< dim, typename CellBase::stype >> &v)
Get the Neighborhood iterator.
Definition: CellListM.hpp:300
Class for Multi-Phase cell-list.
Definition: CellListM.hpp:53
This class implement an NxN (dense) matrix.
Definition: Matrix.hpp:32
CellListM< dim, T, sh_byte, CellBase > & operator=(CellListM< dim, T, sh_byte, CellBase > &&clm)
operator=
Definition: CellListM.hpp:319
it iterate through the elements of a cell
size_t v
phase id
Definition: CellListM.hpp:19
This class represent an N-dimensional box.
Definition: Box.hpp:56
CellListM()
Default Constructor.
Definition: CellListM.hpp:67
void add(const T(&pos)[dim], size_t ele, size_t v_id)
Add an element in the cell list.
Definition: CellListM.hpp:145
void addCell(size_t cell_id, size_t ele, size_t v_id)
Add to the cell.
Definition: CellListM.hpp:131
static size_t getV(size_t ele)
Convert an element in phase id.
Definition: CellListM.hpp:195
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:61
size_t getV(size_t cell, size_t ele)
Get the element vector in the cell.
Definition: CellListM.hpp:225