OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
IntSUDS.h
Go to the documentation of this file.
1// -*- C++ -*-
2/***************************************************************************
3 *
4 * The IPPL Framework
5 *
6 *
7 * Visit http://people.web.psi.ch/adelmann/ for more details
8 *
9 ***************************************************************************/
10
11#ifndef INT_SUDS_H
12#define INT_SUDS_H
13
14/* IntSUDS.h -- Definition of simple class to perform subtracted dipole
15 interpolation of data for a single particle to or from a IPPL Field. */
16
17// include files
19#include "Field/Field.h"
20
21
22// forward declaration
23class IntSUDS;
24
25// specialization of InterpolatorTraits
26template <class T, unsigned Dim>
29};
30
31
32// IntSUDSImpl class definition
33template <unsigned Dim>
34class IntSUDSImpl : public Interpolator {
35
36public:
37 // constructor/destructor
40
41 // gather/scatter functions
42
43 // scatter particle data into Field using particle position and mesh
44 template <class FT, class M, class C, class PT>
45 static
46 void scatter(const FT& /*pdata*/, Field<FT,Dim,M,C>& f,
47 const Vektor<PT,Dim>& ppos, const M& mesh) {
48 CenteringTag<C> ctag;
49 Vektor<PT,Dim> gpos, dpos, delta;
50 // unsigned int d;
51 // find nearest grid point for particle position, store in NDIndex obj
52 NDIndex<Dim> ngp = FindNGP(mesh, ppos, ctag);
53 // get position of ngp
54 FindPos(gpos, mesh, ngp, ctag);
55 // get distance from ppos to gpos
56 dpos = ppos - gpos;
57 // get mesh spacings
58 FindDelta(delta, mesh, ngp, ctag);
59 // normalize dpos by mesh spacing
60 dpos /= delta;
61 // Try to find ngp in local fields and get iterator
63 // accumulate into local elements
64 ERRORMSG("IntSUDS::scatter: not implemented for Dim>3!!"<<endl);
65 return;
66 }
67
68 // scatter particle data into Field using particle position and mesh
69 // and cache mesh information for reuse
70 template <class FT, class M, class C, class PT>
71 static
72 void scatter(const FT& /*pdata*/, Field<FT,Dim,M,C>& f,
73 const Vektor<PT,Dim>& ppos, const M& mesh,
74 NDIndex<Dim>& ngp, Vektor<PT,Dim>& dpos) {
75 CenteringTag<C> ctag;
76 Vektor<PT,Dim> gpos, delta;
77 // unsigned int d;
78 // find nearest grid point for particle position, store in NDIndex obj
79 ngp = FindNGP(mesh, ppos, ctag);
80 // get position of ngp
81 FindPos(gpos, mesh, ngp, ctag);
82 // get distance from ppos to gpos
83 dpos = ppos - gpos;
84 // get mesh spacings
85 FindDelta(delta, mesh, ngp, ctag);
86 // normalize dpos by mesh spacing
87 dpos /= delta;
88 // Try to find ngp in local fields and get iterator
90 // accumulate into local elements
91 ERRORMSG("IntSUDS::scatter: not implemented for Dim>3!!"<<endl);
92 return;
93 }
94
95 // scatter particle data into Field using cached mesh information
96 template <class FT, class M, class C, class PT>
97 static
98 void scatter(const FT& /*pdata*/, Field<FT,Dim,M,C>& f,
99 const NDIndex<Dim>& ngp, const Vektor<PT,Dim>&) {
100 // Try to find ngp in local fields and get iterator
102 // accumulate into local elements
103 ERRORMSG("IntSUDS::scatter: not implemented for Dim>3!!"<<endl);
104 return;
105 }
106
107 // gather particle data from Field using particle position and mesh
108 template <class FT, class M, class C, class PT>
109 static
110 void gather(FT& /*pdata*/, const Field<FT,Dim,M,C>& f,
111 const Vektor<PT,Dim>& ppos, const M& mesh) {
112 CenteringTag<C> ctag;
113 Vektor<PT,Dim> gpos, dpos, delta;
114 // unsigned int d;
115 // find nearest grid point for particle position, store in NDIndex obj
116 NDIndex<Dim> ngp = FindNGP(mesh, ppos, ctag);
117 // get position of ngp
118 FindPos(gpos, mesh, ngp, ctag);
119 // get distance from ppos to gpos
120 dpos = ppos - gpos;
121 // get mesh spacings
122 FindDelta(delta, mesh, ngp, ctag);
123 // normalize dpos by mesh spacing
124 dpos /= delta;
125 // Try to find ngp in local fields and get iterator
127 // accumulate into particle attrib
128 ERRORMSG("IntSUDS::gather: not implemented for Dim>3!!"<<endl);
129 return;
130 }
131
132 // gather particle data from Field using particle position and mesh
133 // and cache mesh information for reuse
134 template <class FT, class M, class C, class PT>
135 static
136 void gather(FT& /*pdata*/, const Field<FT,Dim,M,C>& f,
137 const Vektor<PT,Dim>& ppos, const M& mesh,
138 NDIndex<Dim>& ngp, Vektor<PT,Dim>& dpos) {
139 CenteringTag<C> ctag;
140 Vektor<PT,Dim> gpos, delta;
141 // unsigned int d;
142 // find nearest grid point for particle position, store in NDIndex obj
143 ngp = FindNGP(mesh, ppos, ctag);
144 // get position of ngp
145 FindPos(gpos, mesh, ngp, ctag);
146 // get distance from ppos to gpos
147 dpos = ppos - gpos;
148 // get mesh spacings
149 FindDelta(delta, mesh, ngp, ctag);
150 // normalize dpos by mesh spacing
151 dpos /= delta;
152 // Try to find ngp in local fields and get iterator
154 // accumulate into particle attrib
155 ERRORMSG("IntSUDS::gather: not implemented for Dim>3!!"<<endl);
156 return;
157 }
158
159 // gather particle data from Field using cached mesh information
160 template <class FT, class M, class C, class PT>
161 static
162 void gather(FT& /*pdata*/, const Field<FT,Dim,M,C>& f,
163 const NDIndex<Dim>& ngp, const Vektor<PT,Dim>&) {
164 // Try to find ngp in local fields and get iterator
166 // accumulate into particle attrib
167 ERRORMSG("IntSUDS::gather: not implemented for Dim>3!!"<<endl);
168 return;
169 }
170
171};
172
173
174template <>
175class IntSUDSImpl<1U> : public Interpolator {
176
177public:
178 // constructor/destructor
181
182 // gather/scatter functions
183
184 // scatter particle data into Field using particle position and mesh
185 template <class FT, class M, class C, class PT>
186 static
187 void scatter(const FT& pdata, Field<FT,1U,M,C>& f,
188 const Vektor<PT,1U>& ppos, const M& mesh) {
189 CenteringTag<C> ctag;
190 Vektor<PT,1U> gpos, dpos, delta;
191 // find nearest grid point for particle position, store in NDIndex obj
192 NDIndex<1U> ngp = FindNGP(mesh, ppos, ctag);
193 // get position of ngp
194 FindPos(gpos, mesh, ngp, ctag);
195 // get distance from ppos to gpos
196 dpos = ppos - gpos;
197 // get mesh spacings
198 FindDelta(delta, mesh, ngp, ctag);
199 // normalize dpos by mesh spacing
200 dpos /= delta;
201 // Try to find ngp in local fields and get iterator
203 // accumulate into local elements
204 *fiter += pdata;
205 fiter.offset( 1) += 0.5 * dpos(0) * pdata;
206 fiter.offset(-1) -= 0.5 * dpos(0) * pdata;
207 return;
208 }
209
210 // scatter particle data into Field using particle position and mesh
211 // and cache mesh information for reuse
212 template <class FT, class M, class C, class PT>
213 static
214 void scatter(const FT& pdata, Field<FT,1U,M,C>& f,
215 const Vektor<PT,1U>& ppos, const M& mesh,
216 NDIndex<1U>& ngp, Vektor<PT,1U>& dpos) {
217 CenteringTag<C> ctag;
218 Vektor<PT,1U> gpos, delta;
219 // find nearest grid point for particle position, store in NDIndex obj
220 ngp = FindNGP(mesh, ppos, ctag);
221 // get position of ngp
222 FindPos(gpos, mesh, ngp, ctag);
223 // get distance from ppos to gpos
224 dpos = ppos - gpos;
225 // get mesh spacings
226 FindDelta(delta, mesh, ngp, ctag);
227 // normalize dpos by mesh spacing
228 dpos /= delta;
229 // Try to find ngp in local fields and get iterator
231 // accumulate into local elements
232 *fiter += pdata;
233 fiter.offset( 1) += 0.5 * dpos(0) * pdata;
234 fiter.offset(-1) -= 0.5 * dpos(0) * pdata;
235 return;
236 }
237
238 // scatter particle data into Field using cached mesh information
239 template <class FT, class M, class C, class PT>
240 static
241 void scatter(const FT& pdata, Field<FT,1U,M,C>& f,
242 const NDIndex<1U>& ngp, const Vektor<PT,1U>& dpos) {
243 // Try to find ngp in local fields and get iterator
245 // accumulate into local elements
246 *fiter += pdata;
247 fiter.offset( 1) += 0.5 * dpos(0) * pdata;
248 fiter.offset(-1) -= 0.5 * dpos(0) * pdata;
249 return;
250 }
251
252 // gather particle data from Field using particle position and mesh
253 template <class FT, class M, class C, class PT>
254 static
255 void gather(FT& pdata, const Field<FT,1U,M,C>& f,
256 const Vektor<PT,1U>& ppos, const M& mesh) {
257 CenteringTag<C> ctag;
258 Vektor<PT,1U> gpos, dpos, delta;
259 // find nearest grid point for particle position, store in NDIndex obj
260 NDIndex<1U> ngp = FindNGP(mesh, ppos, ctag);
261 // get position of ngp
262 FindPos(gpos, mesh, ngp, ctag);
263 // get distance from ppos to gpos
264 dpos = ppos - gpos;
265 // get mesh spacings
266 FindDelta(delta, mesh, ngp, ctag);
267 // normalize dpos by mesh spacing
268 dpos /= delta;
269 // Try to find ngp in local fields and get iterator
271 // accumulate into particle attrib
272 pdata = (*fiter) +
273 0.5 * dpos(0) * (fiter.offset(1) - fiter.offset(-1));
274 return;
275 }
276
277 // gather particle data from Field using particle position and mesh
278 // and cache mesh information for reuse
279 template <class FT, class M, class C, class PT>
280 static
281 void gather(FT& pdata, const Field<FT,1U,M,C>& f,
282 const Vektor<PT,1U>& ppos, const M& mesh,
283 NDIndex<1U>& ngp, Vektor<PT,1U>& dpos) {
284 CenteringTag<C> ctag;
285 Vektor<PT,1U> gpos, delta;
286 // find nearest grid point for particle position, store in NDIndex obj
287 ngp = FindNGP(mesh, ppos, ctag);
288 // get position of ngp
289 FindPos(gpos, mesh, ngp, ctag);
290 // get distance from ppos to gpos
291 dpos = ppos - gpos;
292 // get mesh spacings
293 FindDelta(delta, mesh, ngp, ctag);
294 // normalize dpos by mesh spacing
295 dpos /= delta;
296 // Try to find ngp in local fields and get iterator
298 // accumulate into particle attrib
299 pdata = (*fiter) +
300 0.5 * dpos(0) * (fiter.offset(1) - fiter.offset(-1));
301 return;
302 }
303
304 // gather particle data from Field using cached mesh information
305 template <class FT, class M, class C, class PT>
306 static
307 void gather(FT& pdata, const Field<FT,1U,M,C>& f,
308 const NDIndex<1U>& ngp, const Vektor<PT,1U>& dpos) {
309 // Try to find ngp in local fields and get iterator
311 // accumulate into particle attrib
312 pdata = (*fiter) +
313 0.5 * dpos(0) * (fiter.offset(1) - fiter.offset(-1));
314 return;
315 }
316
317};
318
319
320template <>
321class IntSUDSImpl<2U> : public Interpolator {
322
323public:
324 // constructor/destructor
327
328 // gather/scatter functions
329
330 // scatter particle data into Field using particle position and mesh
331 template <class FT, class M, class C, class PT>
332 static
333 void scatter(const FT& pdata, Field<FT,2U,M,C>& f,
334 const Vektor<PT,2U>& ppos, const M& mesh) {
335 CenteringTag<C> ctag;
336 Vektor<PT,2U> gpos, dpos, delta;
337 // find nearest grid point for particle position, store in NDIndex obj
338 NDIndex<2U> ngp = FindNGP(mesh, ppos, ctag);
339 // get position of ngp
340 FindPos(gpos, mesh, ngp, ctag);
341 // get distance from ppos to gpos
342 dpos = ppos - gpos;
343 // get mesh spacings
344 FindDelta(delta, mesh, ngp, ctag);
345 // normalize dpos by mesh spacing
346 dpos /= delta;
347 // Try to find ngp in local fields and get iterator
349 // accumulate into local elements
350 *fiter += pdata;
351 fiter.offset( 1,0) += 0.5 * dpos(0) * pdata;
352 fiter.offset(-1,0) -= 0.5 * dpos(0) * pdata;
353 fiter.offset(0, 1) += 0.5 * dpos(1) * pdata;
354 fiter.offset(0,-1) -= 0.5 * dpos(1) * pdata;
355 return;
356 }
357
358 // scatter particle data into Field using particle position and mesh
359 // and cache mesh information for reuse
360 template <class FT, class M, class C, class PT>
361 static
362 void scatter(const FT& pdata, Field<FT,2U,M,C>& f,
363 const Vektor<PT,2U>& ppos, const M& mesh,
364 NDIndex<2U>& ngp, Vektor<PT,2U>& dpos) {
365 CenteringTag<C> ctag;
366 Vektor<PT,2U> gpos, delta;
367 // find nearest grid point for particle position, store in NDIndex obj
368 ngp = FindNGP(mesh, ppos, ctag);
369 // get position of ngp
370 FindPos(gpos, mesh, ngp, ctag);
371 // get distance from ppos to gpos
372 dpos = ppos - gpos;
373 // get mesh spacings
374 FindDelta(delta, mesh, ngp, ctag);
375 // normalize dpos by mesh spacing
376 dpos /= delta;
377 // Try to find ngp in local fields and get iterator
379 // accumulate into local elements
380 *fiter += pdata;
381 fiter.offset( 1,0) += 0.5 * dpos(0) * pdata;
382 fiter.offset(-1,0) -= 0.5 * dpos(0) * pdata;
383 fiter.offset(0, 1) += 0.5 * dpos(1) * pdata;
384 fiter.offset(0,-1) -= 0.5 * dpos(1) * pdata;
385 return;
386 }
387
388 // scatter particle data into Field using cached mesh information
389 template <class FT, class M, class C, class PT>
390 static
391 void scatter(const FT& pdata, Field<FT,2U,M,C>& f,
392 const NDIndex<2U>& ngp, const Vektor<PT,2U>& dpos) {
393 // Try to find ngp in local fields and get iterator
395 // accumulate into local elements
396 *fiter += pdata;
397 fiter.offset( 1,0) += 0.5 * dpos(0) * pdata;
398 fiter.offset(-1,0) -= 0.5 * dpos(0) * pdata;
399 fiter.offset(0, 1) += 0.5 * dpos(1) * pdata;
400 fiter.offset(0,-1) -= 0.5 * dpos(1) * pdata;
401 return;
402 }
403
404 // gather particle data from Field using particle position and mesh
405 template <class FT, class M, class C, class PT>
406 static
407 void gather(FT& pdata, const Field<FT,2U,M,C>& f,
408 const Vektor<PT,2U>& ppos, const M& mesh) {
409 CenteringTag<C> ctag;
410 Vektor<PT,2U> gpos, dpos, delta;
411 // find nearest grid point for particle position, store in NDIndex obj
412 NDIndex<2U> ngp = FindNGP(mesh, ppos, ctag);
413 // get position of ngp
414 FindPos(gpos, mesh, ngp, ctag);
415 // get distance from ppos to gpos
416 dpos = ppos - gpos;
417 // get mesh spacings
418 FindDelta(delta, mesh, ngp, ctag);
419 // normalize dpos by mesh spacing
420 dpos /= delta;
421 // Try to find ngp in local fields and get iterator
423 // accumulate into particle attrib
424 pdata = (*fiter) +
425 0.5 * dpos(0) * (fiter.offset(1,0) - fiter.offset(-1,0)) +
426 0.5 * dpos(1) * (fiter.offset(0,1) - fiter.offset(0,-1));
427 return;
428 }
429
430 // gather particle data from Field using particle position and mesh
431 // and cache mesh information for reuse
432 template <class FT, class M, class C, class PT>
433 static
434 void gather(FT& pdata, const Field<FT,2U,M,C>& f,
435 const Vektor<PT,2U>& ppos, const M& mesh,
436 NDIndex<2U>& ngp, Vektor<PT,2U>& dpos) {
437 CenteringTag<C> ctag;
438 Vektor<PT,2U> gpos, delta;
439 // find nearest grid point for particle position, store in NDIndex obj
440 ngp = FindNGP(mesh, ppos, ctag);
441 // get position of ngp
442 FindPos(gpos, mesh, ngp, ctag);
443 // get distance from ppos to gpos
444 dpos = ppos - gpos;
445 // get mesh spacings
446 FindDelta(delta, mesh, ngp, ctag);
447 // normalize dpos by mesh spacing
448 dpos /= delta;
449 // Try to find ngp in local fields and get iterator
451 // accumulate into particle attrib
452 pdata = (*fiter) +
453 0.5 * dpos(0) * (fiter.offset(1,0) - fiter.offset(-1,0)) +
454 0.5 * dpos(1) * (fiter.offset(0,1) - fiter.offset(0,-1));
455 return;
456 }
457
458 // gather particle data from Field using cached mesh information
459 template <class FT, class M, class C, class PT>
460 static
461 void gather(FT& pdata, const Field<FT,2U,M,C>& f,
462 const NDIndex<2U>& ngp, const Vektor<PT,2U>& dpos) {
463 // Try to find ngp in local fields and get iterator
465 // accumulate into particle attrib
466 pdata = (*fiter) +
467 0.5 * dpos(0) * (fiter.offset(1,0) - fiter.offset(-1,0)) +
468 0.5 * dpos(1) * (fiter.offset(0,1) - fiter.offset(0,-1));
469 return;
470 }
471
472};
473
474
475template <>
476class IntSUDSImpl<3U> : public Interpolator {
477
478public:
479 // constructor/destructor
482
483 // gather/scatter functions
484
485 // scatter particle data into Field using particle position and mesh
486 template <class FT, class M, class C, class PT>
487 static
488 void scatter(const FT& pdata, Field<FT,3U,M,C>& f,
489 const Vektor<PT,3U>& ppos, const M& mesh) {
490 CenteringTag<C> ctag;
491 Vektor<PT,3U> gpos, dpos, delta;
492 // find nearest grid point for particle position, store in NDIndex obj
493 NDIndex<3U> ngp = FindNGP(mesh, ppos, ctag);
494 // get position of ngp
495 FindPos(gpos, mesh, ngp, ctag);
496 // get distance from ppos to gpos
497 dpos = ppos - gpos;
498 // get mesh spacings
499 FindDelta(delta, mesh, ngp, ctag);
500 // normalize dpos by mesh spacing
501 dpos /= delta;
502 // Try to find ngp in local fields and get iterator
504 // accumulate into local elements
505 *fiter += pdata;
506 fiter.offset( 1,0,0) += 0.5 * dpos(0) * pdata;
507 fiter.offset(-1,0,0) -= 0.5 * dpos(0) * pdata;
508 fiter.offset(0, 1,0) += 0.5 * dpos(1) * pdata;
509 fiter.offset(0,-1,0) -= 0.5 * dpos(1) * pdata;
510 fiter.offset(0,0, 1) += 0.5 * dpos(2) * pdata;
511 fiter.offset(0,0,-1) -= 0.5 * dpos(2) * pdata;
512 return;
513 }
514
515 // scatter particle data into Field using particle position and mesh
516 // and cache mesh information for reuse
517 template <class FT, class M, class C, class PT>
518 static
519 void scatter(const FT& pdata, Field<FT,3U,M,C>& f,
520 const Vektor<PT,3U>& ppos, const M& mesh,
521 NDIndex<3U>& ngp, Vektor<PT,3U>& dpos) {
522 CenteringTag<C> ctag;
523 Vektor<PT,3U> gpos, delta;
524 // find nearest grid point for particle position, store in NDIndex obj
525 ngp = FindNGP(mesh, ppos, ctag);
526 // get position of ngp
527 FindPos(gpos, mesh, ngp, ctag);
528 // get distance from ppos to gpos
529 dpos = ppos - gpos;
530 // get mesh spacings
531 FindDelta(delta, mesh, ngp, ctag);
532 // normalize dpos by mesh spacing
533 dpos /= delta;
534 // Try to find ngp in local fields and get iterator
536 // accumulate into local elements
537 *fiter += pdata;
538 fiter.offset( 1,0,0) += 0.5 * dpos(0) * pdata;
539 fiter.offset(-1,0,0) -= 0.5 * dpos(0) * pdata;
540 fiter.offset(0, 1,0) += 0.5 * dpos(1) * pdata;
541 fiter.offset(0,-1,0) -= 0.5 * dpos(1) * pdata;
542 fiter.offset(0,0, 1) += 0.5 * dpos(2) * pdata;
543 fiter.offset(0,0,-1) -= 0.5 * dpos(2) * pdata;
544 return;
545 }
546
547 // scatter particle data into Field using cached mesh information
548 template <class FT, class M, class C, class PT>
549 static
550 void scatter(const FT& pdata, Field<FT,3U,M,C>& f,
551 const NDIndex<3U>& ngp, const Vektor<PT,3U>& dpos) {
552 // Try to find ngp in local fields and get iterator
554 // accumulate into local elements
555 *fiter += pdata;
556 fiter.offset( 1,0,0) += 0.5 * dpos(0) * pdata;
557 fiter.offset(-1,0,0) -= 0.5 * dpos(0) * pdata;
558 fiter.offset(0, 1,0) += 0.5 * dpos(1) * pdata;
559 fiter.offset(0,-1,0) -= 0.5 * dpos(1) * pdata;
560 fiter.offset(0,0, 1) += 0.5 * dpos(2) * pdata;
561 fiter.offset(0,0,-1) -= 0.5 * dpos(2) * pdata;
562 return;
563 }
564
565 // gather particle data from Field using particle position and mesh
566 template <class FT, class M, class C, class PT>
567 static
568 void gather(FT& pdata, const Field<FT,3U,M,C>& f,
569 const Vektor<PT,3U>& ppos, const M& mesh) {
570 CenteringTag<C> ctag;
571 Vektor<PT,3U> gpos, dpos, delta;
572 // find nearest grid point for particle position, store in NDIndex obj
573 NDIndex<3U> ngp = FindNGP(mesh, ppos, ctag);
574 // get position of ngp
575 FindPos(gpos, mesh, ngp, ctag);
576 // get distance from ppos to gpos
577 dpos = ppos - gpos;
578 // get mesh spacings
579 FindDelta(delta, mesh, ngp, ctag);
580 // normalize dpos by mesh spacing
581 dpos /= delta;
582 // Try to find ngp in local fields and get iterator
584 // accumulate into particle attrib
585 pdata = (*fiter) +
586 0.5 * dpos(0) * (fiter.offset(1,0,0) - fiter.offset(-1,0,0)) +
587 0.5 * dpos(1) * (fiter.offset(0,1,0) - fiter.offset(0,-1,0)) +
588 0.5 * dpos(2) * (fiter.offset(0,0,1) - fiter.offset(0,0,-1));
589 return;
590 }
591
592 // gather particle data from Field using particle position and mesh
593 // and cache mesh information for reuse
594 template <class FT, class M, class C, class PT>
595 static
596 void gather(FT& pdata, const Field<FT,3U,M,C>& f,
597 const Vektor<PT,3U>& ppos, const M& mesh,
598 NDIndex<3U>& ngp, Vektor<PT,3U>& dpos) {
599 CenteringTag<C> ctag;
600 Vektor<PT,3U> gpos, delta;
601 // find nearest grid point for particle position, store in NDIndex obj
602 ngp = FindNGP(mesh, ppos, ctag);
603 // get position of ngp
604 FindPos(gpos, mesh, ngp, ctag);
605 // get distance from ppos to gpos
606 dpos = ppos - gpos;
607 // get mesh spacings
608 FindDelta(delta, mesh, ngp, ctag);
609 // normalize dpos by mesh spacing
610 dpos /= delta;
611 // Try to find ngp in local fields and get iterator
613 // accumulate into particle attrib
614 pdata = (*fiter) +
615 0.5 * dpos(0) * (fiter.offset(1,0,0) - fiter.offset(-1,0,0)) +
616 0.5 * dpos(1) * (fiter.offset(0,1,0) - fiter.offset(0,-1,0)) +
617 0.5 * dpos(2) * (fiter.offset(0,0,1) - fiter.offset(0,0,-1));
618 return;
619 }
620
621 // gather particle data from Field using cached mesh information
622 template <class FT, class M, class C, class PT>
623 static
624 void gather(FT& pdata, const Field<FT,3U,M,C>& f,
625 const NDIndex<3U>& ngp, const Vektor<PT,3U>& dpos) {
626 // Try to find ngp in local fields and get iterator
628 // accumulate into particle attrib
629 pdata = (*fiter) +
630 0.5 * dpos(0) * (fiter.offset(1,0,0) - fiter.offset(-1,0,0)) +
631 0.5 * dpos(1) * (fiter.offset(0,1,0) - fiter.offset(0,-1,0)) +
632 0.5 * dpos(2) * (fiter.offset(0,0,1) - fiter.offset(0,0,-1));
633 return;
634 }
635
636};
637
638
639// IntSUDS class -- what the user sees
640class IntSUDS {
641
642public:
643 // constructor/destructor
646
647 // gather/scatter functions
648
649 // scatter particle data into Field using particle position and mesh
650 template <class FT, unsigned Dim, class M, class C, class PT>
651 static
652 void scatter(const FT& pdata, Field<FT,Dim,M,C>& f,
653 const Vektor<PT,Dim>& ppos, const M& mesh) {
654 IntSUDSImpl<Dim>::scatter(pdata,f,ppos,mesh);
655 }
656
657 // scatter particle data into Field using particle position and mesh
658 // and cache mesh information for reuse
659 template <class FT, unsigned Dim, class M, class C, class PT>
660 static
661 void scatter(const FT& pdata, Field<FT,Dim,M,C>& f,
662 const Vektor<PT,Dim>& ppos, const M& mesh,
663 CacheData1<PT,Dim>& cache) {
664 IntSUDSImpl<Dim>::scatter(pdata,f,ppos,mesh,cache.Index_m,cache.Delta_m);
665 }
666
667 // scatter particle data into Field using cached mesh information
668 template <class FT, unsigned Dim, class M, class C, class PT>
669 static
670 void scatter(const FT& pdata, Field<FT,Dim,M,C>& f,
671 const CacheData1<PT,Dim>& cache) {
672 IntSUDSImpl<Dim>::scatter(pdata,f,cache.Index_m,cache.Delta_m);
673 }
674
675 // gather particle data from Field using particle position and mesh
676 template <class FT, unsigned Dim, class M, class C, class PT>
677 static
678 void gather(FT& pdata, const Field<FT,Dim,M,C>& f,
679 const Vektor<PT,Dim>& ppos, const M& mesh) {
680 IntSUDSImpl<Dim>::gather(pdata,f,ppos,mesh);
681 }
682
683 // gather particle data from Field using particle position and mesh
684 // and cache mesh information for reuse
685 template <class FT, unsigned Dim, class M, class C, class PT>
686 static
687 void gather(FT& pdata, const Field<FT,Dim,M,C>& f,
688 const Vektor<PT,Dim>& ppos, const M& mesh,
689 CacheData1<PT,Dim>& cache) {
690 IntSUDSImpl<Dim>::gather(pdata,f,ppos,mesh,cache.Index_m,cache.Delta_m);
691 }
692
693 // gather particle data from Field using cached mesh information
694 template <class FT, unsigned Dim, class M, class C, class PT>
695 static
696 void gather(FT& pdata, const Field<FT,Dim,M,C>& f,
697 const CacheData1<PT,Dim>& cache) {
698 IntSUDSImpl<Dim>::gather(pdata,f,cache.Index_m,cache.Delta_m);
699 }
700
701};
702
703#endif // INT_SUDS_H
704
705/***************************************************************************
706 * $RCSfile: IntSUDS.h,v $ $Author: adelmann $
707 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:28 $
708 * IPPL_VERSION_ID: $Id: IntSUDS.h,v 1.1.1.1 2003/01/23 07:40:28 adelmann Exp $
709 ***************************************************************************/
710
const unsigned Dim
void FindDelta(Vektor< PT, Dim > &delta, const M &mesh, const NDIndex< Dim > &gp, CenteringTag< Cell >)
Definition: Interpolator.h:95
NDIndex< Dim > FindNGP(const M &mesh, const Vektor< PT, Dim > &ppos, CenteringTag< Cell >)
Definition: Interpolator.h:37
void FindPos(Vektor< PT, Dim > &pos, const M &mesh, const NDIndex< Dim > &indices, CenteringTag< Cell >)
Definition: Interpolator.h:62
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
#define ERRORMSG(msg)
Definition: IpplInfo.h:350
Definition: Vektor.h:32
Definition: Field.h:33
T & offset(int i) const
Vektor< T, Dim > Delta_m
Definition: Interpolator.h:134
NDIndex< Dim > Index_m
Definition: Interpolator.h:133
static CompressedBrickIterator< T, Dim > getFieldIter(const BareField< T, Dim > &f, const NDIndex< Dim > &pt)
Definition: Interpolator.h:183
CacheData1< T, Dim > Cache_t
Definition: IntSUDS.h:28
static void scatter(const FT &, Field< FT, Dim, M, C > &f, const Vektor< PT, Dim > &ppos, const M &mesh, NDIndex< Dim > &ngp, Vektor< PT, Dim > &dpos)
Definition: IntSUDS.h:72
static void gather(FT &, const Field< FT, Dim, M, C > &f, const Vektor< PT, Dim > &ppos, const M &mesh)
Definition: IntSUDS.h:110
static void gather(FT &, const Field< FT, Dim, M, C > &f, const Vektor< PT, Dim > &ppos, const M &mesh, NDIndex< Dim > &ngp, Vektor< PT, Dim > &dpos)
Definition: IntSUDS.h:136
static void gather(FT &, const Field< FT, Dim, M, C > &f, const NDIndex< Dim > &ngp, const Vektor< PT, Dim > &)
Definition: IntSUDS.h:162
static void scatter(const FT &, Field< FT, Dim, M, C > &f, const NDIndex< Dim > &ngp, const Vektor< PT, Dim > &)
Definition: IntSUDS.h:98
~IntSUDSImpl()
Definition: IntSUDS.h:39
IntSUDSImpl()
Definition: IntSUDS.h:38
static void scatter(const FT &, Field< FT, Dim, M, C > &f, const Vektor< PT, Dim > &ppos, const M &mesh)
Definition: IntSUDS.h:46
static void scatter(const FT &pdata, Field< FT, 1U, M, C > &f, const NDIndex< 1U > &ngp, const Vektor< PT, 1U > &dpos)
Definition: IntSUDS.h:241
static void gather(FT &pdata, const Field< FT, 1U, M, C > &f, const NDIndex< 1U > &ngp, const Vektor< PT, 1U > &dpos)
Definition: IntSUDS.h:307
static void scatter(const FT &pdata, Field< FT, 1U, M, C > &f, const Vektor< PT, 1U > &ppos, const M &mesh, NDIndex< 1U > &ngp, Vektor< PT, 1U > &dpos)
Definition: IntSUDS.h:214
static void gather(FT &pdata, const Field< FT, 1U, M, C > &f, const Vektor< PT, 1U > &ppos, const M &mesh)
Definition: IntSUDS.h:255
static void scatter(const FT &pdata, Field< FT, 1U, M, C > &f, const Vektor< PT, 1U > &ppos, const M &mesh)
Definition: IntSUDS.h:187
static void gather(FT &pdata, const Field< FT, 1U, M, C > &f, const Vektor< PT, 1U > &ppos, const M &mesh, NDIndex< 1U > &ngp, Vektor< PT, 1U > &dpos)
Definition: IntSUDS.h:281
static void scatter(const FT &pdata, Field< FT, 2U, M, C > &f, const Vektor< PT, 2U > &ppos, const M &mesh, NDIndex< 2U > &ngp, Vektor< PT, 2U > &dpos)
Definition: IntSUDS.h:362
static void gather(FT &pdata, const Field< FT, 2U, M, C > &f, const Vektor< PT, 2U > &ppos, const M &mesh, NDIndex< 2U > &ngp, Vektor< PT, 2U > &dpos)
Definition: IntSUDS.h:434
static void gather(FT &pdata, const Field< FT, 2U, M, C > &f, const NDIndex< 2U > &ngp, const Vektor< PT, 2U > &dpos)
Definition: IntSUDS.h:461
static void scatter(const FT &pdata, Field< FT, 2U, M, C > &f, const NDIndex< 2U > &ngp, const Vektor< PT, 2U > &dpos)
Definition: IntSUDS.h:391
static void gather(FT &pdata, const Field< FT, 2U, M, C > &f, const Vektor< PT, 2U > &ppos, const M &mesh)
Definition: IntSUDS.h:407
static void scatter(const FT &pdata, Field< FT, 2U, M, C > &f, const Vektor< PT, 2U > &ppos, const M &mesh)
Definition: IntSUDS.h:333
static void scatter(const FT &pdata, Field< FT, 3U, M, C > &f, const Vektor< PT, 3U > &ppos, const M &mesh, NDIndex< 3U > &ngp, Vektor< PT, 3U > &dpos)
Definition: IntSUDS.h:519
static void gather(FT &pdata, const Field< FT, 3U, M, C > &f, const NDIndex< 3U > &ngp, const Vektor< PT, 3U > &dpos)
Definition: IntSUDS.h:624
static void gather(FT &pdata, const Field< FT, 3U, M, C > &f, const Vektor< PT, 3U > &ppos, const M &mesh)
Definition: IntSUDS.h:568
static void scatter(const FT &pdata, Field< FT, 3U, M, C > &f, const Vektor< PT, 3U > &ppos, const M &mesh)
Definition: IntSUDS.h:488
static void gather(FT &pdata, const Field< FT, 3U, M, C > &f, const Vektor< PT, 3U > &ppos, const M &mesh, NDIndex< 3U > &ngp, Vektor< PT, 3U > &dpos)
Definition: IntSUDS.h:596
static void scatter(const FT &pdata, Field< FT, 3U, M, C > &f, const NDIndex< 3U > &ngp, const Vektor< PT, 3U > &dpos)
Definition: IntSUDS.h:550
static void scatter(const FT &pdata, Field< FT, Dim, M, C > &f, const Vektor< PT, Dim > &ppos, const M &mesh)
Definition: IntSUDS.h:652
IntSUDS()
Definition: IntSUDS.h:644
~IntSUDS()
Definition: IntSUDS.h:645
static void scatter(const FT &pdata, Field< FT, Dim, M, C > &f, const Vektor< PT, Dim > &ppos, const M &mesh, CacheData1< PT, Dim > &cache)
Definition: IntSUDS.h:661
static void gather(FT &pdata, const Field< FT, Dim, M, C > &f, const Vektor< PT, Dim > &ppos, const M &mesh)
Definition: IntSUDS.h:678
static void gather(FT &pdata, const Field< FT, Dim, M, C > &f, const Vektor< PT, Dim > &ppos, const M &mesh, CacheData1< PT, Dim > &cache)
Definition: IntSUDS.h:687
static void gather(FT &pdata, const Field< FT, Dim, M, C > &f, const CacheData1< PT, Dim > &cache)
Definition: IntSUDS.h:696
static void scatter(const FT &pdata, Field< FT, Dim, M, C > &f, const CacheData1< PT, Dim > &cache)
Definition: IntSUDS.h:670