1 #ifndef GRID_FIELD_PACK_HPP
2 #define GRID_FIELD_PACK_HPP
20 template<
class Device, PhiInterpType PIT>
24 using pack_type = Pack<Labeled<EfieldType, Label::E>,
39 using pack_type = Pack<Labeled<EfieldType, Label::E>,
44 using pack_type = Pack<Labeled<EfieldType, Label::E>,
66 KOKKOS_INLINE_FUNCTION
const auto&
get()
const{
67 return pack.template get<FN>();
73 return pack.template get<FN>();
122 vec.
phi[i_simd]=(vec.
phi[i_simd]*Bmag - vec.
r[i_simd]*B.
r[i_simd] - vec.
z[i_simd]*B.
z[i_simd]) / B.
phi[i_simd];
130 E_rho(node,0).gather(fld.template get<Label::E>(),i_simd, wp, corr);
134 const int i_phi = (grid_wts.phi_wts.phi.i[i_simd] -
phi_offset)%get<Label::E>().f.extent(0);
135 get<Label::E>()(i_phi,node).gather(fld.template get<Label::E>(),i_simd, wp, grid_wts.phi_wts, corr);
137 get<Label::Ah>()(i_phi,node).gather(fld.template get<Label::Ah>(),i_simd, wp, grid_wts.phi_wts);
138 get<Label::dAh>()(i_phi,node).gather(fld.template get<Label::dAh>(),i_simd, wp, grid_wts.phi_wts, corr);
140 if(push_controls.em_mixed_variable) {
141 get<Label::dAs>()(i_phi,node).gather(fld.template get<Label::dAs>(),i_simd, wp, grid_wts.phi_wts, corr);
142 get<Label::As>()(i_phi,node).gather(fld.template get<Label::As>(),i_simd, wp, grid_wts.phi_wts);
144 if(push_controls.em_mixed_variable && (push_controls.em_pullback_mode==4)) {
145 get<Label::Epar_em>()(i_phi,node).gather(fld.template get<Label::Epar_em>(),i_simd,wp,grid_wts.phi_wts);
152 #if defined(DELTAF_CONV) && !defined(EXPLICIT_EM)
153 get<Label::E00>()(node).gather(fld.template get<Label::E00>(),i_simd, wp, grid_wts.phi_wts, corr);
154 get<Label::ddpotdt>()(i_phi,node).gather(fld.template get<Label::ddpotdt>(),i_simd, wp, grid_wts.phi_wts);
160 int irho = rho_wts.
irho(i_simd);
162 E_rho(node,irho).gather(fld.template get<Label::E>(),i_simd, wp, rho_wts, corr, E_rho(node,irho+1));
164 dEr_B2_rho(node,0).gather(fld.template get<Label::dEr_B2>(),i_simd, wp, corr);
165 dEz_B2_rho(node,0).gather(fld.template get<Label::dEz_B2>(),i_simd, wp, corr);
166 du2_E_rho(node,0).gather(fld.template get<Label::du2_E>(),i_simd, wp, corr);
171 get<Label::E_gyro>()(node,irho).gather(fld.template get<Label::E>(),i_simd, wp, rho_wts, grid_wts.phi_wts, corr, get<Label::E_gyro>()(node,irho+1));
173 get<Label::Ah_gyro>()(node,irho).gather(fld.template get<Label::Ah>(),i_simd, wp, rho_wts, grid_wts.phi_wts, get<Label::Ah_gyro>()(node,irho+1));
174 get<Label::dAh_gyro>()(node,irho).gather(fld.template get<Label::dAh>(),i_simd, wp, rho_wts, grid_wts.phi_wts, corr, get<Label::dAh_gyro>()(node,irho+1));
176 if(push_controls.em_mixed_variable) {
177 get<Label::dAs_gyro>()(node,irho).gather(fld.template get<Label::dAs>(),i_simd, wp, rho_wts, grid_wts.phi_wts, corr, get<Label::dAs_gyro>()(node,irho+1));
178 get<Label::As_gyro>()(node,irho).gather(fld.template get<Label::As>(),i_simd, wp, rho_wts, grid_wts.phi_wts, get<Label::As_gyro>()(node,irho+1));
180 if(push_controls.em_mixed_variable && (push_controls.em_pullback_mode==4)) {
181 get<Label::Epar_em_gyro>()(node,irho).gather(fld.template get<Label::Epar_em>(),i_simd,wp,rho_wts, grid_wts.phi_wts, get<Label::Epar_em_gyro>()(node,irho+1));
204 fld.template get<Label::E>().zero();
205 #if defined(DELTAF_CONV) && !defined(EXPLICIT_EM)
206 fld.template get<Label::E00>().zero();
207 fld.template get<Label::ddpotdt>().zero();
210 fld.template get<Label::dAh>().zero();
211 fld.template get<Label::dAs>().zero();
212 fld.template get<Label::Ah>().zero();
213 fld.template get<Label::As>().zero();
214 fld.template get<Label::Epar_em>().zero();
217 fld.template get<Label::dEr_B2>()zero();
218 fld.template get<Label::dEz_B2>()zero();
219 fld.template get<Label::du2_E>()zero();
222 for (
int i_simd = 0; i_simd<SIMD_SIZE; i_simd++){
224 int itr_work = grid_wts.is_valid(i_simd) ? grid_wts.itr[i_simd] : 1;
230 for (
int ip = 0; ip<3; ip++){
231 int node = grid_wts.is_valid(i_simd) ? grid.
get_node_index(itr_work, ip) : 0;
232 double wp = grid_wts.is_valid(i_simd) ? grid_wts.p[ip][i_simd] : 0.0;
236 gather_all_fields(push_controls, i_simd, node, wp, field_correction, grid_wts, rho_wts, fld);
239 #ifdef NEOCLASSICAL_TEST
240 fld.template get<Label::E>().phi[i_simd]=0.0;
248 phi_from_para(fld.template get<Label::E>(), i_simd, B, Bmag);
250 phi_from_para(fld.template get<Label::dAh>(), i_simd, B, Bmag);
251 phi_from_para(fld.template get<Label::dAs>(), i_simd, B, Bmag);
254 fld.template get<Label::E>().phi[i_simd]=0.0;
256 fld.template get<Label::dAh>().phi[i_simd]=0.0;
257 fld.template get<Label::dAs>().phi[i_simd]=0.0;
272 for (
int i_simd = 0; i_simd<SIMD_SIZE; i_simd++){
274 int itr_work = grid_wts.is_valid(i_simd) ? grid_wts.itr[i_simd] : 1;
276 int irho = rho_wts.
irho(i_simd);
279 for (
int ip = 0; ip<3; ip++){
280 int node = grid_wts.is_valid(i_simd) ? grid.
get_node_index(itr_work, ip) : 0;
281 double wp = grid_wts.is_valid(i_simd) ? grid_wts.p[ip][i_simd] : 0.0;
283 get<Label::Ah_gyro>()(node,irho).gather(Ah,i_simd, wp, rho_wts, grid_wts.phi_wts, get<Label::Ah_gyro>()(node,irho+1));
295 for (
int i_simd = 0; i_simd<SIMD_SIZE; i_simd++){
297 int itr_work = grid_wts.is_valid(i_simd) ? grid_wts.itr[i_simd] : 1;
300 for (
int ip = 0; ip<3; ip++){
301 int i_node = grid_wts.is_valid(i_simd) ? grid.
get_node_index(itr_work, ip) : 0;
302 double wp = grid_wts.is_valid(i_simd) ? grid_wts.p[ip][i_simd] : 0.0;
305 constexpr
int PHI_ZERO=0;
306 get<Label::Ah>()(PHI_ZERO,node).gather(Ah,i_simd, wp, grid_wts.phi_wts);
317 for (
int i_simd = 0; i_simd<SIMD_SIZE; i_simd++){
319 int itr_work = grid_wts.is_valid(i_simd) ? grid_wts.itr[i_simd] : 1;
321 for(
int ip=0; ip<3; ip++){
322 int node = grid_wts.is_valid(i_simd) ? grid.
get_node_index(itr_work, ip) : 0;
323 double wp = grid_wts.is_valid(i_simd) ? grid_wts.p[ip][i_simd] : 0.0;
328 dpot_ff(node).gather(dpot_out,i_simd, wp, grid_wts.phi_wts);
334 dpot(node).gather(dpot_out,i_simd,wp);
KOKKOS_INLINE_FUNCTION void set(int i_simd, double basis, const SimdVector2D &gradpsi)
Definition: field.hpp:35
Simd< double > r
Definition: simd.hpp:150
KOKKOS_INLINE_FUNCTION void get_Ah(const Grid< Device > &grid, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, const SimdGyroWeights< GyroKin > &rho_wts, Simd< double > &Ah) const
Definition: grid_field_pack.hpp:266
GridFieldPack()
Definition: grid_field_pack.hpp:93
GridField< Device, VarType::Scalar, PIT, TorType::OnePlane, KinType::DriftKin > loop_voltage
Definition: grid_field_pack.hpp:91
KOKKOS_INLINE_FUNCTION int irho(int i_simd) const
Definition: gyro_radius.hpp:107
KOKKOS_INLINE_FUNCTION void get_dpot(const Grid< Device > &grid, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, Simd< double > &dpot_out) const
Definition: grid_field_pack.hpp:312
bool turb_efield
Definition: grid_field_pack.hpp:55
KOKKOS_INLINE_FUNCTION void gather_all_fields(const PushControls &push_controls, int i_simd, int i_node, double wp, const FieldCorrection &corr, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, const SimdGyroWeights< DriftKin > &rho_wts, LocalFields &fld) const
Definition: grid_field_pack.hpp:127
Definition: grid_weights.hpp:47
Definition: push_controls.hpp:9
int phi_offset
Offset for phi_ff field decomposition.
Definition: grid_field_pack.hpp:57
KOKKOS_INLINE_FUNCTION void gather_all_fields(const PushControls &push_controls, int i_simd, int node, double wp, const FieldCorrection &corr, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, const SimdGyroWeights< GyroKin > &rho_wts, LocalFields &fld) const
Definition: grid_field_pack.hpp:159
Definition: grid_field_pack.hpp:21
KOKKOS_INLINE_FUNCTION int uses_rz_basis(const int inode) const
Definition: grid.tpp:251
Definition: local_fields.hpp:33
bool can_reuse(KinType kintype_in)
Definition: grid_field_pack.hpp:103
Definition: gyro_radius.hpp:114
Definition: gyro_radius.hpp:24
Definition: gyro_radius.hpp:84
KinType kintype
Definition: grid_field_pack.hpp:50
KOKKOS_INLINE_FUNCTION int get_node_index(int triangle_index, int tri_vertex_index) const
Definition: grid.tpp:158
KOKKOS_INLINE_FUNCTION void phi_from_para(SimdVector &vec, int i_simd, const SimdVector &B, double Bmag) const
Definition: grid_field_pack.hpp:121
Definition: globals.hpp:90
GridFieldPack(KinType kintype_in, bool turb_efield_in)
Definition: grid_field_pack.hpp:96
Simd< double > phi
Definition: simd.hpp:152
int node_offset
Offset for phi_ff field decomposition.
Definition: grid_field_pack.hpp:58
Simd< double > z
Definition: simd.hpp:151
KinType
Definition: globals.hpp:88
KOKKOS_INLINE_FUNCTION void zero()
Definition: simd.hpp:76
KOKKOS_INLINE_FUNCTION void get_Ah(const Grid< Device > &grid, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, const SimdGyroWeights< DriftKin > &rho_wts, Simd< double > &Ah) const
Definition: grid_field_pack.hpp:289
pack_type pack
Definition: grid_field_pack.hpp:62
GridField< Device, VarType::Scalar, PIT, TorType::OnePlane, KinType::DriftKin > dpot_ff
Definition: grid_field_pack.hpp:79
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
bool is_initialized
Definition: grid_field_pack.hpp:51
Pack< Labeled< EfieldType, Label::E >, Labeled< EfieldGyroType, Label::E_gyro >> pack_type
Definition: grid_field_pack.hpp:45
KOKKOS_INLINE_FUNCTION double magnitude(const int i_simd) const
Definition: simd.hpp:176
Definition: grid_field_pack.hpp:17