8#ifndef VECTOR_DIST_FUNCS_HPP_
9#define VECTOR_DIST_FUNCS_HPP_
15 template<
typename T1,
typename T2>
inline static void proc(
size_t lbl,
size_t cnt,
size_t id, T1 & v_prp, T2 & m_prp)
17 m_prp.get(lbl).set(cnt, v_prp.get(
id));
25 template<
typename T1,
typename T2> __device__
inline static void proc(
size_t cnt,
size_t id, T1 & v_prp, T2 & m_prp)
27 m_prp.set(cnt, v_prp.get(
id));
40template<
typename m_opart_type>
41inline size_t get_end_valid(
long int & end,
long int & end_id, m_opart_type & m_opart)
45 while (end >= 0 && end_id >= 0 && (
long int)m_opart.template get<0>(end) == end_id)
70template<
typename proc_
class,
typename Top,
typename Pmr,
typename T1,
typename T2,
typename T3,
typename T4>
71inline void process_map_particle(
size_t i,
long int & end,
long int & id_end, Top & m_opart, Pmr p_map_req, T1 & m_pos, T2 & m_prp, T3 & v_pos, T4 & v_prp,
openfpm::vector<size_t> & cnt)
73 long int prc_id = m_opart.template get<2>(i);
74 size_t id = m_opart.template get<0>(i);
78 size_t lbl = p_map_req.get(prc_id);
80 m_pos.get(lbl).set(cnt.get(lbl), v_pos.get(
id));
81 proc_class::proc(lbl,cnt.get(lbl),
id,v_prp,m_prp);
87 long int id_valid = get_end_valid(end,id_end,m_opart);
89 if (id_valid > 0 && (
long int)
id < id_valid)
91 v_pos.set(
id,v_pos.get(id_valid));
92 v_prp.set(
id,v_prp.get(id_valid));
98 long int id_valid = get_end_valid(end,id_end,m_opart);
100 if (id_valid > 0 && (
long int)
id < id_valid)
102 v_pos.set(
id,v_pos.get(id_valid));
103 v_prp.set(
id,v_prp.get(id_valid));
110template<
typename proc_
class,
typename Top,
typename T1,
typename T2,
typename T3,
typename T4>
111__device__
inline void process_map_device_particle(
unsigned int i,
unsigned int offset, Top & m_opart, T1 & m_pos, T2 & m_prp, T3 & v_pos, T4 & v_prp)
113 size_t id = m_opart.template get<0>(i+offset);
115 m_pos.set(i, v_pos.get(
id));
116 proc_class::proc(i,
id,v_prp,m_prp);
121template<
typename Top,
typename T2,
typename T4,
unsigned int ... prp>
122__device__
inline void process_ghost_device_particle_prp(
unsigned int i,
unsigned int offset, Top & g_opart, T2 & m_prp, T4 & v_prp)
124 unsigned int id = g_opart.template get<1>(i+offset) & 0xFFFFFFFF;
127 typedef decltype(v_prp.get(
id)) encap_src;
129 typedef decltype(m_prp.get(i)) encap_dst;
132 object_si_d<encap_src, encap_dst, OBJ_ENCAP, prp...>(v_prp.get(
id), m_prp.get(i));
136template<
typename T2,
typename T4,
unsigned int ... prp>
137__device__
inline void process_ghost_device_particle_prp(
unsigned int i,
unsigned int offset, T2 & m_prp, T4 & v_prp)
139 unsigned int id = i+offset;
142 typedef decltype(v_prp.get(
id)) encap_src;
144 typedef decltype(m_prp.get(i)) encap_dst;
147 object_si_d<encap_src, encap_dst, OBJ_ENCAP, prp...>(v_prp.get(
id), m_prp.get(i));
150template<
typename base_type,
unsigned int prp>
153 template<
typename St,
typename vector_type>
154 static bool compare(
vector_type & v_prp,St & tol, St & near,
bool silent =
false)
161 tmp.resize(v_prp.size());
170 tmp.template get<0>(p) = v_prp.template get<prp>(p);
175 v_prp.template deviceToHost<prp>();
184 if (fabs(tmp.template get<0>(p) - v_prp.template get<prp>(p)) >= tol && (fabs(tmp.template get<0>(p)) > near && fabs(v_prp.template get<prp>(p)) ) )
186 std::cout <<
"Host and Device buffer differ over set tollerance: " <<
"Host[" << p <<
"]=" << tmp.template get<0>(p)
187 <<
" Device[" << p <<
"]="<< v_prp.template get<0>(p) <<
188 " differ more than: " << tol << std::endl;
196 it = tmp.getIterator();
202 v_prp.template get<prp>(p) = tmp.template get<0>(p);
211template<
typename base_type,
unsigned int N1,
unsigned int prp>
214 template<
typename St,
typename vector_type>
215 static bool compare(
vector_type & v_pos,St & tol, St & near,
bool silent =
false)
222 tmp.resize(v_pos.size());
231 tmp.get(p) = v_pos.get(p);
236 v_pos.template deviceToHost<prp>();
245 for (
size_t j = 0 ; j < N1 ; j++)
247 if (fabs(tmp.template get<0>(p)[j] - v_pos.template get<0>(p)[j]) >= tol && (fabs(tmp.template get<0>(p)[j]) > near && fabs(v_pos.template get<0>(p)[j]) ) )
249 std::cout <<
"Host and Device buffer differ over set tollerance: " <<
"Host[" << p <<
"][" << j <<
"]=" << tmp.template get<0>(p)[j]
250 <<
" Device[" << p <<
"][" << j <<
"]=" << v_pos.template get<0>(p)[j] <<
251 " differ more than: " << tol << std::endl;
260 it = tmp.getIterator();
266 v_pos.get(p) = tmp.get(p);
275template<
typename base_type,
unsigned int N1,
unsigned int prp>
278 template<
typename St,
typename vector_type>
279 static bool compare(
vector_type & v_prp,St & tol, St & near,
bool silent =
false)
286 tmp.resize(v_prp.size());
295 for (
size_t j = 0 ; j < N1 ; j++)
297 tmp.template get<0>(p)[j] = v_prp.template get<prp>(p)[j];
303 v_prp.template deviceToHost<prp>();
312 for (
size_t j = 0 ; j < N1 ; j++)
314 if (fabs(tmp.template get<0>(p)[j] - v_prp.template get<prp>(p)[j]) >= tol && (fabs(tmp.template get<0>(p)[j]) > near && fabs(v_prp.template get<prp>(p)[j]) ) )
316 std::cout <<
"Host and Device buffer differ over set tollerance: " <<
"Host[" << p <<
"]=" << tmp.template get<0>(p)[j]
317 <<
" Device[" << p <<
"]="<< v_prp.template get<prp>(p)[j] <<
318 " differ more than: " << tol << std::endl;
333 for (
size_t j = 0 ; j < N1 ; j++)
335 v_prp.template get<prp>(p)[j] = tmp.template get<0>(p)[j];
345template<
typename base_type,
unsigned int N1 ,
unsigned int N2,
unsigned int prp>
348 template<
typename St,
typename vector_type>
349 static bool compare(
vector_type & v_prp,St & tol, St & near,
bool silent =
false)
356 tmp.resize(v_prp.size());
365 for (
size_t j = 0 ; j < N1 ; j++)
367 for (
size_t k = 0 ; k < N2 ; k++)
369 tmp.template get<0>(p)[j][k] = v_prp.template get<prp>(p)[j][k];
376 v_prp.template deviceToHost<prp>();
385 for (
size_t j = 0 ; j < N1 ; j++)
387 for (
size_t k = 0 ; k < N2 ; k++)
389 if (fabs(tmp.template get<0>(p)[j][k] - v_prp.template get<prp>(p)[j][k]) >= tol && (fabs(tmp.template get<0>(p)[j][k]) > near && fabs(v_prp.template get<prp>(p)[j][k]) ) )
391 std::cout <<
"Host and Device buffer differ over set tollerance: " <<
"Host[" << p <<
"][" << j <<
"][" << k <<
"]=" << tmp.template get<0>(p)[j][k]
392 <<
" Device[" << p <<
"][" << j <<
"][" << k <<
"]=" << v_prp.template get<prp>(p)[j][k] <<
" differ more than: " << tol << std::endl;
409 for (
size_t j = 0 ; j < N1 ; j++)
411 for (
size_t k = 0 ; k < N2 ; k++)
413 v_prp.template get<prp>(p)[j][k] = tmp.template get<0>(p)[j][k];
This class implement the point shape in an N-dimensional space.
Implementation of 1-D std::vector like structure.
vect_dist_key_dx get()
Get the actual key.
vector_dist_iterator getIterator()
Get an iterator that traverse domain and ghost particles.
It copy the properties from one object to another.
process the particle without properties
static __device__ void proc(size_t cnt, size_t id, T1 &v_prp, T2 &m_prp)
process the particle
process the particle without properties
static void proc(size_t lbl, size_t cnt, size_t id, T1 &v_prp, T2 &m_prp)
process the particle