quadgrid 0.1
simple cartesian quad grid with particles for c++/octave
Loading...
Searching...
No Matches
particles_imp.h
Go to the documentation of this file.
1#ifndef PARTICLES_IMP_H
2#define PARTICLES_IMP_H
3#include "counter.h"
4
5template<typename str>
6void
8(std::map<std::string, device_vector_t<real_t>> & vars,
9 std::initializer_list<str> const & pvarnames,
10 std::initializer_list<str> const & gvarnames,
11 bool apply_mass) {
12 using strlist = std::initializer_list<str> const &;
14 (vars, pvarnames, gvarnames, apply_mass);
15}
16
17template<typename GVAR_t, typename PVAR_t, typename P2C_t>
18class
20
22 const PVAR_t x;
23 const PVAR_t y;
24 const PVAR_t dprop;
25 const P2C_t ptcl_to_grd;
26 const idx_t nrows;
27 const real_t hx;
28 const real_t hy;
29 GVAR_t M;
30 GVAR_t gvar;
31
33
34public :
35
36 p2g_helper_t (const PVAR_t x_, const PVAR_t y_, GVAR_t M_,
37 GVAR_t gvar_, const P2C_t ptcl_to_grd_, const idx_t nrows_,
38 const real_t hx_, const real_t hy_, const PVAR_t dprop_, bool apply_mass_)
39 : x(x_), y(y_), M(M_), gvar(gvar_),
40 ptcl_to_grd(ptcl_to_grd_), nrows(nrows_), hx(hx_), hy(hy_),
41 dprop(dprop_), apply_mass(apply_mass_) {};
42
43 DEVICE
44 void
45 operator() (idx_t ip) {
46 using qgt = quadgrid_t<GVAR_t>;
47 real_t N = 0.0;
48 auto xx = x[ip];
49 auto yy = y[ip];
50 auto r = qgt::gind2row (ptcl_to_grd[ip], nrows);
51 auto c = qgt::gind2col (ptcl_to_grd[ip], nrows);
52 for (idx_t inode = 0; inode < 4; ++inode) {
53 N = apply_mass ? qgt::shp (xx, yy, inode, c, r, hx, hy)/M[qgt::gt(inode, c, r, nrows)] :
54 qgt::shp (xx, yy, inode, c, r, hx, hy);
55 atomicAdd(&(gvar[qgt::gt(inode, c, r, nrows)]), N*dprop[ip]);
56 }
57 }
58
59
60};
61
62
63template<typename GT, typename PT>
64void
66(std::map<std::string, device_vector_t<real_t>> & vars,
67 PT const & pvarnames,
68 GT const & gvarnames,
69 bool apply_mass) {
70
72 //real_t N = 0.0, xx = 0.0, yy = 0.0;
73 //idx_t idx = 0;
74
75
76 for (std::size_t ivar = 0; ivar < std::size(gvarnames); ++ivar) {
77
78 #ifdef USE_THRUST
79 auto & device_gvar = device_grid_vars[getkey(gvarnames, ivar)];
80 auto const & device_dprop = device_dprops.at(getkey(pvarnames, ivar));
81 thrust::counting_iterator<idx_t> first_p(0), last_p(this -> num_particles);
82 p2g_helper_t helper(device_x.cbegin(), device_y.cbegin(), thrust::raw_pointer_cast(device_grid_M.data()),
83 thrust::raw_pointer_cast(device_gvar.data()), device_ptcl_to_grd.cbegin(), grid.num_rows(), grid.hx(),
84 grid.hy(), device_dprop.cbegin(), apply_mass);
85 #else
86 auto & gvar = vars[getkey(gvarnames, ivar)];
87 auto const & dprop = dprops.at (getkey(pvarnames, ivar));
88 range<idx_t> rng (0, this->num_particles);
89 range<idx_t>::iterator first_p = rng.begin(), last_p = rng.end();
90 p2g_helper_t helper(x.cbegin(), y.cbegin(), M.begin(), gvar.begin(), ptcl_to_grd.cbegin(), grid.num_rows(), grid.hx(), grid.hy(), dprop.cbegin(), apply_mass);
91 #endif
92
93 algorithm_namespace::for_each(device_exec_policy, first_p, last_p, helper);
94
95 }
96
97}
98
99//p2g with custom helper
100template<typename UnaryFunction>
101void
103(std::map<std::string, device_vector_t<real_t>> & vars,
104 UnaryFunction helper){
105
106 #ifdef USE_THRUST
107 thrust::counting_iterator<idx_t> first_p(0), last_p(this -> num_particles);
108 #else
109 range<idx_t> rng (0, this->num_particles);
110 range<idx_t>::iterator first_p = rng.begin(), last_p = rng.end();
111 #endif
112
113 algorithm_namespace::for_each(device_exec_policy, first_p, last_p, helper);
114
115};
116
117
118template<typename str>
119void
121(std::map<std::string, device_vector_t<real_t>> & vars,
122 std::initializer_list<str> const & pxvarnames,
123 std::initializer_list<str> const & pyvarnames,
124 std::string const &area,
125 std::initializer_list<str> const & gvarnames,
126 bool apply_mass) {
127 using strlist = std::initializer_list<str> const &;
129 (vars, pxvarnames, pyvarnames, area, gvarnames, apply_mass);
130}
131
132template<typename GVAR_t, typename PVAR_t, typename P2C_t, typename DPROPX_t, typename DPROPY_t, typename DPROPAREA_t>
133class
135
137 const PVAR_t x;
138 const PVAR_t y;
139 const DPROPX_t dpropx;
140 const DPROPY_t dpropy;
141 const DPROPAREA_t dproparea;
142 const P2C_t ptcl_to_grd;
144 const real_t hx;
145 const real_t hy;
146 GVAR_t M;
147 GVAR_t gvar;
148
150
151public :
152
153 p2gd_helper_t (const PVAR_t x_, const PVAR_t y_, const GVAR_t M_,
154 GVAR_t gvar_, const P2C_t ptcl_to_grd_, const idx_t nrows_,
155 const real_t hx_, const real_t hy_, const DPROPX_t dpropx_, const DPROPY_t dpropy_, const DPROPAREA_t dproparea_, bool apply_mass_)
156 : x(x_), y(y_), M(M_), gvar(gvar_),
157 ptcl_to_grd(ptcl_to_grd_), nrows(nrows_), hx(hx_), hy(hy_),
158 dpropx(dpropx_), dpropy(dpropy_), dproparea(dproparea_), apply_mass(apply_mass_) {};
159
160 DEVICE
161 void
162 operator() (idx_t ip) {
163 using qgt = quadgrid_t<GVAR_t>;
164 real_t Nx = 0.0, Ny = 0.0;
165 auto xx = x[ip];
166 auto yy = y[ip];
167 auto r = qgt::gind2row (ptcl_to_grd[ip], nrows);
168 auto c = qgt::gind2col (ptcl_to_grd[ip], nrows);
169 for (idx_t inode = 0; inode < 4; ++inode) {
170 Nx = apply_mass ? qgt::shg (xx, yy, 0, inode, c, r, hx, hy) / M[qgt::gt(inode, c, r, nrows)] :
171 qgt::shg (xx, yy, 0, inode, c, r, hx, hy);
172 Ny = apply_mass ? qgt::shg (xx, yy, 1, inode, c, r, hx, hy) / M[qgt::gt(inode, c, r, nrows)] :
173 qgt::shg (xx, yy, 1, inode, c, r, hx, hy);
174
175 atomicAdd(&(gvar[qgt::gt(inode, c, r, nrows)]), (Nx*dpropx[ip] + Ny*dpropy[ip])*dproparea[ip]);
176 }
177 }
178
179
180};
181
182
183template<typename GT, typename PT>
184void
186(std::map<std::string, device_vector_t<real_t>> & vars,
187 PT const & pxvarnames,
188 PT const & pyvarnames,
189 std::string const &area,
190 GT const & gvarnames,
191 bool apply_mass) {
192
194 //real_t xx = 0.0, yy = 0.0, Nx = 0.0, Ny = 0.0;
195
196 for (std::size_t ivar = 0; ivar < std::size (gvarnames); ++ivar) {
197
198 #ifdef USE_THRUST
199 auto & device_gvar = device_grid_vars[getkey(gvarnames, ivar)];
200 auto const & device_dpropx = device_dprops.at (getkey(pxvarnames, ivar));
201 auto const & device_dpropy = device_dprops.at (getkey(pyvarnames, ivar));
202 auto const & device_dproparea = device_dprops.at (area);
203
204 thrust::counting_iterator<idx_t> first_p(0), last_p(this -> num_particles);
205
206 p2gd_helper_t helper(device_x.cbegin(), device_y.cbegin(), thrust::raw_pointer_cast(device_grid_M.data()),
207 thrust::raw_pointer_cast(device_gvar.data()), device_ptcl_to_grd.cbegin(), grid.num_rows(), grid.hx(),
208 grid.hy(), device_dpropx.cbegin(), device_dpropy.cbegin(), device_dproparea.cbegin(), apply_mass);
209
210 #else
211 auto & gvar = vars[getkey(gvarnames, ivar)];
212 auto const & dpropx = dprops.at (getkey(pxvarnames, ivar));
213 auto const & dpropy = dprops.at (getkey(pyvarnames, ivar));
214 auto const & dproparea = dprops.at (area);
215
216 range<idx_t> rng (0, this->num_particles);
217 range<idx_t>::iterator first_p = rng.begin(), last_p = rng.end();
218 p2gd_helper_t helper(x.cbegin(), y.cbegin(), M.cbegin(), gvar.begin(), ptcl_to_grd.cbegin(), grid.num_rows(), grid.hx(), grid.hy(),
219 dpropx.begin(), dpropy.begin(), dproparea.begin(), apply_mass);
220 #endif
221
222 algorithm_namespace::for_each(first_p, last_p, helper);
223
224 /*for (idx_t ip = 0; ip <= this->num_particles; ++ip) {
225 xx = x[ip];
226 yy = y[ip];
227 auto icell = grid[ptcl_to_grd[ip]];
228 for (idx_t inode = 0; inode < 4; ++inode) {
229 Nx = icell.shg (xx, yy, 0, inode);
230 Ny = icell.shg (xx, yy, 1, inode);
231 gvar[icell.gt(inode)] += (Nx * dpropx[ip] + Ny * dpropy[ip]) * dproparea[ip];
232 }
233 }*/
234
235 }
236
237 /*if (apply_mass)
238 for (std::size_t ivar = 0; ivar < std::size (gvarnames); ++ivar)
239 for (idx_t ii = 0; ii < M.size (); ++ii) {
240 vars[getkey(gvarnames, ivar)][ii] /= M[ii];
241 }*/
242
243}
244
245//P2GD with custom helper
246template<typename UnaryFunction>
247void
249(std::map<std::string, device_vector_t<real_t>> & vars,
250 UnaryFunction helper){
251
252 #ifdef USE_THRUST
253 thrust::counting_iterator<idx_t> first_p(0), last_p(this -> num_particles);
254 #else
255 range<idx_t> rng (0, this->num_particles);
256 range<idx_t>::iterator first_p = rng.begin(), last_p = rng.end();
257 #endif
258
259 algorithm_namespace::for_each(device_exec_policy, first_p, last_p, helper);
260
261 };
262
263
264template<typename str>
265void
267(const std::map<std::string, device_vector_t<real_t>> & vars,
268 std::initializer_list<str> const & gvarnames,
269 std::initializer_list<str> const & pvarnames,
270 bool apply_mass) {
271 using strlist = std::initializer_list<str> const &;
272 g2p<strlist, strlist> (vars, gvarnames,
273 pvarnames, apply_mass);
274}
275
278template<typename GVAR_t, typename PVAR_t, typename P2C_t, typename GRIDM_t>
279class
281
283 PVAR_t x;
284 PVAR_t y;
285 const GRIDM_t M;
286 const GVAR_t gvar;
287 const P2C_t ptcl_to_grd;
289 const real_t hx;
290 const real_t hy;
291 PVAR_t dprop;
293
294public :
295
296 g2p_helper_t (const PVAR_t x_, const PVAR_t y_, GRIDM_t M_,
297 const GVAR_t gvar_, const P2C_t ptcl_to_grd_, const idx_t nrows_,
298 const real_t hx_, const real_t hy_, PVAR_t dprop_, bool apply_mass_)
299 : x(x_), y(y_), M(M_), gvar(gvar_),
300 ptcl_to_grd(ptcl_to_grd_), nrows(nrows_), hx(hx_), hy(hy_),
301 dprop(dprop_), apply_mass(apply_mass_) {};
302
303 DEVICE
304 void
305 operator() (idx_t ip) {
306 using qgt = quadgrid_t<GVAR_t>;
307 real_t N = 0.0;
308 auto xx = x[ip];
309 auto yy = y[ip];
310 auto r = qgt::gind2row (ptcl_to_grd[ip], nrows);
311 auto c = qgt::gind2col (ptcl_to_grd[ip], nrows);
312 dprop[ip] = 0.;
313 for (idx_t inode = 0; inode < 4; ++inode) {
314 N = apply_mass ? qgt::shp (xx, yy, inode, c, r, hx, hy) * M[qgt::gt(inode, c, r, nrows)] :
315 qgt::shp (xx, yy, inode, c, r, hx, hy);
316 dprop[ip] += N * gvar[qgt::gt(inode, c, r, nrows)];
317 }
318 }
319};
320
321
322template<typename GT, typename PT>
323void
325(const std::map<std::string, device_vector_t<real_t>>& vars,
326 GT const & gvarnames,
327 PT const & pvarnames,
328 bool apply_mass) {
329
331 //real_t N = 0.0, xx = 0.0, yy = 0.0;
332 //idx_t idx = 0;
333
334 for (std::size_t ivar = 0; ivar < std::size (gvarnames); ++ivar) {
335
336 #ifdef USE_THRUST
337 auto & device_dprop = device_dprops.at(getkey(pvarnames, ivar));
338 auto const & device_gvar = device_grid_vars[getkey(gvarnames, ivar)];
339 thrust::counting_iterator<idx_t> first_p(0), last_p(this -> num_particles);
340 g2p_helper_t helper(thrust::raw_pointer_cast(device_x.data()), thrust::raw_pointer_cast(device_y.data()), device_grid_M.cbegin(), device_gvar.cbegin(),
341 device_ptcl_to_grd.cbegin(), grid.num_rows (), grid.hx (), grid.hy (), thrust::raw_pointer_cast(device_dprop.data()), apply_mass);
342 #else
343 auto & dprop = dprops.at (getkey (pvarnames, ivar));
344 auto const & gvar = vars.at (getkey (gvarnames, ivar));
345 range<idx_t> rng (0, this->num_particles);
346 range<idx_t>::iterator first_p = rng.begin(), last_p = rng.end();
347 g2p_helper_t helper (x.begin (), y.begin (), M.cbegin(),
348 gvar.cbegin (), ptcl_to_grd.cbegin (),
349 grid.num_rows (), grid.hx (), grid.hy (),
350 dprop.begin (), apply_mass);
351 #endif
352
353 algorithm_namespace::for_each(device_exec_policy, first_p, last_p, helper);
354
355 }
356}
357
358//g2p with custom helper
359template<typename UnaryFunction>
360void
362 (std::map<std::string, device_vector_t<real_t>> & vars,
363 UnaryFunction helper){
364
365 #ifdef USE_THRUST
366 thrust::counting_iterator<idx_t> first_p(0), last_p(this -> num_particles);
367 #else
368 range<idx_t> rng (0, this->num_particles);
369 range<idx_t>::iterator first_p = rng.begin(), last_p = rng.end();
370 #endif
371
372 algorithm_namespace::for_each(device_exec_policy, first_p, last_p, helper);
373
374};
375
376
377
378template<typename str>
379void
381(const std::map<std::string, device_vector_t<real_t>>& vars,
382 std::initializer_list<str> const & gvarnames,
383 std::initializer_list<str> const & pxvarnames,
384 std::initializer_list<str> const & pyvarnames,
385 bool apply_mass) {
386 using strlist = std::initializer_list<str> const &;
387 g2pd<strlist, strlist> (vars, gvarnames, pxvarnames,
388 pyvarnames, apply_mass);
389}
390
393template<typename GVAR_t, typename PVAR_t, typename P2C_t, typename GRIDM_t>
394class
396
398 PVAR_t x;
399 PVAR_t y;
400 const GRIDM_t M;
401 const GVAR_t gvar;
402 const P2C_t ptcl_to_grd;
404 const real_t hx;
405 const real_t hy;
406 PVAR_t dpropx;
407 PVAR_t dpropy;
409
410public :
411
412 g2pd_helper_t (const PVAR_t x_, const PVAR_t y_, const GRIDM_t M_,
413 const GVAR_t gvar_, const P2C_t ptcl_to_grd_, const idx_t nrows_,
414 const real_t hx_, const real_t hy_, PVAR_t dpropx_, PVAR_t dpropy_,
415 bool apply_mass_)
416 : x(x_), y(y_), M(M_), gvar(gvar_),
417 ptcl_to_grd(ptcl_to_grd_), nrows(nrows_), hx(hx_), hy(hy_),
418 dpropx(dpropx_), dpropy(dpropy_), apply_mass(apply_mass_) {};
419
420 DEVICE
421 void
422 operator() (idx_t ip) {
423 using qgt = quadgrid_t<GVAR_t>;
424 real_t Nx = 0.0, Ny = 0.0;
425 auto xx = x[ip];
426 auto yy = y[ip];
427 auto r = qgt::gind2row (ptcl_to_grd[ip], nrows);
428 auto c = qgt::gind2col (ptcl_to_grd[ip], nrows);
429
430 for (idx_t inode = 0; inode < 4; ++inode) {
431 Nx = apply_mass ?
432 qgt::shg (xx, yy, 0, inode, c, r, hx, hy) * M[qgt::gt(inode, c, r, nrows)] :
433 qgt::shg (xx, yy, 0, inode, c, r, hx, hy);
434 Ny = apply_mass ?
435 qgt::shg (xx, yy, 1, inode, c, r, hx, hy) * M[qgt::gt(inode, c, r, nrows)] :
436 qgt::shg (xx, yy, 1, inode, c, r, hx, hy);
437 dpropx[ip] += Nx * gvar[qgt::gt(inode, c, r, nrows)];
438 dpropy[ip] += Ny * gvar[qgt::gt(inode, c, r, nrows)];
439
440 }
441 }
442};
443
444template<typename GT, typename PT>
445void
447(const std::map<std::string, device_vector_t<real_t>>& vars,
448 GT const & gvarnames,
449 PT const & pxvarnames,
450 PT const & pyvarnames,
451 bool apply_mass) {
452
454 //real_t Nx = 0.0, Ny = 0.0, xx = 0.0, yy = 0.0;
455
456 for (std::size_t ivar = 0; ivar < std::size (gvarnames); ++ivar) {
457
458
459 // for (idx_t ip = 0; ip <= this->num_particles; ++ip) {
460 // xx = x[ip];
461 // yy = y[ip];
462 // auto icell = grid[ptcl_to_grd[ip]];
463 // for (idx_t inode = 0; inode < 4; ++inode) {
464 // Nx = apply_mass ?
465 // icell.shg(xx, yy, 0, inode) * M[icell.gt(inode)] :
466 // icell.shg(xx, yy, 0, inode);
467 // Ny = apply_mass ?
468 // icell.shg(xx, yy, 1, inode) * M[icell.gt(inode)] :
469 // icell.shg(xx, yy, 1, inode);
470 // dpropx[ip] += Nx * gvar[icell.gt(inode)];
471 // dpropy[ip] += Ny * gvar[icell.gt(inode)];
472 // }
473 // }
474
475
476
477 #ifdef USE_THRUST
478 auto const & device_gvar = device_grid_vars.at (getkey (gvarnames, ivar));
479 auto & device_dpropx = device_dprops.at (getkey (pxvarnames, ivar));
480 auto & device_dpropy = device_dprops.at (getkey (pyvarnames, ivar));
481 thrust::counting_iterator<idx_t> first_p(0), last_p(this -> num_particles);
482 g2pd_helper_t helper(thrust::raw_pointer_cast(device_x.data()), thrust::raw_pointer_cast(device_y.data()), device_grid_M.cbegin(), device_gvar.cbegin(),
483 device_ptcl_to_grd.cbegin(), grid.num_rows (), grid.hx (), grid.hy (), thrust::raw_pointer_cast(device_dpropx.data()),
484 thrust::raw_pointer_cast(device_dpropy.data()), apply_mass);
485
486 #else
487 auto const & gvar = vars.at (getkey (gvarnames, ivar));
488 auto & dpropx = dprops.at (getkey (pxvarnames, ivar));
489 auto & dpropy = dprops.at (getkey (pyvarnames, ivar));
490
491 range<idx_t> rng (0, this->num_particles);
492 range<idx_t>::iterator first_p = rng.begin(), last_p = rng.end();
493 g2pd_helper_t helper (x.begin (), y.begin (), M.cbegin (),
494 gvar.cbegin (), ptcl_to_grd.cbegin (),
495 grid.num_rows (), grid.hx (), grid.hy (),
496 dpropx.begin (), dpropy.begin (), apply_mass);
497 #endif
498
499 algorithm_namespace::for_each(first_p, last_p, helper);
500
501 }
502}
503
504
505//g2pd with custom helper
506template<typename UnaryFunction>
507void
509 (std::map<std::string, device_vector_t<real_t>> & vars,
510 UnaryFunction helper){
511
512 #ifdef USE_THRUST
513 thrust::counting_iterator<idx_t> first_p(0), last_p(this -> num_particles);
514 #else
515 range<idx_t> rng (0, this->num_particles);
516 range<idx_t>::iterator first_p = rng.begin(), last_p = rng.end();
517 #endif
518
519 algorithm_namespace::for_each(device_exec_policy, first_p, last_p, helper);
520 };
521
522
523
524
525#ifdef USE_THRUST
526// Updates 'device_ptcl_to_grd'
527class
528particles_t::update_ptcl_to_grd_device{
529
530public:
531
532 static
533 void
534 update(particles_t& p){
535 ptcl_to_grd_update_t p2gu (thrust::raw_pointer_cast(p.device_ptcl_to_grd.data ()), thrust::raw_pointer_cast(p.device_x.data ()),
536 thrust::raw_pointer_cast(p.device_y.data ()), p.grid.hx (), p.grid.hy (), p.grid.num_rows ());
537
538 thrust::counting_iterator<idx_t> first_p(0), last_p(p.num_particles);
539 thrust::for_each(device_exec_policy, first_p, last_p, p2gu);}
540};
541
542#endif
543
544//Updates 'host_ptcl_to_grd'
545class
547
548public:
549
550 static
551 void
553 ptcl_to_grd_update_t p2gu (p.ptcl_to_grd.begin (), p.x.begin (), p.y.begin (), p.grid.hx(), p.grid.hy(), p.grid.num_rows() );
554 range rng (0, p.num_particles);
555 std::for_each(rng.begin(), rng.end(), p2gu);}
556
557 };
558
559template<class backend>
560void
562 backend::update(*this);
563};
564
565
566template<typename str>
567void
569(std::map<std::string, vector_t<real_t>> & vars,
570 std::initializer_list<str> const & pvarnames,
571 std::initializer_list<str> const & gvarnames,
572 bool apply_mass) const {
573 using strlist = std::initializer_list<str> const &;
575 (vars, pvarnames, gvarnames, apply_mass);
576}
577
578template<typename GT, typename PT>
579void
581(std::map<std::string, vector_t<real_t>> & vars,
582 PT const & pvarnames,
583 GT const & gvarnames,
584 bool apply_mass) const {
585
587 double N = 0.0, xx = 0.0, yy = 0.0;
588
589
590 for (std::size_t ivar = 0; ivar < std::size(gvarnames); ++ivar) {
591 auto & gvar = vars[getkey(gvarnames, ivar)];
592 auto const & dprop = dprops.at (getkey(pvarnames, ivar));
593
594 for (idx_t ip = 0; ip <= this->num_particles; ++ip) {
595 xx = x[ip];
596 yy = y[ip];
597 auto icell = grid[ptcl_to_grd[ip]];
598 for (idx_t inode = 0; inode < 4; ++inode) {
599 N = icell.shp(xx, yy, inode) * dprop[ip];
600 gvar[icell.gt(inode)] += N;
601 }
602 }
603 }
604
605 if (apply_mass)
606 for (std::size_t ivar = 0; ivar < std::size (gvarnames); ++ivar)
607 for (idx_t ii = 0; ii < M.size (); ++ii) {
608 vars[getkey(gvarnames, ivar)][ii] /= M[ii];
609 }
610}
611
612template<>
613void
615(std::ostream & os) const;
616
617template<>
618void
620(std::ostream & os) const;
621
622template<>
623void
625(std::ostream & os) const;
626
627#endif
void atomicAdd(T *x, const T y)
Definition atomicAdd.h:9
Template class for the implementation of the g2p method.
const idx_t nrows
const P2C_t ptcl_to_grd
const real_t hy
const GVAR_t gvar
particles_t::idx_t idx_t
const real_t hx
g2p_helper_t(const PVAR_t x_, const PVAR_t y_, GRIDM_t M_, const GVAR_t gvar_, const P2C_t ptcl_to_grd_, const idx_t nrows_, const real_t hx_, const real_t hy_, PVAR_t dprop_, bool apply_mass_)
const GRIDM_t M
Template class for the implementation g2pd method.
particles_t::idx_t idx_t
const GRIDM_t M
const P2C_t ptcl_to_grd
g2pd_helper_t(const PVAR_t x_, const PVAR_t y_, const GRIDM_t M_, const GVAR_t gvar_, const P2C_t ptcl_to_grd_, const idx_t nrows_, const real_t hx_, const real_t hy_, PVAR_t dpropx_, PVAR_t dpropy_, bool apply_mass_)
const idx_t nrows
const GVAR_t gvar
const real_t hy
const real_t hx
particles_t::idx_t idx_t
const idx_t nrows
const P2C_t ptcl_to_grd
const real_t hx
const PVAR_t dprop
p2g_helper_t(const PVAR_t x_, const PVAR_t y_, GVAR_t M_, GVAR_t gvar_, const P2C_t ptcl_to_grd_, const idx_t nrows_, const real_t hx_, const real_t hy_, const PVAR_t dprop_, bool apply_mass_)
const PVAR_t y
const real_t hy
const PVAR_t x
const DPROPY_t dpropy
const real_t hy
const PVAR_t y
p2gd_helper_t(const PVAR_t x_, const PVAR_t y_, const GVAR_t M_, GVAR_t gvar_, const P2C_t ptcl_to_grd_, const idx_t nrows_, const real_t hx_, const real_t hy_, const DPROPX_t dpropx_, const DPROPY_t dpropy_, const DPROPAREA_t dproparea_, bool apply_mass_)
const DPROPX_t dpropx
const PVAR_t x
const real_t hx
particles_t::idx_t idx_t
const P2C_t ptcl_to_grd
const idx_t nrows
const DPROPAREA_t dproparea
static void update(particles_t &p)
Template class for the update of ptcl_to_grd mapping.
Definition particles.h:459
real_t hy() const
idx_t num_rows() const
real_t hx() const
#define device_exec_policy
#define DEVICE
double real_t
#define vector_t
#define device_vector_t
Class to represent particles embedded in a grid.
Definition particles.h:29
void p2g(std::map< std::string, device_vector_t< real_t > > &vars, bool apply_mass=false)
Map particle variables to the grid.
Definition particles.h:331
void g2pd(const std::map< std::string, device_vector_t< real_t > > &vars, GT const &gvarnames, PT const &pxvarnames, PT const &pyvarnames, bool apply_mass=false)
idx_t & ip(const std::string &name, idx_t ii)
shortcut for iprops.at (name) [ii]
Definition particles.h:294
void p2g_print(std::map< std::string, vector_t< real_t > > &vars, PT const &pvarnames, GT const &gvarnames, bool apply_mass=false) const
void g2p(const std::map< std::string, device_vector_t< real_t > > &vars, bool apply_mass=false)
Definition particles.h:401
idx_t num_particles
number of particles.
Definition particles.h:34
vector_t< idx_t > ptcl_to_grd
particles->grid connectivity.
Definition particles.h:46
quadgrid_t< vector_t< real_t > >::idx_t idx_t
datatype for indexing into vectors of properties
Definition particles.h:32
void print(std::ostream &os) const
Template for export function.
Definition particles.h:109
vector_t< real_t > M
Mass matrix to be used for transfers if required.
Definition particles.h:44
vector_t< real_t > x
x coordinate of particle positions.
Definition particles.h:35
const quadgrid_t< vector_t< real_t > > & grid
refernce to a grid object.
Definition particles.h:48
std::map< std::string, vector_t< real_t > > dprops
double type quantities associated with the particles.
Definition particles.h:42
vector_t< real_t > y
y coordinate of particle positions.
Definition particles.h:36
particles_t(idx_t n, const quadgrid_t< vector_t< real_t > > &grid_)
Simplest form of constructor.
Definition particles.h:118
void p2gd(std::map< std::string, device_vector_t< real_t > > &vars, PT const &pxvarnames, PT const &pyvarnames, std::string const &area, GT const &gvarnames, bool apply_mass=false)
static const std::string & getkey(std::map< std::string, device_vector_t< real_t > > const &varnames, std::size_t ivar)
Definition particles.h:306
void update_ptcl_to_grd()
Updates theptcl_to_grd map only, without changing.
Definition counter.h:7
iterator begin() const
Definition counter.h:33
iterator end() const
Definition counter.h:34