XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
perturbed_B_field.hpp
Go to the documentation of this file.
1 #ifndef PTB_3DB_HPP
2 #define PTB_3DB_HPP
3 #include "NamelistReader.hpp"
4 #include "grid.hpp"
5 #include "field.hpp"
6 
7 extern "C" void get_3db_rampup_fac(const double *rampup_fac);
8 extern "C" void get_ptb_3db_arrays(Field<VarType::Vector,PhiInterpType::None>** ptb_3db_bfield_re_vac, Field<VarType::Vector,PhiInterpType::None>** ptb_3db_bfield_im_vac);
9 
10 // Perturbed magnetic field class
11 template<class Device>
13  public:
14 
15  // Field variables
16  bool rampup_vac;
17  int num_ntor;
19  int start_time;
20  int mode;
21  bool full_spec_on;
22 
23  double rampup_fac;
24 
25  bool active;
26 
27  // Field arrays
28  Kokkos::View<int*,Kokkos::LayoutRight,Device> ntor;
29  Kokkos::View<Field<VarType::Vector,PhiInterpType::None>**,Kokkos::LayoutRight,Device> bfield_im_vac;
30  Kokkos::View<Field<VarType::Vector,PhiInterpType::None>**,Kokkos::LayoutRight,Device> bfield_re_vac;
31 
32  // Constructor
33  PerturbedBField(NLReader::NamelistReader& nlr, bool rampup_vac_in, int num_ntor_in,
34  int rampup_time_in, int start_time_in,
35  int nnode_in, int *ntor_in);
36 
37  // Null constructor if ptb_3db is off
39  : active(false) {}
40 
41  // Update ramp_up
44  }
45 
47 #ifndef NO_FORTRAN_MODULES
48  Field<VarType::Vector,PhiInterpType::None>* ptb_3db_bfield_re_vac;
49  Field<VarType::Vector,PhiInterpType::None>* ptb_3db_bfield_im_vac;
50  get_ptb_3db_arrays(&ptb_3db_bfield_re_vac, &ptb_3db_bfield_im_vac);
51 
52  array_deep_copy(bfield_re_vac, ptb_3db_bfield_re_vac);
53  array_deep_copy(bfield_im_vac, ptb_3db_bfield_im_vac);
54 #endif
55  }
56 
57  void copy_to_device_if_on(int gstep){
58  if(is_triggered(gstep)){
61  active = true;
62  }else{
63  active = false;
64  }
65  }
66 
67  KOKKOS_INLINE_FUNCTION bool is_triggered(int gstep) const;
68 
69  // Get perturbed b-field
70  template<Order OT>
71  KOKKOS_INLINE_FUNCTION void get_delta_b(const Grid<Device> &grid, const Simd<double>& phi, const SimdGridWeights<OT, PhiInterpType::None>& grid_wts, SimdVector &tdb) const;
72 
73 };
74 
75 #include "perturbed_B_field.tpp"
76 #endif
double rampup_fac
The current relative amplitude of the vacuum vector potential (if ptb_3db_mode==2) - this is updated ...
Definition: perturbed_B_field.hpp:23
void array_deep_copy(T *array, const Kokkos::View< T *, Kokkos::LayoutRight, Device > &view)
Definition: array_deep_copy.hpp:11
int mode
Mode of RMP operation (details in XGC_core/module_ptb_3db.F90 –&gt; ptb_3db_mode)
Definition: perturbed_B_field.hpp:20
void get_3db_rampup_fac(const double *rampup_fac)
bool active
Whether the field is in device memory and should be used in the push etc. Could be renamed for clarit...
Definition: perturbed_B_field.hpp:25
void update_rampup_fac_from_fortran() const
Definition: perturbed_B_field.hpp:42
Definition: simd.hpp:149
Definition: perturbed_B_field.hpp:12
int rampup_time
Number of time steps over which the perturbed field is ramped up.
Definition: perturbed_B_field.hpp:18
KOKKOS_INLINE_FUNCTION bool is_triggered(int gstep) const
Definition: perturbed_B_field.tpp:33
bool full_spec_on
(EM-only) whether to retain the full RMP spectrum from M3D-C1 or only |m/q-n|&lt;=sml_mode_select_mres_q...
Definition: perturbed_B_field.hpp:21
Definition: grid_weights.hpp:47
Definition: NamelistReader.hpp:193
Definition: grid.hpp:21
void copy_bfield_from_fortran() const
Definition: perturbed_B_field.hpp:46
Kokkos::View< int *, Kokkos::LayoutRight, Device > ntor
Array to store the toroidal mode numbers.
Definition: perturbed_B_field.hpp:28
int num_ntor
Number of toroidal mode numbers (&lt;= sml_nphi_total)
Definition: perturbed_B_field.hpp:17
Kokkos::View< Field< VarType::Vector, PhiInterpType::None > **, Kokkos::LayoutRight, Device > bfield_im_vac
perturbed vacuum field on XGC mesh, imaginary part
Definition: perturbed_B_field.hpp:29
PerturbedBField()
Definition: perturbed_B_field.hpp:38
bool rampup_vac
(.true.) Ramp up perturbed field slowly, (.false.) turn on perturbed field abruptly ...
Definition: perturbed_B_field.hpp:16
int start_time
Time step in which perturbed field is switched on.
Definition: perturbed_B_field.hpp:19
KOKKOS_INLINE_FUNCTION void get_delta_b(const Grid< Device > &grid, const Simd< double > &phi, const SimdGridWeights< OT, PhiInterpType::None > &grid_wts, SimdVector &tdb) const
Definition: perturbed_B_field.tpp:48
void get_ptb_3db_arrays(Field< VarType::Vector, PhiInterpType::None > **ptb_3db_bfield_re_vac, Field< VarType::Vector, PhiInterpType::None > **ptb_3db_bfield_im_vac)
Kokkos::View< Field< VarType::Vector, PhiInterpType::None > **, Kokkos::LayoutRight, Device > bfield_re_vac
perturbed vacuum field on XGC mesh, real part, dimensions: (grid vertex, R-Z-phi components, tor. mode number)
Definition: perturbed_B_field.hpp:30
void copy_to_device_if_on(int gstep)
Definition: perturbed_B_field.hpp:57