1 #ifndef ELECTRIC_FIELD_HPP
2 #define ELECTRIC_FIELD_HPP
50 Kokkos::View<T**,Kokkos::LayoutRight,HostType> ff_h;
51 Kokkos::View<T**,Kokkos::LayoutRight,HostType> phi_ff_h;
52 Kokkos::View<T**,Kokkos::LayoutRight,HostType> rho_ff_h;
56 rho_ff_h = Kokkos::View<T**,Kokkos::LayoutRight,HostType>(
"rho_ff_h",nnode,nrho+1);
59 phi_ff_h = Kokkos::View<T**,Kokkos::LayoutRight,HostType>(
"phi_ff_h",nphi,nnode);
63 Kokkos::View<T**,Kokkos::LayoutRight,HostType>
rho_h;
66 :
rho_h(
"rho_h",nnode, nrho+1) {}
71 template<
class Device>
86 Kokkos::View<double**,Kokkos::LayoutRight,HostType>
dpot_h;
87 Kokkos::View<ScalarFieldPlanes*,Kokkos::LayoutRight,HostType> dpot_ff_h;
89 Kokkos::View<Vector2DFieldPlanes*,Kokkos::LayoutRight,HostType> E00_ff_h;
94 Kokkos::View<double**,Kokkos::LayoutRight,HostType> Ah_h;
97 Kokkos::View<double**,Kokkos::LayoutRight,HostType> As_h;
107 Kokkos::View<double*,Kokkos::LayoutRight,HostType>
dpot_h;
112 Kokkos::View<VectorFieldPlanes**,Kokkos::LayoutRight,Device> E_phi_ff;
113 Kokkos::View<VectorFieldPlanes**,Kokkos::LayoutRight,Device> E_rho_ff;
114 Kokkos::View<ScalarFieldPlanes*,Kokkos::LayoutRight,Device> dpot_ff;
116 Kokkos::View<Vector2DFieldPlanes*,Kokkos::LayoutRight,Device> E00_ff;
117 Kokkos::View<ScalarFieldPlanes**,Kokkos::LayoutRight,Device> ddpotdt_phi;
121 Kokkos::View<VectorFieldPlanes**,Kokkos::LayoutRight,Device> dAh_phi_ff;
122 Kokkos::View<VectorFieldPlanes**,Kokkos::LayoutRight,Device> dAh_rho_ff;
123 Kokkos::View<ScalarFieldPlanes**,Kokkos::LayoutRight,Device> Ah_phi_ff;
124 Kokkos::View<ScalarFieldPlanes**,Kokkos::LayoutRight,Device> Ah_rho_ff;
125 Kokkos::View<VectorFieldPlanes**,Kokkos::LayoutRight,Device> dAs_phi_ff;
126 Kokkos::View<VectorFieldPlanes**,Kokkos::LayoutRight,Device> dAs_rho_ff;
127 Kokkos::View<ScalarFieldPlanes**,Kokkos::LayoutRight,Device> As_phi_ff;
128 Kokkos::View<ScalarFieldPlanes**,Kokkos::LayoutRight,Device> As_rho_ff;
129 Kokkos::View<ScalarFieldPlanes**,Kokkos::LayoutRight,Device> Ah_cv_phi_ff;
130 Kokkos::View<ScalarFieldPlanes**,Kokkos::LayoutRight,Device> Epar_em_phi_ff;
131 Kokkos::View<ScalarFieldPlanes**,Kokkos::LayoutRight,Device> Epar_em_rho_ff;
136 Kokkos::View<FieldXGCa**,Kokkos::LayoutRight,Device>
E_rho;
137 Kokkos::View<double*,Kokkos::LayoutRight,Device>
dpot;
157 E00_ff_h(
"E00_ff_h",
nnode),
167 Ah_h(
"Ah_h",4,
nnode),
168 As_h(
"As_h",4,
nnode),
171 dpot_ff_h(
"dpot_ff_h",
nnode),
179 E_phi_ff(
"E_phi_ff",0,0),
180 E_rho_ff(
"E_rho_ff",0,0),
183 ddpotdt_phi(
"ddpotdt_phi",0,0),
186 dAs_phi_ff(
"dAs_phi_ff",0,0),
187 dAs_rho_ff(
"dAs_rho_ff",0,0),
188 dAh_phi_ff(
"dAh_phi_ff",0,0),
189 dAh_rho_ff(
"dAh_rho_ff",0,0),
190 As_phi_ff(
"As_phi_ff",0,0),
191 As_rho_ff(
"As_rho_ff",0,0),
192 Ah_phi_ff(
"Ah_phi_ff",0,0),
193 Ah_rho_ff(
"Ah_rho_ff",0,0),
194 Ah_cv_phi_ff(
"Ah_cv_phi_ff",0,0),
195 Epar_em_phi_ff(
"Epar_em_phi_ff",0,0),
196 Epar_em_rho_ff(
"Epar_em_rho_ff",0,0),
209 set_rho_ff_pointers(
nrho,
nnode,
dpot_h.data(), dpot_ff_h.data(), pot.rho_ff_h.data(),
E.rho_ff_h.data()
211 , Ah_h.data(), Ah.rho_ff_h.data(), dAh.rho_ff_h.data(), As_h.data(), As.rho_ff_h.data(), dAs.rho_ff_h.data(), Epar_em.rho_ff_h.data()
221 void copy_phi_fields_to_device(){
223 Kokkos::deep_copy(E_phi_ff,
E.phi_ff_h);
226 Kokkos::deep_copy(ddpotdt_phi, ddpotdt.phi_ff_h);
227 Kokkos::resize(E00_ff,
nnode);
228 Kokkos::deep_copy(E00_ff, E00_ff_h);
236 Kokkos::resize(Epar_em_phi_ff,
nphi,
nnode);
237 Kokkos::deep_copy(dAs_phi_ff, dAs.phi_ff_h);
238 Kokkos::deep_copy(dAh_phi_ff, dAh.phi_ff_h);
239 Kokkos::deep_copy(As_phi_ff, As.phi_ff_h);
240 Kokkos::deep_copy(Ah_phi_ff, Ah.phi_ff_h);
241 Kokkos::deep_copy(Ah_cv_phi_ff, Ah_cv.phi_ff_h);
242 Kokkos::deep_copy(Epar_em_phi_ff, Epar_em.phi_ff_h);
247 void deallocate_phi_fields_on_device(){
248 Kokkos::resize(E_phi_ff,0,0);
250 Kokkos::resize(ddpotdt_phi,0,0);
251 Kokkos::resize(E00_ff, 0);
254 Kokkos::resize(dAs_phi_ff,0,0);
255 Kokkos::resize(dAh_phi_ff,0,0);
256 Kokkos::resize(As_phi_ff,0,0);
257 Kokkos::resize(Ah_phi_ff,0,0);
258 Kokkos::resize(Ah_cv_phi_ff,0,0);
259 Kokkos::resize(Epar_em_phi_ff,0,0);
266 Kokkos::deep_copy(E_rho_ff,
E.rho_ff_h);
272 Kokkos::resize(Epar_em_rho_ff,
nnode,
nrho+1);
273 Kokkos::deep_copy(dAs_rho_ff, dAs.rho_ff_h);
274 Kokkos::deep_copy(dAh_rho_ff, dAh.rho_ff_h);
275 Kokkos::deep_copy(As_rho_ff, As.rho_ff_h);
276 Kokkos::deep_copy(Ah_rho_ff, Ah.rho_ff_h);
277 Kokkos::deep_copy(Epar_em_rho_ff, Epar_em.rho_ff_h);
283 Kokkos::resize(E_rho_ff,0,0);
285 Kokkos::resize(dAs_rho_ff,0,0);
286 Kokkos::resize(dAh_rho_ff,0,0);
287 Kokkos::resize(As_rho_ff,0,0);
288 Kokkos::resize(Ah_rho_ff,0,0);
289 Kokkos::resize(Epar_em_rho_ff,0,0);
296 void copy_Ah_cv_to_device(){
298 Kokkos::deep_copy(Ah_cv_phi_ff, Ah_cv.phi_ff_h);
302 void deallocate_Ah_cv_on_device(){
303 Kokkos::resize(Ah_cv_phi_ff,0,0);
306 void copy_Ah_phi_ff_to_device(){
308 Kokkos::deep_copy(Ah_phi_ff, Ah.phi_ff_h);
312 void deallocate_Ah_phi_ff_on_device(){
313 Kokkos::resize(Ah_phi_ff,0,0);
317 void copy_Ah_rho_ff_to_device(){
319 Kokkos::deep_copy(Ah_rho_ff, Ah.rho_ff_h);
323 void deallocate_Ah_rho_ff_on_device(){
324 Kokkos::resize(Ah_rho_ff,0,0);
330 Kokkos::resize(dpot_ff,
nnode);
331 Kokkos::deep_copy(dpot_ff, dpot_ff_h);
336 Kokkos::resize(dpot_ff,0);
347 Kokkos::resize(
E_rho,0,0);
358 Kokkos::resize(
dpot,0);
void set_rho_pointers(int nrho, int n, double *dpot, FieldXGCa *E_rho)
void deallocate_dpot_on_device()
Definition: electric_field.hpp:357
Definition: electric_field.hpp:10
ElectricField(NLReader::NamelistReader &nlr, int nnode_in, int nplanes_in, int nrho_in)
Definition: electric_field.hpp:145
T get(const string ¶m, const T default_val, int val_ind=0)
Definition: NamelistReader.hpp:353
double V[3][2]
Definition: electric_field.hpp:11
GridField(int nrho, int nnode)
Definition: electric_field.hpp:65
int nrho
Definition: electric_field.hpp:77
Definition: NamelistReader.hpp:163
Definition: electric_field.hpp:72
Definition: electric_field.hpp:20
void copy_dpot_to_device()
Definition: electric_field.hpp:351
double S[2]
Definition: electric_field.hpp:21
Kokkos::View< FieldXGCa **, Kokkos::LayoutRight, Device > E_rho
Definition: electric_field.hpp:136
Definition: electric_field.hpp:48
ElectricField()
Definition: electric_field.hpp:141
void use_namelist(const string &namelist)
Definition: NamelistReader.hpp:322
void deallocate_rho_fields_on_device()
Definition: electric_field.hpp:346
Definition: electric_field.hpp:25
Kokkos::View< double *, Kokkos::LayoutRight, HostType > dpot_h
Definition: electric_field.hpp:107
double E[2]
Definition: electric_field.hpp:26
void copy_rho_fields_to_device()
Definition: electric_field.hpp:340
Definition: electric_field.hpp:15
bool turb_efield
Whether the electric field is turbulent?
Definition: electric_field.hpp:80
int nphi
Definition: electric_field.hpp:76
int nnode
Definition: electric_field.hpp:75
Kokkos::View< T **, Kokkos::LayoutRight, HostType > rho_h
Definition: electric_field.hpp:63
GridFieldOpts
Definition: electric_field.hpp:40
GridField< FieldXGCa > E
Definition: electric_field.hpp:106
double V[2][2]
Definition: electric_field.hpp:16
Kokkos::View< double *, Kokkos::LayoutRight, Device > dpot
Definition: electric_field.hpp:137