XGC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
push_diagnostic.hpp
Go to the documentation of this file.
1 #ifndef PUSH_DIAGNOSTIC_HPP
2 #define PUSH_DIAGNOSTIC_HPP
3 
4 #include "push_controls.hpp"
5 #include "electric_field.hpp"
6 #include "perturbed_B_field.hpp"
7 
8 enum class PushDiagToggle{On, Off};
9 
10 namespace Diag{
11  enum D1D_PV1{
12  D1D_NPV1 = 19
13  };
14 }
15 
16 template<PushDiagToggle PDT>
17 struct VFDiag{};
18 
19 template<>
21  enum VF_DIAG{
22  PSI=0,
31  N_VF_DIAG
32  };
33 
34  Simd<double> vd[N_VF_DIAG];
35 
36  KOKKOS_INLINE_FUNCTION const Simd<double>& operator [](int i) const {return vd[i];}
37  KOKKOS_INLINE_FUNCTION Simd<double>& operator [](int i) {return vd[i];}
38 
39  KOKKOS_INLINE_FUNCTION void set(int i_simd, double fac, const Simd<double>& psi, double B, const SimdVector& bfield, const SimdVector2D& gradpsi, const SimdVector& tdb, const double (&yp_exb)[3], const SimdPhase& yprime){
40  vd[PSI][i_simd] = psi[i_simd];
41  vd[BMAG][i_simd] = B;
42  vd[BPHI][i_simd] = bfield.phi[i_simd];
43  vd[V_ExB_GRADPSI][i_simd] = yp_exb[PIR]*gradpsi.r[i_simd] + yp_exb[PIZ]*gradpsi.z[i_simd]; // V_ExB dot grad psi
44  vd[V_d_GRADPSI][i_simd] = yprime.r[i_simd]*gradpsi.r[i_simd] + yprime.z[i_simd]*gradpsi.z[i_simd]; // V_d dot grad psi
45  vd[GRADPSI2][i_simd] = gradpsi.r[i_simd]*gradpsi.r[i_simd] + gradpsi.z[i_simd]*gradpsi.z[i_simd]; // |grad psi|^2
46  double Bp = bfield.poloidal_magnitude(i_simd);
47  vd[V_d_B_POL][i_simd] = (yprime.r[i_simd]*bfield.r[i_simd] + yprime.z[i_simd]*bfield.z[i_simd])/Bp;
48  vd[V_ExB_B_POL][i_simd] = (yp_exb[PIR]*bfield.r[i_simd] + yp_exb[PIZ]*bfield.z[i_simd])/Bp;
49  vd[TDB_GRADPSI][i_simd] = fac * (tdb.r[i_simd]*gradpsi.r[i_simd] + tdb.z[i_simd]*gradpsi.z[i_simd]); // v_para*(deltaB.grad(psi))
50  }
51 };
52 
54 
55 // PushDiagnostic class
56 template<class Device>
58 
59  public:
60 
61  // Used in diag_1d_port1 (in pushe)
62  int d1d_period;
63 
64  // Arrays
65  Kokkos::View<double****,Kokkos::LayoutRight,Device> d1d_f_pv1;
66  Kokkos::View<double****,Kokkos::LayoutRight,Device> d1d_df_pv1;
67 
68  // Constructor
69  PushDiagnostic(NLReader::NamelistReader& nlr, bool allocate_df_diagnostic, int np, int nspecies, int nthreads);
70 
71  // Null constructor
73 
74  // Check whether to record diagnostics
75  inline bool determine_diag_on(int istep,int ipc);
76 
77  KOKKOS_INLINE_FUNCTION void scatter_single_diag(bool is_deltaf, int ithread, int sp_type, int ip, double w, double dw, double wp, int i_v, double v) const;
78 
79  // General 1D push diagnostics
80  KOKKOS_INLINE_FUNCTION void d1d_port1(const Grid<Device> &grid, const Species<Device> &species, const MagneticField<Device> &magnetic_field, const SimdParticles &part,const SimdPhase &derivs,int sp_type, const VFDiag<PushDiagToggle::On>& vf) const;
81 
82 };
83 
84 template<class Device>
85 KOKKOS_INLINE_FUNCTION void push_diagnostics_c(const Grid<Device> &grid,
86  const MagneticField<Device> &magnetic_field, const ElectricField<Device> &electric_field,
87  const PushDiagnostic<Device> &diag, const PushControls &push_controls, const Species<Device> &species,
88  const PerturbedBField<Device> &perturbed_B_field, int);
89 
90 #include "push_diagnostic.tpp"
91 #endif
Simd< double > r
Definition: simd.hpp:150
VF_DIAG
Definition: push_diagnostic.hpp:21
Definition: simd.hpp:149
Definition: perturbed_B_field.hpp:11
KOKKOS_INLINE_FUNCTION void d1d_port1(const Grid< Device > &grid, const Species< Device > &species, const MagneticField< Device > &magnetic_field, const SimdParticles &part, const SimdPhase &derivs, int sp_type, const VFDiag< PushDiagToggle::On > &vf) const
Definition: push_diagnostic.tpp:73
Definition: push_diagnostic.hpp:26
KOKKOS_INLINE_FUNCTION void scatter_single_diag(bool is_deltaf, int ithread, int sp_type, int ip, double w, double dw, double wp, int i_v, double v) const
Definition: push_diagnostic.tpp:58
Definition: push_diagnostic.hpp:20
Definition: push_diagnostic.hpp:17
Definition: push_controls.hpp:9
Definition: NamelistReader.hpp:193
Definition: magnetic_field.hpp:12
Definition: electric_field.hpp:39
Definition: push_diagnostic.hpp:29
Definition: grid.hpp:55
int d1d_period
steps between diag recording
Definition: push_diagnostic.hpp:62
KOKKOS_INLINE_FUNCTION void set(int i_simd, double fac, const Simd< double > &psi, double B, const SimdVector &bfield, const SimdVector2D &gradpsi, const SimdVector &tdb, const double(&yp_exb)[3], const SimdPhase &yprime)
Definition: push_diagnostic.hpp:39
subroutine derivs(x, phi, dx)
Definition: field_following.F90:97
Definition: push_diagnostic.hpp:27
D1D_PV1
Definition: push_diagnostic.hpp:11
Definition: push_diagnostic.hpp:28
KOKKOS_INLINE_FUNCTION double poloidal_magnitude(const int i_simd) const
Definition: simd.hpp:181
Kokkos::View< double ****, Kokkos::LayoutRight, Device > d1d_df_pv1
Array of delta f diagnostic quantities (optional)
Definition: push_diagnostic.hpp:66
r coordinate
Definition: globals.hpp:162
KOKKOS_INLINE_FUNCTION void push_diagnostics_c(const Grid< Device > &grid, const MagneticField< Device > &magnetic_field, const ElectricField< Device > &electric_field, const PushDiagnostic< Device > &diag, const PushControls &push_controls, const Species< Device > &species, const PerturbedBField< Device > &perturbed_B_field, int)
Simd< double > r
Definition: particles.hpp:18
Definition: push_diagnostic.hpp:24
Simd< double > z
Definition: simd.hpp:141
PushDiagnostic()
Definition: push_diagnostic.hpp:72
Simd< double > phi
Definition: simd.hpp:152
Definition: particles.hpp:58
Simd< double > z
Definition: simd.hpp:151
Definition: push_diagnostic.hpp:25
Simd< double > z
Definition: particles.hpp:19
Simd< double > r
Definition: simd.hpp:140
Definition: magnetic_field.F90:1
Definition: particles.hpp:17
Definition: push_diagnostic.hpp:57
Definition: simd.hpp:139
PushDiagToggle
Definition: push_diagnostic.hpp:8
Definition: push_diagnostic.hpp:12
VFDiag< PushDiagToggle::On > VF
Definition: push_diagnostic.hpp:53
bool determine_diag_on(int istep, int ipc)
Definition: push_diagnostic.tpp:24
Definition: species.hpp:75
Definition: push_diagnostic.hpp:30
z coordinate
Definition: globals.hpp:163
Kokkos::View< double ****, Kokkos::LayoutRight, Device > d1d_f_pv1
Array of diagnostic quantities.
Definition: push_diagnostic.hpp:65
Definition: push_diagnostic.hpp:23
Definition: tracer_diag.cpp:59