1 #ifndef FIELD_ALIGNED_LOCAL_FIELDS_HPP
2 #define FIELD_ALIGNED_LOCAL_FIELDS_HPP
20 template<KinType KT, PhiInterpType PIT>
27 template<
class Device>
32 template<
class Device>
36 fields.
fields_at_point(push_controls, grid, B,gradpsi,grid_wts,rho_wts, fld);
54 #if defined(DELTAF_CONV) && !defined(EXPLICIT_EM)
66 const auto& fld_E = fld.template get<Label::E>();
68 const auto& fld_dAh = fld.template get<Label::dAh>();
69 const auto& fld_dAs = fld.template get<Label::dAs>();
71 for (
int i_simd = 0; i_simd<SIMD_SIZE; i_simd++){
74 double grad2 = gradpsi.
r[i_simd]*gradpsi.
r[i_simd] + gradpsi.
z[i_simd]*gradpsi.
z[i_simd];
77 E.r[i_simd] = (fld_E.r[i_simd] *gradpsi.
r[i_simd] + fld_E.z[i_simd] *gradpsi.
z[i_simd])/grad2;
78 E.z[i_simd] = (fld_E.r[i_simd] *B.
r[i_simd] + fld_E.z[i_simd] *B.
z[i_simd] )/Bp;
79 E.phi[i_simd] = (
E.z[i_simd]*Bp + fld_E.phi[i_simd]*B.
phi[i_simd] )/Bmag;
83 dAh.r[i_simd] = (fld_dAh.r[i_simd]*gradpsi.
r[i_simd] + fld_dAh.z[i_simd]*gradpsi.
z[i_simd])/grad2;
84 dAh.z[i_simd] = (fld_dAh.r[i_simd]*B.
r[i_simd] + fld_dAh.z[i_simd]*B.
z[i_simd] )/Bp;
85 dAh.phi[i_simd] = (
dAh.z[i_simd] *Bp + fld_dAh.phi[i_simd]*B.
phi[i_simd] )/Bmag;
90 dAs.r[i_simd] = (fld_dAs.r[i_simd]*gradpsi.
r[i_simd] + fld_dAs.z[i_simd]*gradpsi.
z[i_simd])/grad2;
91 dAs.z[i_simd] = (fld_dAs.r[i_simd]*B.
r[i_simd] + fld_dAs.z[i_simd]*B.
z[i_simd] )/Bp;
92 dAs.phi[i_simd] = (
dAs.z[i_simd] *Bp + fld_dAs.phi[i_simd]*B.
phi[i_simd] )/Bmag;
99 auto& fld_E = fld.template get<Label::E>();
101 auto& fld_dAh = fld.template get<Label::dAh>();
102 auto& fld_dAs = fld.template get<Label::dAs>();
104 for (
int i_simd = 0; i_simd<SIMD_SIZE; i_simd++){
107 double Br_norm = B.
r[i_simd] / Bp;
108 double Bz_norm = B.
z[i_simd] / Bp;
110 fld_E.r[i_simd] =
E.r[i_simd]*gradpsi.
r[i_simd]+
E.z[i_simd]*Br_norm;
111 fld_E.z[i_simd] =
E.r[i_simd]*gradpsi.
z[i_simd]+
E.z[i_simd]*Bz_norm;
112 fld_E.phi[i_simd] = (
E.phi[i_simd]*Bmag - fld_E.r[i_simd]*B.
r[i_simd] - fld_E.z[i_simd]*B.
z[i_simd])/B.
phi[i_simd];
115 fld_dAh.r[i_simd] =
dAh.r[i_simd]*gradpsi.
r[i_simd]+
dAh.z[i_simd]*Br_norm;
116 fld_dAh.z[i_simd] =
dAh.r[i_simd]*gradpsi.
z[i_simd]+
dAh.z[i_simd]*Bz_norm;
117 fld_dAh.phi[i_simd] = (
dAh.phi[i_simd]*Bmag - fld_dAh.r[i_simd]*B.
r[i_simd] - fld_dAh.z[i_simd]*B.
z[i_simd])/B.
phi[i_simd];
121 fld_dAs.r[i_simd] =
dAs.r[i_simd]*gradpsi.
r[i_simd]+
dAs.z[i_simd]*Br_norm;
122 fld_dAs.z[i_simd] =
dAs.r[i_simd]*gradpsi.
z[i_simd]+
dAs.z[i_simd]*Bz_norm;
123 fld_dAs.phi[i_simd] = (
dAs.phi[i_simd]*Bmag - fld_dAs.r[i_simd]*B.
r[i_simd] - fld_dAs.z[i_simd]*B.
z[i_simd])/B.
phi[i_simd];
131 template<
class Device>
143 magnetic_field.
field(part.
ph.
v(), B, jacb, psi, gradpsi, tdb, rz_outside);
154 gfpack.
fields_at_point(push_controls, grid, B,gradpsi,grid_wts,rho_wts, fld);
157 convert_cyl_to_mag(B, gradpsi, fld);
160 #if defined(DELTAF_CONV) && !defined(EXPLICIT_EM)
161 E00=fld.template get<Label::E00>();
162 ddpotdt = fld.template get<Label::ddpotdt>();
165 Ah = fld.template get<Label::Ah>();
166 As = fld.template get<Label::As>();
167 Epar_em = fld.template get<Label::Epar_em>();
172 template<
class Device>
176 convert_mag_to_cyl(B, gradpsi, fld);
179 #if defined(DELTAF_CONV) && !defined(EXPLICIT_EM)
180 fld.template get<Label::E00>()=
E00;
181 fld.template get<Label::ddpotdt>() =
ddpotdt;
184 fld.template get<Label::Ah>() =
Ah;
185 fld.template get<Label::As>() =
As;
186 fld.template get<Label::Epar_em>() =
Epar_em;
Simd< double > r
Definition: simd.hpp:150
Definition: grid_weights.hpp:73
Definition: grid_weights.hpp:47
Definition: push_controls.hpp:9
Definition: magnetic_field.hpp:12
Definition: grid_field_pack.hpp:21
KOKKOS_INLINE_FUNCTION void field(const SimdVector &v, SimdVector &bvec, SimdVector(&jacb)[3], Simd< double > &psivec, SimdVector2D &gradpsi, SimdVector &tdb, Simd< bool > &rz_outside) const
Definition: magnetic_field.tpp:138
Definition: local_fields.hpp:33
KOKKOS_INLINE_FUNCTION double poloidal_magnitude(const int i_simd) const
Definition: simd.hpp:181
KOKKOS_INLINE_FUNCTION FieldAlignedLocalFields(const Grid< Device > &grid, const PushControls &push_controls, const Species< Device > &species, const MagneticField< Device > &magnetic_field, const GridFieldPack< Device, PIT > &gfpack, SimdParticles &part, SimdGridWeights< Order::One, PIT > &grid_wts)
Definition: field_aligned_local_fields.hpp:28
PhiInterpType
Definition: globals.hpp:95
Definition: gyro_radius.hpp:24
Definition: gyro_radius.hpp:84
KOKKOS_INLINE_FUNCTION SimdVector & v()
Definition: particles.hpp:39
KOKKOS_INLINE_FUNCTION void convert_cyl_to_mag(const SimdVector &B, const SimdVector2D &gradpsi, const LocalFields &fld)
Definition: field_aligned_local_fields.hpp:65
Simd< double > z
Definition: simd.hpp:141
Definition: globals.hpp:90
KOKKOS_INLINE_FUNCTION void fields_at_point(const GridFieldPack< Device, PhiInterpType::Planes > fields, const PushControls &push_controls, const Grid< Device > &grid, const SimdVector &B, const SimdVector2D &gradpsi, const SimdGridWeights< Order::One, PhiInterpType::Planes > &grid_wts, SimdGyroWeights< GyroKin > &rho_wts, LocalFields &fld) const
Definition: field_aligned_local_fields.hpp:173
SimdPhase ph
Definition: particles.hpp:62
Simd< double > phi
Definition: simd.hpp:152
Definition: particles.hpp:61
Simd< double > z
Definition: simd.hpp:151
KOKKOS_INLINE_FUNCTION FieldAlignedLocalFields(const Grid< Device > &grid, const PushControls &push_controls, const Species< Device > &species, const MagneticField< Device > &magnetic_field, const GridFieldPack< Device, PhiInterpType::Planes > &gfpack, SimdParticles &part, SimdGridWeights< Order::One, PhiInterpType::Planes > &grid_wts)
Definition: field_aligned_local_fields.hpp:132
Simd< double > r
Definition: simd.hpp:140
Definition: field_aligned_local_fields.hpp:21
Definition: magnetic_field.F90:1
SimdVector E
Definition: field_aligned_local_fields.hpp:47
SimdConstants ct
Definition: particles.hpp:63
KOKKOS_INLINE_FUNCTION void convert_mag_to_cyl(const SimdVector &B, const SimdVector2D &gradpsi, LocalFields &fld) const
Definition: field_aligned_local_fields.hpp:98
KOKKOS_INLINE_FUNCTION void fields_at_point(const PushControls &push_controls, const Grid< Device > &grid, const SimdVector &B, const SimdVector2D &gradpsi, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, const SimdGyroWeights< PT > &rho_wts, LocalFields &fld) const
Definition: grid_field_pack.hpp:201
Definition: species.hpp:75
KOKKOS_INLINE_FUNCTION void get_grid_weights(const MagneticField< Device > &magnetic_field, const SimdVector &v, const Simd< double > &psi, SimdVector2D &xff, SimdGridWeights< Order::One, PIT > &grid_wts) const
Definition: grid.tpp:32
KOKKOS_INLINE_FUNCTION double magnitude(const int i_simd) const
Definition: simd.hpp:176
Simd< double > mu
Definition: particles.hpp:52
KOKKOS_INLINE_FUNCTION void fields_at_point(const GridFieldPack< Device, PIT > fields, const PushControls &push_controls, const Grid< Device > &grid, const SimdVector &B, const SimdVector2D &gradpsi, const SimdGridWeights< Order::One, PIT > &grid_wts, SimdGyroWeights< KT > &rho_wts, LocalFields &fld) const
Definition: field_aligned_local_fields.hpp:33
KOKKOS_INLINE_FUNCTION void deactivate(const Simd< bool > &mask)
Definition: particles.hpp:79