OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
IntNGP.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_NGP_H
12 #define INT_NGP_H
13 
14 /* IntNGP.h -- Definition of simple class to perform nearest-grid-point
15  interpolation of data for a single particle to or from IPPL Field. */
16 
17 // include files
18 #include "Particle/Interpolator.h"
19 #include "Field/Field.h"
20 
21 
22 // forward declaration
23 class IntNGP;
24 
25 // specialization of InterpolatorTraits
26 
27 template <class T, unsigned Dim>
30 };
31 
32 
33 // IntNGP class definition
34 class IntNGP : public Interpolator {
35 
36 public:
37  // constructor/destructor
38  IntNGP() {}
39  ~IntNGP() {}
40 
41  // gather/scatter functions
42 
43  // scatter particle data into Field using particle position and mesh
44  template <class FT, unsigned Dim, 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  // find nearest-grid-point for particle position, store in NDIndex obj
49  NDIndex<Dim> ngp = FindNGP(mesh, ppos, CenteringTag<C>());
50  // scatter data value to Field ... this assumes that the Field
51  // data point is local to this processor, if not an error will be printed.
52 
54  *fiter += pdata;
55 
56  return;
57  }
58 
59  // scatter particle data into Field using particle position and mesh
60  // and cache mesh information for reuse
61  template <class FT, unsigned Dim, class M, class C, class PT>
62  static
63  void scatter(const FT& pdata, Field<FT,Dim,M,C>& f,
64  const Vektor<PT,Dim>& ppos, const M& mesh,
65  NDIndex<Dim>& ngp) {
66  // find nearest-grid-point for particle position, store in NDIndex obj
67  ngp = FindNGP(mesh, ppos, CenteringTag<C>());
68  // scatter data value to Field ... this assumes that the Field
69  // data point is local to this processor, if not an error will be printed.
70 
72  *fiter += pdata;
73 
74  return;
75  }
76 
77  // scatter particle data into Field using cached mesh information
78  template <class FT, unsigned Dim, class M, class C>
79  static
80  void scatter(const FT& pdata, Field<FT,Dim,M,C>& f,
81  const NDIndex<Dim>& ngp) {
82  // scatter data value to Field ... this assumes that the Field
83  // data point is local to this processor, if not an error will be printed.
84 
86  *fiter += pdata;
87 
88  return;
89  }
90 
91  // gather particle data from Field using particle position and mesh
92  template <class FT, unsigned Dim, class M, class C, class PT>
93  static
94  void gather(FT& pdata, const Field<FT,Dim,M,C>& f,
95  const Vektor<PT,Dim>& ppos, const M& mesh) {
96  // find nearest-grid-point for particle position, store in NDIndex obj
97  NDIndex<Dim> ngp = FindNGP(mesh, ppos, CenteringTag<C>());
98  // gather Field value to particle data ... this assumes that the Field
99  // data point is local to this processor, if not an error will be printed.
100 
102  pdata = *fiter;
103 
104  return;
105  }
106 
107  // gather particle data from Field using particle position and mesh
108  // and cache mesh information for reuse
109  template <class FT, unsigned Dim, class M, class C, class PT>
110  static
111  void gather(FT& pdata, const Field<FT,Dim,M,C>& f,
112  const Vektor<PT,Dim>& ppos, const M& mesh,
113  NDIndex<Dim>& ngp) {
114  // find nearest-grid-point for particle position, store in NDIndex obj
115  ngp = FindNGP(mesh, ppos, CenteringTag<C>());
116  // gather Field value to particle data ... this assumes that the Field
117  // data point is local to this processor, if not an error will be printed.
118 
120  pdata = *fiter;
121 
122  return;
123  }
124 
125  // gather particle data from Field using cached mesh information
126  template <class FT, unsigned Dim, class M, class C>
127  static
128  void gather(FT& pdata, const Field<FT,Dim,M,C>& f,
129  const NDIndex<Dim>& ngp) {
130  // gather Field value to particle data ... this assumes that the Field
131  // data point is local to this processor, if not an error will be printed.
132 
134  pdata = *fiter;
135 
136  return;
137  }
138 
139 };
140 
141 #endif // INT_NGP_H
142 
143 /***************************************************************************
144  * $RCSfile: IntNGP.h,v $ $Author: adelmann $
145  * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:28 $
146  * IPPL_VERSION_ID: $Id: IntNGP.h,v 1.1.1.1 2003/01/23 07:40:28 adelmann Exp $
147  ***************************************************************************/
148 
Definition: TSVMeta.h:24
Definition: rbendmap.h:8
static void scatter(const FT &pdata, Field< FT, Dim, M, C > &f, const Vektor< PT, Dim > &ppos, const M &mesh, NDIndex< Dim > &ngp)
Definition: IntNGP.h:63
static void scatter(const FT &pdata, Field< FT, Dim, M, C > &f, const Vektor< PT, Dim > &ppos, const M &mesh)
Definition: IntNGP.h:46
static void scatter(const FT &pdata, Field< FT, Dim, M, C > &f, const NDIndex< Dim > &ngp)
Definition: IntNGP.h:80
static CompressedBrickIterator< T, Dim > getFieldIter(const BareField< T, Dim > &f, const NDIndex< Dim > &pt)
Definition: Interpolator.h:191
static void gather(FT &pdata, const Field< FT, Dim, M, C > &f, const Vektor< PT, Dim > &ppos, const M &mesh, NDIndex< Dim > &ngp)
Definition: IntNGP.h:111
NDIndex< Dim > FindNGP(const M &mesh, const Vektor< PT, Dim > &ppos, CenteringTag< Cell >)
Definition: Interpolator.h:45
static void gather(FT &pdata, const Field< FT, Dim, M, C > &f, const NDIndex< Dim > &ngp)
Definition: IntNGP.h:128
static void gather(FT &pdata, const Field< FT, Dim, M, C > &f, const Vektor< PT, Dim > &ppos, const M &mesh)
Definition: IntNGP.h:94
const unsigned Dim
~IntNGP()
Definition: IntNGP.h:39
IntNGP()
Definition: IntNGP.h:38
Definition: IntNGP.h:34