OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
PointIteratorSkin.hpp
1 /*
2  * PointIteratorSkin.hpp
3  *
4  * Created on: Jan 4, 2017
5  * Author: i-bird
6  */
7 
8 #ifndef OPENFPM_NUMERICS_SRC_DRAW_POINTITERATORSKIN_HPP_
9 #define OPENFPM_NUMERICS_SRC_DRAW_POINTITERATORSKIN_HPP_
10 
11 #include "Grid/Iterators/grid_dist_id_iterator_dec_skin.hpp"
12 
13 #define RETURN_A 1
14 #define RETURN_B 2
15 
53 template<unsigned int dim, typename T, typename Decomposition>
54 class PointIteratorSkin: protected grid_dist_id_iterator_dec_skin<Decomposition>
55 {
58 
61 
64 
66  T sp[dim];
67 
68  static Box<dim,long int> getAB(size_t (& gs)[dim], const Box<dim,T> & dom, const Box<dim,T> & sub_domA , const Box<dim,T> & sub_domB, T (& sp)[dim], size_t AB)
69  {
70  for (size_t i = 0 ; i < dim ; i++)
71  sp[i] = (dom.getHigh(i) - dom.getLow(i)) / (gs[i] -1);
72 
74 
75  for (size_t i = 0 ; i < dim ; i++)
76  {
77  size_t Ast = std::ceil( (sub_domA.getLow(i) - dom.getLow(i)) / sp[i] ) - 1;
78  size_t Asp = std::floor( (sub_domA.getHigh(i) - dom.getLow(i)) / sp[i] ) + 1;
79 
80  size_t Bst = std::ceil( (sub_domB.getLow(i) - dom.getLow(i)) / sp[i] );
81  size_t Bsp = std::floor( (sub_domB.getHigh(i) - dom.getLow(i)) / sp[i] );
82 
83  // grid_dist_id_iterator_dec_skin only work if A is contained into B
84  Ast = (Ast < Bst)?Bst:Ast;
85  Asp = (Asp > Bsp)?Bsp:Asp;
86 
87  if (AB == RETURN_A)
88  {
89  box.setLow(i,Ast);
90  box.setHigh(i,Asp);
91  }
92  else
93  {
94  box.setLow(i,Bst);
95  box.setHigh(i,Bsp);
96  }
97  }
98 
99  return box;
100  }
101 
102  void calculateAp()
103  {
105  return;
106 
108 
109  for (size_t i = 0 ; i < dim ; i++)
110  ap.get(i) = key.get(i) * sp[i] + domain.getLow(i);
111  }
112 
113 
120  {
121  bool valid = true;
122 
123  for (size_t i = 0 ; i < sub_domainA.size() ; i++)
124  {
125  if (Box<dim,T>(sub_domainA.get(i)).isInside(ap) == true)
126  valid = false;
127  }
128 
129  return valid;
130  }
131 
132 public:
133 
140  size_t (& sz)[dim],
141  const Box<dim,T> & domain,
142  const Box<dim,T> & sub_A,
143  const Box<dim,T> & sub_B,
144  size_t (& bc)[dim])
145  :grid_dist_id_iterator_dec_skin<Decomposition>(dec, sz, getAB(sz,domain,sub_A,sub_B,sp,RETURN_A),
146  getAB(sz,domain,sub_A,sub_B,sp,RETURN_B), bc),
147  domain(domain)
148  {
149  sub_domainA.add(sub_A);
150  calculateAp();
151  }
152 
158  Point<dim,T> & get()
159  {
160  return ap;
161  }
162 
169  {
171 
172  calculateAp();
173 
175  {
177 
178  calculateAp();
179  }
180 
181  return *this;
182  }
183 
184  bool isNext()
185  {
187  }
188 
190  {
192 
193  ap = p.ap;
195  domain = p.domain;
196 
197  for (size_t i = 0 ; i < dim; i++)
198  sp[i] = p.sp[i];
199 
200  return *this;
201  }
202 
203  void addBoxA(const Box<dim,double> & BoxA)
204  {
205  sub_domainA.add(BoxA);
206  }
207 };
208 
209 
210 
211 #endif /* OPENFPM_NUMERICS_SRC_DRAW_POINTITERATORSKIN_HPP_ */
T getLow(int i) const
get the i-coordinate of the low bound interval of the box
Definition: Box.hpp:479
grid_key_dx is the key to access any element in the grid
Definition: grid_key.hpp:18
Point< dim, T > ap
Actual point.
PointIteratorSkin & operator++()
Next point.
this class draw particles on subset of grid-like position
T getHigh(int i) const
get the high interval of the box
Definition: Box.hpp:490
void setHigh(int i, T val)
set the high interval of the box
Definition: Box.hpp:467
size_t size()
Stub size.
Definition: map_vector.hpp:70
This class implement the point shape in an N-dimensional space.
Definition: Point.hpp:22
grid_dist_id_iterator_dec_skin< Decomposition > & operator=(const grid_dist_id_iterator_dec_skin< Decomposition > &tmp)
Copy operator=.
mem_id get(size_t i) const
Get the i index.
Definition: grid_key.hpp:394
PointIteratorSkin(Decomposition &dec, size_t(&sz)[dim], const Box< dim, T > &domain, const Box< dim, T > &sub_A, const Box< dim, T > &sub_B, size_t(&bc)[dim])
Draw Particles.
This class define the domain decomposition interface.
openfpm::vector< Box< dim, T > > sub_domainA
sub_domain (required to filter out points)
grid_key_dx< Decomposition::dims > get()
Get the actual global key of the grid.
Box< dim, T > domain
domain
void setLow(int i, T val)
set the low interval of the box
Definition: Box.hpp:456
T sp[dim]
Spacing.
This class represent an N-dimensional box.
Definition: Box.hpp:56
This class is a trick to indicate the compiler a specific specialization pattern. ...
Definition: memory_c.hpp:201
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:61
bool isNext()
Check if there is the next element.
Given the decomposition it create an iterator.
grid_dist_id_iterator_dec_skin< Decomposition > & operator++()
Get the next element.