OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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
53template<unsigned int dim, typename T, typename 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
132public:
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),
148 {
149 sub_domainA.add(sub_A);
150 calculateAp();
151 }
152
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_ */
This class represent an N-dimensional box.
Definition Box.hpp:61
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the box
Definition Box.hpp:556
__device__ __host__ T getHigh(int i) const
get the high interval of the box
Definition Box.hpp:567
__host__ __device__ bool isInside(const Point< dim, T > &p) const
Check if the point is inside the box.
Definition Box.hpp:1004
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
Definition Box.hpp:544
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
Definition Box.hpp:533
This class define the domain decomposition interface.
this class draw particles on subset of grid-like position
Point< dim, T > & get()
openfpm::vector< Box< dim, T > > sub_domainA
sub_domain (required to filter out points)
Box< dim, T > domain
domain
PointIteratorSkin & operator++()
Next point.
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.
Point< dim, T > ap
Actual point.
This class implement the point shape in an N-dimensional space.
Definition Point.hpp:28
Given the decomposition it create an iterator.
bool isNext()
Check if there is the next element.
grid_key_dx< Decomposition::dims > get()
Get the actual global key of the grid.
grid_dist_id_iterator_dec_skin< Decomposition > & operator=(const grid_dist_id_iterator_dec_skin< Decomposition > &tmp)
Copy operator=.
grid_dist_id_iterator_dec_skin< Decomposition > & operator++()
Get the next element.
grid_key_dx is the key to access any element in the grid
Definition grid_key.hpp:19
__device__ __host__ index_type get(index_type i) const
Get the i index.
Definition grid_key.hpp:503
Implementation of 1-D std::vector like structure.
size_t size()
Stub size.