OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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 "CellList.hpp"
12#include "CellNNIteratorM.hpp"
13
14struct PV_cl
15{
17 size_t v;
18};
19
50template<unsigned int dim, typename T, unsigned int sh_byte, typename CellBase=CellList<dim,T,Mem_fast<>,shift<dim, T>> >
51class CellListM : public CellBase
52{
54 typedef boost::high_bit_mask_t<sh_byte> mask_high;
55
57 typedef boost::low_bits_mask_t<sizeof(size_t)*8-sh_byte> mask_low;
58
59public:
60
63
66 {};
67
74 {
75 this->operator=(cell);
76 }
77
84 {
85 this->operator=(cell);
86 }
87
88
98 CellListM(Box<dim,T> & box, const size_t (&div)[dim], Matrix<dim,T> mat, const size_t pad = 1, size_t slot=STARTING_NSLOT)
99 :CellBase(box,div,mat,pad,slot)
100 {}
101
110 CellListM(Box<dim,T> & box, const size_t (&div)[dim], const size_t pad = 1, size_t slot=STARTING_NSLOT)
111 :CellBase(box,div,pad,slot)
112 {}
113
114
120 {}
121
129 inline void addCell(size_t cell_id, size_t ele, size_t v_id)
130 {
131 size_t ele_k = ele | (v_id << (sizeof(size_t)*8-sh_byte));
132
133 CellBase::addCell(cell_id,ele_k);
134 }
135
143 inline void add(const T (& pos)[dim], size_t ele, size_t v_id)
144 {
145 // calculate the Cell id
146
147 size_t cell_id = this->getCell(pos);
148 size_t ele_k = ele | (v_id << (sizeof(size_t)*8-sh_byte));
149
150 // add the element to the cell
151
152 CellBase::addCell(cell_id,ele_k);
153 }
154
162 inline void add(const Point<dim,T> & pos, size_t ele, size_t v_id)
163 {
164 // calculate the Cell id
165
166 size_t cell_id = this->getCell(pos);
167 size_t ele_k = ele | (v_id << (sizeof(size_t)*8-sh_byte));
168
169 // add the element to the cell
170
171 CellBase::addCell(cell_id,ele_k);
172 }
173
181 static inline size_t getP(size_t ele)
182 {
183 return ele & mask_low::sig_bits_fast;
184 }
185
193 static inline size_t getV(size_t ele)
194 {
195 return ele >> (sizeof(size_t)*8-sh_byte);
196 }
197
208 inline size_t getP(size_t cell, size_t ele)
209 {
210 return CellBase::get(cell,ele) & mask_low::sig_bits_fast;
211 }
212
223 inline size_t getV(size_t cell, size_t ele)
224 {
225 return (CellBase::get(cell,ele)) >> (sizeof(size_t)*8-sh_byte);
226 }
227
234 {
235 CellBase::swap(*this);
236 }
237
246 {
247 return CellBase::getIterator(cell);
248 }
249
270 template<unsigned int impl=NO_CHECK> inline CellNNIteratorM<dim,CellListM<dim,T,sh_byte,CellBase>,sh_byte,FULL,impl> getNNIterator(size_t cell)
271 {
273
274 return cln;
275 }
276
277
297 template<unsigned int impl> inline CellNNIteratorSymM<dim,CellListM<dim,T,sh_byte,CellBase>,sh_byte,SYM,impl>
298 getNNIteratorSym(size_t cell,
299 size_t pp,
300 size_t p,
301 const typename CellBase::internal_vector_pos_type & pos,
303 {
305
306 return cln;
307 }
308
309
318 {
319 CellBase::swap(clm);
320
321 return *this;
322 }
323
332 {
333 static_cast<CellBase *>(this)->operator=(*static_cast<const CellBase *>(&clm));
334
335 return *this;
336 }
337};
338
339#endif /* OPENFPM_DATA_SRC_NN_CELLLIST_CELLLISTM_HPP_ */
This class represent an N-dimensional box.
Definition Box.hpp:61
it iterate through the elements of a cell
Class for Multi-Phase cell-list.
Definition CellListM.hpp:52
CellNNIteratorSymM< dim, CellListM< dim, T, sh_byte, CellBase >, sh_byte, RUNTIME, NO_CHECK > SymNNIterator
Type of the iterator for the neighborhood.
Definition CellListM.hpp:62
void swap(CellListM< dim, T, sh_byte, CellBase > &cl)
Swap the memory.
~CellListM()
Destructor.
CellListM()
Default Constructor.
Definition CellListM.hpp:65
CellListM(Box< dim, T > &box, const size_t(&div)[dim], const size_t pad=1, size_t slot=STARTING_NSLOT)
Cell list constructor.
void add(const Point< dim, T > &pos, size_t ele, size_t v_id)
Add an element in the cell list.
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:98
CellNNIteratorM< dim, CellListM< dim, T, sh_byte, CellBase >, sh_byte, FULL, impl > getNNIterator(size_t cell)
Get the Neighborhood iterator.
CellListM(CellListM< dim, T, sh_byte, CellBase > &&cell)
Copy constructor.
Definition CellListM.hpp:83
static size_t getP(size_t ele)
Convert an element in particle id.
void add(const T(&pos)[dim], size_t ele, size_t v_id)
Add an element in the cell list.
static size_t getV(size_t ele)
Convert an element in phase id.
CellIterator< CellListM< dim, T, sh_byte, CellBase > > getIterator(size_t cell)
Get the Cell iterator.
void addCell(size_t cell_id, size_t ele, size_t v_id)
Add to the cell.
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:57
CellListM< dim, T, sh_byte, CellBase > & operator=(CellListM< dim, T, sh_byte, CellBase > &&clm)
operator=
CellListM(const CellListM< dim, T, sh_byte, CellBase > &cell)
Copy constructor.
Definition CellListM.hpp:73
size_t getP(size_t cell, size_t ele)
Get the element-id in the cell.
size_t getV(size_t cell, size_t ele)
Get the element vector in the cell.
boost::high_bit_mask_t< sh_byte > mask_high
Mask to get the high bits of a number.
Definition CellListM.hpp:54
CellListM< dim, T, sh_byte, CellBase > & operator=(const CellListM< dim, T, sh_byte, CellBase > &clm)
operator=
CellNNIteratorSymM< dim, CellListM< dim, T, sh_byte, CellBase >, sh_byte, SYM, impl > getNNIteratorSym(size_t cell, size_t pp, size_t p, const typename CellBase::internal_vector_pos_type &pos, const openfpm::vector< pos_v< typename CellBase::internal_vector_pos_type > > &v)
Get the Neighborhood iterator.
Iterator for the neighborhood of the cell structures.
Iterator for the neighborhood of the cell structures.
This class implement an NxN (dense) matrix.
Definition Matrix.hpp:33
This class implement the point shape in an N-dimensional space.
Definition Point.hpp:28
Implementation of 1-D std::vector like structure.
size_t v
phase id
Definition CellListM.hpp:17
Structure that contain a reference to a vector of particles.