XGCa
electric_field.hpp
Go to the documentation of this file.
1 #ifndef ELECTRIC_FIELD_HPP
2 #define ELECTRIC_FIELD_HPP
3 #include "space_settings.hpp"
4 #include "NamelistReader.hpp"
5 #include "grid.hpp"
6 #include "grid_field_pack.hpp"
7 #include "timer_macro.hpp"
8 #include "smoothing.hpp"
9 #include "get_potential_grad.hpp"
10 #include "plane_field_gatherer.hpp"
12 #ifdef SONIC_GK
13 #include "get_sonic_fields.hpp"
14 #endif
15 #include "perturbed_B_field.hpp"
16 #include "get_dAdt_guess.hpp"
17 
18 template<KinType KT, PhiInterpType PIT, MarkerType MT, MagneticFieldMode MFM>
20 
21 template<KinType KT> struct getGyroVecFldType;
22 template<> struct getGyroVecFldType<KinType::DriftKin>{ using t = EfieldType; };
23 template<> struct getGyroVecFldType<KinType::GyroKin>{ using t = EfieldGyroType; };
24 
25 template<KinType KT> struct getGyroScaFldType;
26 template<> struct getGyroScaFldType<KinType::DriftKin>{ using t = PotType; };
27 template<> struct getGyroScaFldType<KinType::GyroKin>{ using t = PotGyroType; };
28 
29 // XGC1
30 
32 template<KinType KT, MarkerType MT>
34  using t = Pack<Labeled<typename getGyroVecFldType<KT>::t, Label::E>,
40 };
41 
43 template<KinType KT, MarkerType MT>
45  using t = Pack<Labeled<typename getGyroVecFldType<KT>::t, Label::E>>;
46 };
47 
49 template<KinType KT>
51  using t = Pack<Labeled<typename getGyroVecFldType<KT>::t, Label::E>,
54 };
55 
56 // XGCA
57 template<KinType KT, MarkerType MT>
59 # ifdef SONIC_GK
60  using t = Pack<Labeled<Efield2DGyroType, Label::E>,
64 # else
65  using t = Pack<Labeled<Efield2DGyroType, Label::E>>;
66 # endif
67 };
68 
69 
70 // Fortran calls
73 
74 // Electric field class
75 template<class Device>
76 struct ElectricField {
77 
78  // Dimensions
79  int nnode;
80  int nphi;
81 
82  // Gyromatrix info (to be moved soon)
83  int nrho;
84 
85  // Optimization options
87 
88  // Field variables
89  bool turb_efield;
90  bool E00_efield;
92 
93  // Host Views
96 
97  //For EM
109 
112 //#ifdef XGC1
114 //#else
115 //# ifdef SONIC_GK
119 //# endif
120 //#endif
124  View<double***,CLayout, HostType> save_dpot0; // Used for adiabatic response
125  View<double***,CLayout, HostType> save_dpot; // Used for adiabatic response
126  View<double***,CLayout, HostType> dpotsave; // Used for split-weight scheme
127  View<double*,CLayout, HostType> dpot_es; // Used for a diagnostic
128 
129  View<double*,CLayout, HostType> pot0m;
130  View<double*,CLayout, HostType> pot00_1d;
131 
132  // Host View for the adjustable loop voltage current drive
134 
135  // Solver boundaries; These are (shallow) copies so that they aren't needed as arguments to get_potential_grid etc. Should be removed in refactor
138 
139  // Default constructor
141 
142  ElectricField(NLReader::NamelistReader& nlr, const Grid<DeviceType>& grid, int nrho_in, bool es_reduced_deltaf_setup=false);
143 
144  void write_checkpoint_files(const Grid<DeviceType>& grid, const DomainDecomposition<DeviceType>& pol_decomp, bool loop_voltage_on, bool use_split_weight_scheme, bool em, const XGC_IO_Stream& stream);
145 
146  void read_checkpoint_files(const Grid<DeviceType>& grid, const DomainDecomposition<DeviceType>& pol_decomp, bool loop_voltage_on, bool use_split_weight_scheme, bool em, const XGC_IO_Stream& stream, const XGC_IO_Stream& em_stream);
147 
148 
149  /**************************************************/
150  /************ Copy to GridFieldPack *************/
151  /**************************************************/
152  template<MarkerType MT, MagneticFieldMode MFM>
154 
155  // Set push type here for now
157  gfp_push_type gfpack(turb_efield);
158 
159  GPTLstart("GAT_FIELD_INFO");
160  if(pol_decomp.decompose_fields){
161  if(near_field){
162  // Gathering the "near field", defined as the field decomposition region that contains this rank's
163  // global domain decomposition
164  int local_pid = pol_decomp.field_decomp.find_domain_owner(pol_decomp.plane_index, grid.nplanes, pol_decomp.node_offset, grid.nnode);
165  gfpack.phi_offset = pol_decomp.field_decomp.all_first_plane(local_pid);
166  gfpack.node_offset = pol_decomp.field_decomp.all_first_node(local_pid);
167  }else{
168  gfpack.phi_offset = pol_decomp.field_decomp.first_plane;
169  gfpack.node_offset = pol_decomp.field_decomp.first_node;
170  }
171  }
172  PlaneFieldGatherer pfg(pol_decomp, grid, near_field);
173 
175  if(ddpotdt.f.size()>0) pfg.gather_phi_ff_on_device(ddpotdt.f, gfpack.template get<Label::ddpotdt>().f);
176  grid_field_copy(gfpack.template get<Label::E00>(), E00_ff_h); // No gather_phi needed due to axisymmetry
177  }
178 
180  // Allocate temporary views
181  GPTLstart("GET_POT_GRAD_ALLOC_VIEWS");
182  int n_input_field_planes = pot0_h.nphi();
183  bool gradient_requested = true;
184  bool gyroaverage_requested = false;
185  GetPotentialGradTemp<DeviceType, DeviceType> gpg_tmp(sml, grid, pol_decomp, magnetic_field, pbd0, n_input_field_planes, gradient_requested, gyroaverage_requested);
186  GPTLstop("GET_POT_GRAD_ALLOC_VIEWS");
187 
188  // Whether to ignore dpot
189  bool ignore_poloidal_dpot = !(turb_efield);
190  bool use_field00 = E00_efield;
191  bool potential_is_requested = false; // Not used in push
193  pfg.calculate_phi_ff_on_device(sml,grid, gpg_tmp, my_subview(dpot_h.f, 2), pot0_h, gfpack.template get<Label::E>(), unused_pot, potential_is_requested, use_field00, ignore_poloidal_dpot);
194  if constexpr(MFM==MagneticFieldMode::Electromagnetic){
196  pfg.calculate_phi_ff_on_device(sml,grid, gpg_tmp, my_subview(Ah_h.f, 2), pot0_em_h, gfpack.template get<Label::dAh>(), gfpack.template get<Label::Ah>());
197  if(As.f.size()>0) pfg.calculate_phi_ff_on_device(sml,grid, gpg_tmp, my_subview(As_h.f, 2), pot0_em_h, gfpack.template get<Label::dAs>(), gfpack.template get<Label::As>());
198  }
199  }else{
200  pfg.gather_phi_ff_on_device(E.f, gfpack.template get<Label::E>().f);
201  if constexpr(MFM==MagneticFieldMode::Electromagnetic){
202  pfg.gather_phi_ff_on_device(dAh.f, gfpack.template get<Label::dAh>().f);
203  pfg.gather_phi_ff_on_device(Ah.f, gfpack.template get<Label::Ah>().f);
204  if(dAs.f.size()>0) pfg.gather_phi_ff_on_device(dAs.f, gfpack.template get<Label::dAs>().f);
205  if(As.f.size()>0) pfg.gather_phi_ff_on_device(As.f, gfpack.template get<Label::As>().f);
206  }
207  }
208  if constexpr(MFM==MagneticFieldMode::Electromagnetic){
209  if(dAdt_guess.f.size()>0) pfg.gather_phi_ff_on_device(dAdt_guess.f, gfpack.template get<Label::dAdt_guess>().f);
210  }
211  GPTLstop("GAT_FIELD_INFO");
212 
214  // Copy axisymmetric loop voltage to temporary device-view
215  ScalarGridField loop_voltage("loop_voltage",loop_voltage_h.nnode());
216  Kokkos::deep_copy(loop_voltage.f,loop_voltage_h.f);
218  ff.cnvt_grid_real2ff(grid,loop_voltage,gfpack.loop_voltage);
219 
220  return std::make_unique<gfp_push_type>(gfpack);
221  }
222 
223  template<MarkerType MT, MagneticFieldMode MFM>
226  gfp_push_type gfpack(turb_efield);
227 
228  GPTLstart("Copy_rho_ff_fields_to_device");
229  grid_field_copy(gfpack.template get<Label::E>(), E);
230  if constexpr(MFM==MagneticFieldMode::Electromagnetic){
231  grid_field_copy(gfpack.template get<Label::dAs>(), dAs);
232  grid_field_copy(gfpack.template get<Label::dAh>(), dAh);
233  grid_field_copy(gfpack.template get<Label::As>(), As);
234  grid_field_copy(gfpack.template get<Label::Ah>(), Ah);
235  grid_field_copy(gfpack.template get<Label::dAdt_guess>(), dAdt_guess);
236  }
237  GPTLstop("Copy_rho_ff_fields_to_device");
238 
239  // Loop voltage is identical for gyrokinetic and drift-kinetic species,
240  // but different between XGC1 and XGCa
242  // Copy axisymmetric loop voltage to temporary device-view
243  ScalarGridField loop_voltage("loop_voltage",loop_voltage_h.nnode());
244  Kokkos::deep_copy(loop_voltage.f,loop_voltage_h.f);
246  ff.cnvt_grid_real2ff(grid,loop_voltage,gfpack.loop_voltage);
247 
248  return std::make_unique<gfp_push_type>(gfpack);
249  }
250 
251 #ifdef XGC1
252  // Resizes allocations for large arrays that have a phi dimension (i.e used for electron push)
253  GridFieldPackPtr copy_push_fields_to_device(KinType kintype_in, MarkerType markertype_in, const Simulation<DeviceType>& sml, const DomainDecomposition<DeviceType>& pol_decomp, const MagneticField<DeviceType>& magnetic_field, const Grid<DeviceType>& grid, bool near_field=false) const{
254  if(!sml.explicit_electromagnetic){
255  if(markertype_in==MarkerType::ReducedDeltaF){
256  if(kintype_in==DriftKin){
257  return copy_push_fields_to_device_drift_kin_XGC1<MarkerType::ReducedDeltaF, MagneticFieldMode::Electrostatic>(sml, pol_decomp, magnetic_field, grid, near_field);
258  }else{
259  return copy_push_fields_to_device_gyro_kin_XGC1<MarkerType::ReducedDeltaF, MagneticFieldMode::Electrostatic>(sml, pol_decomp, magnetic_field, grid, near_field);
260  }
261  }else{
262  if(kintype_in==DriftKin){
263  return copy_push_fields_to_device_drift_kin_XGC1<MarkerType::TotalF, MagneticFieldMode::Electrostatic>(sml, pol_decomp, magnetic_field, grid, near_field);
264  }else{
265  return copy_push_fields_to_device_gyro_kin_XGC1<MarkerType::TotalF, MagneticFieldMode::Electrostatic>(sml, pol_decomp, magnetic_field, grid, near_field);
266  }
267  }
268  }else{
269  if(markertype_in==MarkerType::ReducedDeltaF){
270  if(kintype_in==DriftKin){
271  return copy_push_fields_to_device_drift_kin_XGC1<MarkerType::ReducedDeltaF, MagneticFieldMode::Electromagnetic>(sml, pol_decomp, magnetic_field, grid, near_field);
272  }else{
273  return copy_push_fields_to_device_gyro_kin_XGC1<MarkerType::ReducedDeltaF, MagneticFieldMode::Electromagnetic>(sml, pol_decomp, magnetic_field, grid, near_field);
274  }
275  }else{
276  if(kintype_in==DriftKin){
277  return copy_push_fields_to_device_drift_kin_XGC1<MarkerType::TotalF, MagneticFieldMode::Electromagnetic>(sml, pol_decomp, magnetic_field, grid, near_field);
278  }else{
279  return copy_push_fields_to_device_gyro_kin_XGC1<MarkerType::TotalF, MagneticFieldMode::Electromagnetic>(sml, pol_decomp, magnetic_field, grid, near_field);
280  }
281  }
282  }
283  }
284 #else
285  // Resizes allocations for large arrays that have a phi dimension (i.e used for electron push)
286  GridFieldPackPtr copy_push_fields_to_device(KinType kintype_in, MarkerType markertype_in, const Simulation<DeviceType>& sml, const DomainDecomposition<DeviceType>& pol_decomp, const MagneticField<DeviceType>& magnetic_field, const Grid<DeviceType>& grid, bool near_field=false) const{
287  // Re-initialize new gridpack - deallocates whatever Views were already allocated
289  gfp_push_type gfpack(turb_efield);
290 
291  grid_field_copy(gfpack.template get<Label::E>(), E);
292 # ifdef SONIC_GK
293  grid_field_copy(gfpack.template get<Label::dEr_B2>, dEr_B2);
294  grid_field_copy(gfpack.template get<Label::dEz_B2>, dEz_B2);
295  grid_field_copy(gfpack.template get<Label::du2_E>, du2_E);
296 # endif
297  // Copy axisymmetric loop voltage to temporary device-view
298  ScalarGridField loop_voltage("loop_voltage",loop_voltage_h.nnode());
299  Kokkos::deep_copy(loop_voltage.f,loop_voltage_h.f);
300  grid_field_copy(gfpack.loop_voltage,loop_voltage);
301 
302  //grid_field_copy(gfpack.loop_voltage,loop_voltage_h);
303  return std::make_unique<gfp_push_type>(gfpack);
304  }
305 #endif
306 
317  GPTLstart("GET_AH_RHO_FF_EXCL_DESTR"); // Timer excludes the destructors which are non-negligible
318 
319  // Allocate temporary views
320  GPTLstart("GET_AH_RHO_FF_ALLOC_VIEWS");
321  int n_input_field_planes = Ah_h.nphi();
322  bool gradient_requested = false;
323  bool gyroaverage_requested = true;
324  species.gyro_avg_matrices.copy_to_device_if_not_resident();
325  GetPotentialGradTemp<DeviceType, HostType> tmp(sml, grid, pol_decomp, magnetic_field, pbd0, n_input_field_planes, gradient_requested, gyroaverage_requested, species.gyro_avg_matrices);
326  GPTLstop("GET_AH_RHO_FF_ALLOC_VIEWS");
327 
328  /****************************************/
329  // Calculation of the Hamiltonian vector potential A_h
330  /****************************************/
332  FieldArgs gpg_field_args(Ah_h.unmanaged());
333  gpg_field_args.request_potential(Ah);
334  get_field_grad(grid, gpg_field_args, tmp);
335 
336  GPTLstop("GET_AH_RHO_FF_EXCL_DESTR");
337 
338  species.gyro_avg_matrices.deallocate_device_matrices_if_not_resident();
339  }
340 
352  GPTLstart("GET_POT_GRAD_EXCL_DESTR"); // Timer excludes the destructors which are non-negligible
353 
354  // Allocate temporary views
355  GPTLstart("GET_POT_GRAD_ALLOC_VIEWS");
356  int n_input_field_planes = dpot_h.nphi();
357  bool gradient_requested = true;
358  bool gyroaverage_requested = true;
359  if(gyroaverage_requested) species.gyro_avg_matrices.copy_to_device_if_not_resident();
360  GetPotentialGradTemp<DeviceType, HostType> tmp(sml, grid, pol_decomp, magnetic_field, pbd0, n_input_field_planes, gradient_requested, gyroaverage_requested, species.gyro_avg_matrices);
361  GPTLstop("GET_POT_GRAD_ALLOC_VIEWS");
362 
363  /****************************************/
364  // Calculation of the electric potential E
365  /****************************************/
366  GPTLstart("GET_POT_GRAD_PHI");
367 
369  FieldArgs gpg_field_args(dpot_h.unmanaged(), !(turb_efield));
370 
371  // Set up E00
372  if(E00_efield){
373  gpg_field_args.field00 = Field00<DeviceType>(pot0_h, sml.grad_psitheta);
374  gpg_field_args.field00.calculate_gradient(grid, tmp.grad_matrices);
375  }
376  // Write results of E00
377  if(sml.reduced_deltaf && sml.electron_on) gpg_field_args.field00.set_field(grid, tmp.ff, E00_ff_h.f);
378 
379  // Request potential and/or gradient outputs
380  // XGC1 algorithm uses potential but XGCa doesnt
381  if(!sml.is_XGCa) gpg_field_args.request_potential(pot);
382  gpg_field_args.request_gradient(E);
383 
385  View<double**,CLayout, DeviceType> para_grad;
386  if(need_para_grad){
387  // dAdt_guess takes parallel gradient as an input, but E is already gyroaveraged and field following
388  // So save the simple parallel gradient here
389  para_grad = View<double**,CLayout, DeviceType>(NoInit("para_grad"), 2, grid.nnode);
390  gpg_field_args.request_para_grad(para_grad);
391  }
392 
393  // Get potentials
394  get_field_grad(grid, gpg_field_args, tmp);
395 
396  GPTLstop("GET_POT_GRAD_PHI");
397 
398  if(sml.explicit_electromagnetic){
399  GPTLstart("GET_EM_PARA");
401  get_dAdt_guess(sml, grid, pol_decomp, magnetic_field, smoothing, perturbed_B_field, tmp, para_grad, AbdH, dAdt_guess);
402  }
403  GPTLstop("GET_EM_PARA");
404 
405 
406  GPTLstart("GET_POT_GRAD_APAR");
407 
408  /****************************************/
409  // Calculation of the Hamiltonian vector potential A_h
410  /****************************************/
411  gpg_field_args = FieldArgs(Ah_h.unmanaged());
412  gpg_field_args.request_potential(Ah);
413  gpg_field_args.request_gradient(dAh);
414  get_field_grad(grid, gpg_field_args, tmp);
415 
416  /****************************************/
417  // Calculation of the symplectic vector potential A_s
418  /****************************************/
419  if (sml.em_mixed_variable){
420  gpg_field_args = FieldArgs(As_h.unmanaged());
421  gpg_field_args.request_potential(As);
422  gpg_field_args.request_gradient(dAs);
423  get_field_grad(grid, gpg_field_args, tmp);
424  }
425 
426  /****************************************/
427  // Calculation of the Hamiltonian vector potential A_h for the control-variate method
428  /****************************************/
429  if (sml.em_control_variate){
430  TIMER("GET_POT_APAR_CV",
431  get_field_Ah_cv_ff(grid, pol_decomp, Ah_cv_h, Ah_cv) );
432  }
433  GPTLstop("GET_POT_GRAD_APAR");
434  }
435 
436 #ifdef SONIC_GK
437  GPTLstart("GET_POT_GRAD_SONIC");
438  View<double*,CLayout,HostType> Er_B2_h("Er_B2_h",grid.nnode);
439  View<double*,CLayout,HostType> Ez_B2_h("Ez_B2_h",grid.nnode);
440  View<double*,CLayout,HostType> u2_E_h("u2_E_h",grid.nnode);
441 
442  TIMER("GET_POT_SONIC",
443  get_sonic_fields(grid, E, Er_B2_h, Ez_B2_h, u2_E_h) );
444 
445  gpg_field_args = FieldArgs(Er_B2_h);
446  gpg_field_args.request_gradient(dEr_B2);
447  get_field_grad(grid, gpg_field_args, tmp);
448 
449  gpg_field_args = FieldArgs(Ez_B2_h);
450  gpg_field_args.request_gradient(dEz_B2);
451  get_field_grad(grid, gpg_field_args, tmp);
452 
453  gpg_field_args = FieldArgs(u2_E_h);
454  gpg_field_args.request_gradient(du2_E);
455  get_field_grad(grid, gpg_field_args, tmp);
456 
457  GPTLstop("GET_POT_GRAD_SONIC");
458 #endif
459 
460  species.gyro_avg_matrices.deallocate_device_matrices_if_not_resident();
461 
462  GPTLstop("GET_POT_GRAD_EXCL_DESTR");
463  }
464 
466  nlr.use_namelist("sml_param");
467  int field_n_rho = nlr.get<int>("sml_grid_nrho", 6);
468 
469 #ifdef EXPLICIT_EM
470  int n_fields = 3 + 1; // E, dAs, dAh, + scalars As,Ah
471 #else
472  int n_fields = 1;
473 #endif
474  double host_field_GB_per_vertex = (53 + 8*grid.nplanes + 11*(field_n_rho + 1))*8*BYTES_TO_GB;
475  double cpu_memory_usage = grid.nnode*host_field_GB_per_vertex;
476 
477  double device_field_GB_per_vertex = std::max(n_fields*8*grid.nplanes, n_fields*8*(field_n_rho+1))*8*BYTES_TO_GB;
478  double gpu_memory_usage = grid.nnode*device_field_GB_per_vertex;
479 
480  MemoryPrediction memory_prediction{"Collisions", cpu_memory_usage, gpu_memory_usage};
481 
482  return memory_prediction;
483  }
484 };
485 
486 #endif
Definition: boundary.hpp:83
bool decompose_fields
Whether to decompose fields.
Definition: domain_decomposition.hpp:91
FieldDecomposition< Device > field_decomp
Definition: domain_decomposition.hpp:92
int plane_index
Offset of local plane.
Definition: domain_decomposition.hpp:88
int node_offset
Offset of first mesh node belonging to this MPI rank.
Definition: domain_decomposition.hpp:95
Definition: field_following_coordinates.hpp:9
void cnvt_grid_real2ff(const Grid< DeviceType > &grid, const View< double **, CLayout, DeviceType > &input, const View< double **, Kokkos::LayoutRight, DeviceType > &output) const
Definition: field_following_coordinates.hpp:169
Projection< HostType > half_plane_ff
Definition: grid.hpp:194
int nplanes
Number of planes.
Definition: grid.hpp:175
int nnode
Number of grid nodes.
Definition: grid.hpp:174
Definition: magnetic_field.hpp:12
Definition: NamelistReader.hpp:193
T get(const string &param, const T default_val, int val_ind=0)
Definition: NamelistReader.hpp:386
void use_namelist(const string &namelist, Options required=Required)
Definition: NamelistReader.hpp:360
Definition: perturbed_B_field.hpp:12
Definition: plane_field_gatherer.hpp:9
void calculate_phi_ff_on_device(const Simulation< DeviceType > &sml, const Grid< DeviceType > &grid, GetPotentialGradTemp< DeviceType, DeviceType > &tmp, const View< Field< VarType::Scalar, PhiInterpType::None > *, CLayout, HostType > &dpot_h, const GT0 &pot0_h, GT &phi_ff, GT2 &pot_phi_ff, bool potential_is_requested=true, bool use_field00=false, bool ignore_poloidal_dpot=false)
Definition: plane_field_gatherer.hpp:117
void gather_phi_ff_on_device(View< FT **, CLayout, HostType > &tmp, View< FT *, CLayout, HostType > &tmp_full, const T_h &rho_ff_h, View< FT **, CLayout, DeviceType > &phi_ff)
Definition: plane_field_gatherer.hpp:197
Definition: sml.hpp:10
bool reduced_deltaf
True if any species is reduced_deltaf. Will be removed.
Definition: sml.hpp:41
bool grad_psitheta
Definition: sml.hpp:91
static constexpr bool explicit_electromagnetic
Equivalent to the preprocessor flag for now.
Definition: sml.hpp:30
bool em_control_variate
Switch for use of control variate method.
Definition: sml.hpp:69
PullbackMethod em_pullback_method
Electrostatic: mixed-variable pullback with dA_s/dt=0,.
Definition: sml.hpp:70
static constexpr bool is_XGCa
Equivalent to the preprocessor flag for now.
Definition: sml.hpp:22
bool electron_on
Use kinetic electrons.
Definition: sml.hpp:57
bool em_mixed_variable
Switch for use of mixed-variable formulation.
Definition: sml.hpp:68
Definition: species.hpp:75
GyroAverageMatrices< Device > gyro_avg_matrices
Definition: species.hpp:151
Definition: xgc_io.hpp:24
constexpr double BYTES_TO_GB
Definition: constants.hpp:13
void set_rho_pointers(int n, Field< VarType::Scalar, PhiInterpType::None > *dpot)
void set_rho_ff_pointers(int n, Field< VarType::Scalar, PhiInterpType::None > *dpot, Field< VarType::Scalar, PhiInterpType::Planes > *dpot_ff)
void get_dAdt_guess(const Simulation< DeviceType > &sml, const Grid< DeviceType > &grid, const DomainDecomposition< DeviceType > &pol_decomp, const MagneticField< DeviceType > &magnetic_field, Smoothing &smoothing, const PerturbedBField< DeviceType > &perturbed_B_field, GetPotentialGradTemp< DeviceType, HostType > &tmp, const View< double **, CLayout, DeviceType > &field_para, const Boundary &filter_bndry, const GridField< HostType, VarType::Scalar, PhiInterpType::Planes, TorType::OnePlane, KinType::GyroKin > &dAdt_guess)
Definition: get_dAdt_guess.cpp:77
void get_field_Ah_cv_ff(const Grid< DeviceType > &grid, const DomainDecomposition< DeviceType > &pol_decomp, const GridField< HostType, VarType::Scalar, PhiInterpType::None, TorType::MultiplePlanes, KinType::DriftKin > &Ah_cv_h, const GridField< HostType, VarType::Scalar, PhiInterpType::Planes, TorType::OnePlane, KinType::DriftKin > &Ah_cv_ff)
Definition: get_potential_grad.cpp:6
void get_field_grad(const Grid< DeviceType > &grid, GetPotGradFieldArgs< DeviceIn, DeviceOut, VT, PIT, TT, KT > &args, GetPotentialGradTemp< DeviceType, DeviceOut > &tmp)
Definition: get_potential_grad.cpp:389
void get_sonic_fields(const Grid< DeviceType > &grid, const GridField< HostType, vec2d_if_axisym< PIT_GLOBAL >(), PIT_GLOBAL, TorType::OnePlane, KinType::GyroKin > &E, View< double *, CLayout, HostType > &Er_B2_h, View< double *, CLayout, HostType > &Ez_B2_h, View< double *, CLayout, HostType > &u2_E_h)
constexpr PhiInterpType PIT_GLOBAL
Definition: globals.hpp:105
KinType
Definition: globals.hpp:88
@ GyroKin
Definition: globals.hpp:90
@ DriftKin
Definition: globals.hpp:89
MarkerType
Definition: globals.hpp:110
PhiInterpType
Definition: globals.hpp:95
GridField< DeviceType, VarType::Scalar, PIT_GLOBAL, TorType::OnePlane, KinType::GyroKin > PotGyroType
Definition: grid_field.hpp:490
GridField< DeviceType, VarType::Vector, PhiInterpType::Planes, TorType::OnePlane, KinType::GyroKin > EfieldGyroType
Definition: grid_field.hpp:488
GridField< DeviceType, VarType::Scalar, PIT_GLOBAL, TorType::MultiplePlanes, KinType::DriftKin > PotType
Definition: grid_field.hpp:486
void grid_field_copy(T &dest, const T &src)
Definition: grid_field.hpp:496
GridField< DeviceType, VarType::Vector, PhiInterpType::Planes, TorType::MultiplePlanes, KinType::DriftKin > EfieldType
Definition: grid_field.hpp:484
std::unique_ptr< GridFieldPackGeneric > GridFieldPackPtr
Definition: grid_field_pack.hpp:21
@ dAdt_guess
@ loop_voltage
Kokkos::View< T *, Kokkos::LayoutRight, Device > my_subview(const Kokkos::View< T ****, Kokkos::LayoutRight, Device > &view, int i, int j, int k)
Definition: my_subview.hpp:8
Definition: magnetic_field.F90:1
Kokkos::ViewAllocateWithoutInitializing NoInit
Definition: space_settings.hpp:69
Definition: electric_field.hpp:76
View< double ***, CLayout, HostType > save_dpot
Definition: electric_field.hpp:125
GridField< HostType, vec2d_if_axisym< PIT_GLOBAL >), PIT_GLOBAL, TorType::OnePlane, KinType::GyroKin > dAh
Definition: electric_field.hpp:100
View< double ***, CLayout, HostType > dpotsave
Definition: electric_field.hpp:126
GridField< HostType, VarType::Scalar, PhiInterpType::Planes, TorType::OnePlane, KinType::GyroKin > dAdt_guess
Definition: electric_field.hpp:108
GridFieldPackPtr copy_push_fields_to_device_drift_kin_XGC1(const Simulation< DeviceType > &sml, const DomainDecomposition< DeviceType > &pol_decomp, const MagneticField< DeviceType > &magnetic_field, const Grid< DeviceType > &grid, bool near_field=false) const
Definition: electric_field.hpp:153
GridField< HostType, VarType::Scalar, PhiInterpType::None, TorType::MultiplePlanes, KinType::DriftKin > dpot_h
Definition: electric_field.hpp:121
View< double *, CLayout, HostType > pot0m
n=0 component of the electrostatic potential before smoothing
Definition: electric_field.hpp:129
void get_potential_grad(const Simulation< DeviceType > &sml, const Grid< DeviceType > &grid, const DomainDecomposition< DeviceType > &pol_decomp, const MagneticField< DeviceType > &magnetic_field, Smoothing &smoothing, const PerturbedBField< DeviceType > &perturbed_B_field, Species< DeviceType > &species)
Definition: electric_field.hpp:351
GridField< HostType, VarType::Vector2D, PIT_GLOBAL, TorType::OnePlane, KinType::DriftKin > E00_ff_h
Radial electric field from in field-following format.
Definition: electric_field.hpp:94
GridField< HostType, vec2d_if_axisym< PIT_GLOBAL >), PIT_GLOBAL, TorType::OnePlane, KinType::GyroKin > dAs
Definition: electric_field.hpp:104
Boundary AbdH
Definition: electric_field.hpp:136
void write_checkpoint_files(const Grid< DeviceType > &grid, const DomainDecomposition< DeviceType > &pol_decomp, bool loop_voltage_on, bool use_split_weight_scheme, bool em, const XGC_IO_Stream &stream)
GridField< HostType, VarType::Vector2D, PIT_GLOBAL, TorType::OnePlane, KinType::GyroKin > dEr_B2
Gradient of Er/B^2.
Definition: electric_field.hpp:116
GridField< HostType, VarType::Scalar, PIT_GLOBAL, TorType::OnePlane, KinType::GyroKin > Ah
Definition: electric_field.hpp:101
View< double *, CLayout, HostType > dpot_es
Definition: electric_field.hpp:127
int nnode
Definition: electric_field.hpp:79
GridField< HostType, VarType::Scalar, PhiInterpType::None, TorType::MultiplePlanes, KinType::DriftKin > As_h_backup
Definition: electric_field.hpp:103
GridField< HostType, VarType::Scalar, PIT_GLOBAL, TorType::OnePlane, KinType::GyroKin > As
Definition: electric_field.hpp:105
View< double *, CLayout, HostType > pot00_1d
1D flux-surface averaged potential
Definition: electric_field.hpp:130
ElectricField(NLReader::NamelistReader &nlr, const Grid< DeviceType > &grid, int nrho_in, bool es_reduced_deltaf_setup=false)
GridField< HostType, VarType::Scalar, PhiInterpType::None, TorType::OnePlane, KinType::DriftKin > dpot_n0_h
Definition: electric_field.hpp:123
GridFieldPackPtr copy_push_fields_to_device(KinType kintype_in, MarkerType markertype_in, const Simulation< DeviceType > &sml, const DomainDecomposition< DeviceType > &pol_decomp, const MagneticField< DeviceType > &magnetic_field, const Grid< DeviceType > &grid, bool near_field=false) const
Definition: electric_field.hpp:286
void read_checkpoint_files(const Grid< DeviceType > &grid, const DomainDecomposition< DeviceType > &pol_decomp, bool loop_voltage_on, bool use_split_weight_scheme, bool em, const XGC_IO_Stream &stream, const XGC_IO_Stream &em_stream)
bool turb_efield
E-field calculated only with if .false., psndpot will still contain all (n=0,|m|>0) and (|n|>0,...
Definition: electric_field.hpp:89
GridField< HostType, VarType::Scalar, PhiInterpType::None, TorType::MultiplePlanes, KinType::DriftKin > As_h
Definition: electric_field.hpp:102
GridField< HostType, VarType::Vector2D, PIT_GLOBAL, TorType::OnePlane, KinType::GyroKin > du2_E
Gradient of the square (dot product) of the E x B drift.
Definition: electric_field.hpp:118
bool E00_efield
Flux-surface averaged potential not used for calculating the electric field if .false.
Definition: electric_field.hpp:90
Boundary pbd0
Definition: electric_field.hpp:137
int nrho
Definition: electric_field.hpp:83
GridField< HostType, VarType::Vector2D, PIT_GLOBAL, TorType::OnePlane, KinType::GyroKin > dEz_B2
Gradient of Ez/B^2.
Definition: electric_field.hpp:117
void get_Ah_rho_ff(const Simulation< DeviceType > &sml, const Grid< DeviceType > &grid, const DomainDecomposition< DeviceType > &pol_decomp, const MagneticField< DeviceType > &magnetic_field, Species< DeviceType > &species)
Definition: electric_field.hpp:316
ElectricField()
Definition: electric_field.hpp:140
GridField< HostType, VarType::Scalar, PhiInterpType::None, TorType::MultiplePlanes, KinType::DriftKin > Ah_h
Definition: electric_field.hpp:98
GridField< HostType, VarType::Scalar, PIT_GLOBAL, TorType::OnePlane, KinType::GyroKin > pot
Definition: electric_field.hpp:110
GridField< HostType, VarType::Scalar, PhiInterpType::Planes, TorType::OnePlane, KinType::DriftKin > ddpotdt
Time derivative of - Not field-following?
Definition: electric_field.hpp:95
GridField< HostType, vec2d_if_axisym< PIT_GLOBAL >), PIT_GLOBAL, TorType::OnePlane, KinType::GyroKin > E
Definition: electric_field.hpp:111
GridField< HostType, VarType::Scalar, PhiInterpType::None, TorType::MultiplePlanes, KinType::DriftKin > Ah_cv_h
Definition: electric_field.hpp:106
GridField< HostType, VarType::Scalar, PhiInterpType::Planes, TorType::OnePlane, KinType::DriftKin > Ah_cv
Definition: electric_field.hpp:107
bool calculate_phi_ff_on_device
Definition: electric_field.hpp:86
GridField< HostType, VarType::Scalar, PhiInterpType::None, TorType::OnePlane, KinType::DriftKin > Ah_h_backup
Definition: electric_field.hpp:99
GridField< HostType, VarType::Scalar, PhiInterpType::Planes, TorType::OnePlane, KinType::DriftKin > dpot_ff_h
Definition: electric_field.hpp:113
GridField< HostType, VarType::Scalar, PhiInterpType::None, TorType::OnePlane, KinType::DriftKin > pot0_h
Definition: electric_field.hpp:122
View< double ***, CLayout, HostType > save_dpot0
Definition: electric_field.hpp:124
GridFieldPackPtr copy_push_fields_to_device_gyro_kin_XGC1(const Simulation< DeviceType > &sml, const DomainDecomposition< DeviceType > &pol_decomp, const MagneticField< DeviceType > &magnetic_field, const Grid< DeviceType > &grid, bool near_field=false) const
Definition: electric_field.hpp:224
bool n0_m_efield
Definition: electric_field.hpp:91
int nphi
Definition: electric_field.hpp:80
static MemoryPrediction estimate_memory_usage(NLReader::NamelistReader &nlr, const Grid< DeviceType > &grid)
Definition: electric_field.hpp:465
GridField< HostType, VarType::Scalar, PhiInterpType::None, TorType::OnePlane, KinType::DriftKin > loop_voltage_h
Definition: electric_field.hpp:133
Definition: get_potential_grad.hpp:205
Definition: get_potential_grad.hpp:44
FieldFollowingCoordinates ff
Definition: get_potential_grad.hpp:66
GradientMatrices< DeviceType > grad_matrices
Definition: get_potential_grad.hpp:65
Definition: grid_field_pack.hpp:24
Definition: grid_field.hpp:22
Definition: label.hpp:44
Definition: memory_prediction.hpp:4
Definition: smoothing.hpp:10
Definition: electric_field.hpp:25
Definition: electric_field.hpp:21
Pack< Labeled< Efield2DGyroType, Label::E > > t
Definition: electric_field.hpp:65
Pack< Labeled< typename getGyroVecFldType< KT >::t, Label::E >, Labeled< typename getGyroVecFldType< KT >::t, Label::dAh >, Labeled< typename getGyroVecFldType< KT >::t, Label::dAs >, Labeled< typename getGyroScaFldType< KT >::t, Label::Ah >, Labeled< typename getGyroScaFldType< KT >::t, Label::As >, Labeled< typename getGyroScaFldType< KT >::t, Label::dAdt_guess > > t
Definition: electric_field.hpp:39
Pack< Labeled< typename getGyroVecFldType< KT >::t, Label::E > > t
Definition: electric_field.hpp:45
Pack< Labeled< typename getGyroVecFldType< KT >::t, Label::E >, Labeled< E00Type, Label::E00 >, Labeled< PotType, Label::ddpotdt > > t
Definition: electric_field.hpp:53
Definition: electric_field.hpp:19
#define TIMER(N, F)
Definition: timer_macro.hpp:24
static int GPTLstart(const char *name)
Definition: timer_macro.hpp:9
static int GPTLstop(const char *name)
Definition: timer_macro.hpp:10