8 #ifndef WARPX_FIELDGATHER_H_
9 #define WARPX_FIELDGATHER_H_
36 template <
int depos_order,
int galerkin_
interpolation>
39 [[maybe_unused]]
const amrex::ParticleReal yp,
40 [[maybe_unused]]
const amrex::ParticleReal zp,
41 amrex::ParticleReal& Exp,
42 amrex::ParticleReal& Eyp,
43 amrex::ParticleReal& Ezp,
44 amrex::ParticleReal& Bxp,
45 amrex::ParticleReal& Byp,
46 amrex::ParticleReal& Bzp,
62 [[maybe_unused]]
const int n_rz_azimuthal_modes)
64 using namespace amrex;
66 constexpr
int zdir = WARPX_ZINDEX;
75 #if (AMREX_SPACEDIM >= 2)
79 const amrex::Real rp = std::sqrt(xp*xp + yp*yp);
80 const amrex::Real
x = (rp - xyzmin.
x)*dinv.
x;
82 const amrex::Real
x = (xp-xyzmin.
x)*dinv.
x;
89 amrex::Real sx_node[depos_order + 1];
90 amrex::Real sx_cell[depos_order + 1];
91 amrex::Real sx_node_galerkin[depos_order + 1 - galerkin_interpolation] = {0._rt};
92 amrex::Real sx_cell_galerkin[depos_order + 1 - galerkin_interpolation] = {0._rt};
98 if ((ey_type[0] ==
NODE) || (ez_type[0] ==
NODE) || (bx_type[0] ==
NODE)) {
99 j_node = compute_shape_factor(sx_node,
x);
101 if ((ey_type[0] == CELL) || (ez_type[0] == CELL) || (bx_type[0] == CELL)) {
102 j_cell = compute_shape_factor(sx_cell,
x - 0.5_rt);
104 if ((ex_type[0] ==
NODE) || (by_type[0] ==
NODE) || (bz_type[0] ==
NODE)) {
105 j_node_v = compute_shape_factor_galerkin(sx_node_galerkin,
x);
107 if ((ex_type[0] == CELL) || (by_type[0] == CELL) || (bz_type[0] == CELL)) {
108 j_cell_v = compute_shape_factor_galerkin(sx_cell_galerkin,
x - 0.5_rt);
110 const amrex::Real (&sx_ex)[depos_order + 1 - galerkin_interpolation] = ((ex_type[0] ==
NODE) ? sx_node_galerkin : sx_cell_galerkin);
111 const amrex::Real (&sx_ey)[depos_order + 1 ] = ((ey_type[0] ==
NODE) ? sx_node : sx_cell );
112 const amrex::Real (&sx_ez)[depos_order + 1 ] = ((ez_type[0] ==
NODE) ? sx_node : sx_cell );
113 const amrex::Real (&sx_bx)[depos_order + 1 ] = ((bx_type[0] ==
NODE) ? sx_node : sx_cell );
114 const amrex::Real (&sx_by)[depos_order + 1 - galerkin_interpolation] = ((by_type[0] ==
NODE) ? sx_node_galerkin : sx_cell_galerkin);
115 const amrex::Real (&sx_bz)[depos_order + 1 - galerkin_interpolation] = ((bz_type[0] ==
NODE) ? sx_node_galerkin : sx_cell_galerkin);
116 int const j_ex = ((ex_type[0] ==
NODE) ? j_node_v : j_cell_v);
117 int const j_ey = ((ey_type[0] ==
NODE) ? j_node : j_cell );
118 int const j_ez = ((ez_type[0] ==
NODE) ? j_node : j_cell );
119 int const j_bx = ((bx_type[0] ==
NODE) ? j_node : j_cell );
120 int const j_by = ((by_type[0] ==
NODE) ? j_node_v : j_cell_v);
121 int const j_bz = ((bz_type[0] ==
NODE) ? j_node_v : j_cell_v);
124 #if defined(WARPX_DIM_3D)
126 const amrex::Real y = (yp-xyzmin.
y)*dinv.
y;
127 amrex::Real sy_node[depos_order + 1];
128 amrex::Real sy_cell[depos_order + 1];
129 amrex::Real sy_node_v[depos_order + 1 - galerkin_interpolation];
130 amrex::Real sy_cell_v[depos_order + 1 - galerkin_interpolation];
135 if ((ex_type[1] ==
NODE) || (ez_type[1] ==
NODE) || (by_type[1] ==
NODE)) {
136 k_node = compute_shape_factor(sy_node, y);
138 if ((ex_type[1] == CELL) || (ez_type[1] == CELL) || (by_type[1] == CELL)) {
139 k_cell = compute_shape_factor(sy_cell, y - 0.5_rt);
141 if ((ey_type[1] ==
NODE) || (bx_type[1] ==
NODE) || (bz_type[1] ==
NODE)) {
142 k_node_v = compute_shape_factor_galerkin(sy_node_v, y);
144 if ((ey_type[1] == CELL) || (bx_type[1] == CELL) || (bz_type[1] == CELL)) {
145 k_cell_v = compute_shape_factor_galerkin(sy_cell_v, y - 0.5_rt);
147 const amrex::Real (&sy_ex)[depos_order + 1 ] = ((ex_type[1] ==
NODE) ? sy_node : sy_cell );
148 const amrex::Real (&sy_ey)[depos_order + 1 - galerkin_interpolation] = ((ey_type[1] ==
NODE) ? sy_node_v : sy_cell_v);
149 const amrex::Real (&sy_ez)[depos_order + 1 ] = ((ez_type[1] ==
NODE) ? sy_node : sy_cell );
150 const amrex::Real (&sy_bx)[depos_order + 1 - galerkin_interpolation] = ((bx_type[1] ==
NODE) ? sy_node_v : sy_cell_v);
151 const amrex::Real (&sy_by)[depos_order + 1 ] = ((by_type[1] ==
NODE) ? sy_node : sy_cell );
152 const amrex::Real (&sy_bz)[depos_order + 1 - galerkin_interpolation] = ((bz_type[1] ==
NODE) ? sy_node_v : sy_cell_v);
153 int const k_ex = ((ex_type[1] ==
NODE) ? k_node : k_cell );
154 int const k_ey = ((ey_type[1] ==
NODE) ? k_node_v : k_cell_v);
155 int const k_ez = ((ez_type[1] ==
NODE) ? k_node : k_cell );
156 int const k_bx = ((bx_type[1] ==
NODE) ? k_node_v : k_cell_v);
157 int const k_by = ((by_type[1] ==
NODE) ? k_node : k_cell );
158 int const k_bz = ((bz_type[1] ==
NODE) ? k_node_v : k_cell_v);
162 const amrex::Real z = (zp-xyzmin.
z)*dinv.
z;
163 amrex::Real sz_node[depos_order + 1];
164 amrex::Real sz_cell[depos_order + 1];
165 amrex::Real sz_node_v[depos_order + 1 - galerkin_interpolation];
166 amrex::Real sz_cell_v[depos_order + 1 - galerkin_interpolation];
171 if ((ex_type[zdir] ==
NODE) || (ey_type[zdir] ==
NODE) || (bz_type[zdir] ==
NODE)) {
172 l_node = compute_shape_factor(sz_node, z);
174 if ((ex_type[zdir] == CELL) || (ey_type[zdir] == CELL) || (bz_type[zdir] == CELL)) {
175 l_cell = compute_shape_factor(sz_cell, z - 0.5_rt);
177 if ((ez_type[zdir] ==
NODE) || (bx_type[zdir] ==
NODE) || (by_type[zdir] ==
NODE)) {
178 l_node_v = compute_shape_factor_galerkin(sz_node_v, z);
180 if ((ez_type[zdir] == CELL) || (bx_type[zdir] == CELL) || (by_type[zdir] == CELL)) {
181 l_cell_v = compute_shape_factor_galerkin(sz_cell_v, z - 0.5_rt);
183 const amrex::Real (&sz_ex)[depos_order + 1 ] = ((ex_type[zdir] ==
NODE) ? sz_node : sz_cell );
184 const amrex::Real (&sz_ey)[depos_order + 1 ] = ((ey_type[zdir] ==
NODE) ? sz_node : sz_cell );
185 const amrex::Real (&sz_ez)[depos_order + 1 - galerkin_interpolation] = ((ez_type[zdir] ==
NODE) ? sz_node_v : sz_cell_v);
186 const amrex::Real (&sz_bx)[depos_order + 1 - galerkin_interpolation] = ((bx_type[zdir] ==
NODE) ? sz_node_v : sz_cell_v);
187 const amrex::Real (&sz_by)[depos_order + 1 - galerkin_interpolation] = ((by_type[zdir] ==
NODE) ? sz_node_v : sz_cell_v);
188 const amrex::Real (&sz_bz)[depos_order + 1 ] = ((bz_type[zdir] ==
NODE) ? sz_node : sz_cell );
189 int const l_ex = ((ex_type[zdir] ==
NODE) ? l_node : l_cell );
190 int const l_ey = ((ey_type[zdir] ==
NODE) ? l_node : l_cell );
191 int const l_ez = ((ez_type[zdir] ==
NODE) ? l_node_v : l_cell_v);
192 int const l_bx = ((bx_type[zdir] ==
NODE) ? l_node_v : l_cell_v);
193 int const l_by = ((by_type[zdir] ==
NODE) ? l_node_v : l_cell_v);
194 int const l_bz = ((bz_type[zdir] ==
NODE) ? l_node : l_cell );
202 #if defined(WARPX_DIM_1D_Z)
206 for (
int iz=0;
iz<=depos_order;
iz++){
208 ey_arr(lo.
x+l_ey+
iz, 0, 0, 0);
210 ex_arr(lo.
x+l_ex+
iz, 0, 0, 0);
212 bz_arr(lo.
x+l_bz+
iz, 0, 0, 0);
218 for (
int iz=0;
iz<=depos_order-galerkin_interpolation;
iz++){
220 ez_arr(lo.
x+l_ez+
iz, 0, 0, 0);
222 bx_arr(lo.
x+l_bx+
iz, 0, 0, 0);
224 by_arr(lo.
x+l_by+
iz, 0, 0, 0);
227 #elif defined(WARPX_DIM_XZ)
229 for (
int iz=0;
iz<=depos_order;
iz++){
230 for (
int ix=0;
ix<=depos_order;
ix++){
231 Eyp += sx_ey[
ix]*sz_ey[
iz]*
232 ey_arr(lo.
x+j_ey+
ix, lo.
y+l_ey+
iz, 0, 0);
237 for (
int iz=0;
iz<=depos_order;
iz++){
238 for (
int ix=0;
ix<=depos_order-galerkin_interpolation;
ix++){
239 Exp += sx_ex[
ix]*sz_ex[
iz]*
240 ex_arr(lo.
x+j_ex+
ix, lo.
y+l_ex+
iz, 0, 0);
241 Bzp += sx_bz[
ix]*sz_bz[
iz]*
242 bz_arr(lo.
x+j_bz+
ix, lo.
y+l_bz+
iz, 0, 0);
247 for (
int iz=0;
iz<=depos_order-galerkin_interpolation;
iz++){
248 for (
int ix=0;
ix<=depos_order;
ix++){
249 Ezp += sx_ez[
ix]*sz_ez[
iz]*
250 ez_arr(lo.
x+j_ez+
ix, lo.
y+l_ez+
iz, 0, 0);
251 Bxp += sx_bx[
ix]*sz_bx[
iz]*
252 bx_arr(lo.
x+j_bx+
ix, lo.
y+l_bx+
iz, 0, 0);
256 for (
int iz=0;
iz<=depos_order-galerkin_interpolation;
iz++){
257 for (
int ix=0;
ix<=depos_order-galerkin_interpolation;
ix++){
258 Byp += sx_by[
ix]*sz_by[
iz]*
259 by_arr(lo.
x+j_by+
ix, lo.
y+l_by+
iz, 0, 0);
263 #elif defined(WARPX_DIM_RZ)
265 amrex::ParticleReal Erp = 0.;
266 amrex::ParticleReal Ethetap = 0.;
267 amrex::ParticleReal Brp = 0.;
268 amrex::ParticleReal Bthetap = 0.;
271 for (
int iz=0;
iz<=depos_order;
iz++){
272 for (
int ix=0;
ix<=depos_order;
ix++){
273 Ethetap += sx_ey[
ix]*sz_ey[
iz]*
274 ey_arr(lo.
x+j_ey+
ix, lo.
y+l_ey+
iz, 0, 0);
279 for (
int iz=0;
iz<=depos_order;
iz++){
280 for (
int ix=0;
ix<=depos_order-galerkin_interpolation;
ix++){
281 Erp += sx_ex[
ix]*sz_ex[
iz]*
282 ex_arr(lo.
x+j_ex+
ix, lo.
y+l_ex+
iz, 0, 0);
283 Bzp += sx_bz[
ix]*sz_bz[
iz]*
284 bz_arr(lo.
x+j_bz+
ix, lo.
y+l_bz+
iz, 0, 0);
289 for (
int iz=0;
iz<=depos_order-galerkin_interpolation;
iz++){
290 for (
int ix=0;
ix<=depos_order;
ix++){
291 Ezp += sx_ez[
ix]*sz_ez[
iz]*
292 ez_arr(lo.
x+j_ez+
ix, lo.
y+l_ez+
iz, 0, 0);
293 Brp += sx_bx[
ix]*sz_bx[
iz]*
294 bx_arr(lo.
x+j_bx+
ix, lo.
y+l_bx+
iz, 0, 0);
298 for (
int iz=0;
iz<=depos_order-galerkin_interpolation;
iz++){
299 for (
int ix=0;
ix<=depos_order-galerkin_interpolation;
ix++){
300 Bthetap += sx_by[
ix]*sz_by[
iz]*
301 by_arr(lo.
x+j_by+
ix, lo.
y+l_by+
iz, 0, 0);
305 amrex::Real costheta;
306 amrex::Real sintheta;
317 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
320 for (
int iz=0;
iz<=depos_order;
iz++){
321 for (
int ix=0;
ix<=depos_order;
ix++){
322 const amrex::Real dEy = (+ ey_arr(lo.
x+j_ey+
ix, lo.
y+l_ey+
iz, 0, 2*imode-1)*xy.
real()
323 - ey_arr(lo.
x+j_ey+
ix, lo.
y+l_ey+
iz, 0, 2*imode)*xy.
imag());
324 Ethetap += sx_ey[
ix]*sz_ey[
iz]*dEy;
329 for (
int iz=0;
iz<=depos_order;
iz++){
330 for (
int ix=0;
ix<=depos_order-galerkin_interpolation;
ix++){
331 const amrex::Real dEx = (+ ex_arr(lo.
x+j_ex+
ix, lo.
y+l_ex+
iz, 0, 2*imode-1)*xy.
real()
332 - ex_arr(lo.
x+j_ex+
ix, lo.
y+l_ex+
iz, 0, 2*imode)*xy.
imag());
333 Erp += sx_ex[
ix]*sz_ex[
iz]*dEx;
334 const amrex::Real dBz = (+ bz_arr(lo.
x+j_bz+
ix, lo.
y+l_bz+
iz, 0, 2*imode-1)*xy.
real()
335 - bz_arr(lo.
x+j_bz+
ix, lo.
y+l_bz+
iz, 0, 2*imode)*xy.
imag());
336 Bzp += sx_bz[
ix]*sz_bz[
iz]*dBz;
341 for (
int iz=0;
iz<=depos_order-galerkin_interpolation;
iz++){
342 for (
int ix=0;
ix<=depos_order;
ix++){
343 const amrex::Real dEz = (+ ez_arr(lo.
x+j_ez+
ix, lo.
y+l_ez+
iz, 0, 2*imode-1)*xy.
real()
344 - ez_arr(lo.
x+j_ez+
ix, lo.
y+l_ez+
iz, 0, 2*imode)*xy.
imag());
345 Ezp += sx_ez[
ix]*sz_ez[
iz]*dEz;
346 const amrex::Real dBx = (+ bx_arr(lo.
x+j_bx+
ix, lo.
y+l_bx+
iz, 0, 2*imode-1)*xy.
real()
347 - bx_arr(lo.
x+j_bx+
ix, lo.
y+l_bx+
iz, 0, 2*imode)*xy.
imag());
348 Brp += sx_bx[
ix]*sz_bx[
iz]*dBx;
352 for (
int iz=0;
iz<=depos_order-galerkin_interpolation;
iz++){
353 for (
int ix=0;
ix<=depos_order-galerkin_interpolation;
ix++){
354 const amrex::Real dBy = (+ by_arr(lo.
x+j_by+
ix, lo.
y+l_by+
iz, 0, 2*imode-1)*xy.
real()
355 - by_arr(lo.
x+j_by+
ix, lo.
y+l_by+
iz, 0, 2*imode)*xy.
imag());
356 Bthetap += sx_by[
ix]*sz_by[
iz]*dBy;
363 Exp += costheta*Erp - sintheta*Ethetap;
364 Eyp += costheta*Ethetap + sintheta*Erp;
365 Bxp += costheta*Brp - sintheta*Bthetap;
366 Byp += costheta*Bthetap + sintheta*Brp;
370 for (
int iz=0;
iz<=depos_order;
iz++){
371 for (
int iy=0;
iy<=depos_order;
iy++){
372 for (
int ix=0;
ix<= depos_order - galerkin_interpolation;
ix++){
373 Exp += sx_ex[
ix]*sy_ex[
iy]*sz_ex[
iz]*
374 ex_arr(lo.
x+j_ex+
ix, lo.
y+k_ex+
iy, lo.
z+l_ex+
iz);
379 for (
int iz=0;
iz<=depos_order;
iz++){
380 for (
int iy=0;
iy<= depos_order - galerkin_interpolation;
iy++){
381 for (
int ix=0;
ix<=depos_order;
ix++){
382 Eyp += sx_ey[
ix]*sy_ey[
iy]*sz_ey[
iz]*
383 ey_arr(lo.
x+j_ey+
ix, lo.
y+k_ey+
iy, lo.
z+l_ey+
iz);
388 for (
int iz=0;
iz<= depos_order - galerkin_interpolation;
iz++){
389 for (
int iy=0;
iy<=depos_order;
iy++){
390 for (
int ix=0;
ix<=depos_order;
ix++){
391 Ezp += sx_ez[
ix]*sy_ez[
iy]*sz_ez[
iz]*
392 ez_arr(lo.
x+j_ez+
ix, lo.
y+k_ez+
iy, lo.
z+l_ez+
iz);
397 for (
int iz=0;
iz<=depos_order;
iz++){
398 for (
int iy=0;
iy<= depos_order - galerkin_interpolation;
iy++){
399 for (
int ix=0;
ix<= depos_order - galerkin_interpolation;
ix++){
400 Bzp += sx_bz[
ix]*sy_bz[
iy]*sz_bz[
iz]*
401 bz_arr(lo.
x+j_bz+
ix, lo.
y+k_bz+
iy, lo.
z+l_bz+
iz);
406 for (
int iz=0;
iz<= depos_order - galerkin_interpolation;
iz++){
407 for (
int iy=0;
iy<=depos_order;
iy++){
408 for (
int ix=0;
ix<= depos_order - galerkin_interpolation;
ix++){
409 Byp += sx_by[
ix]*sy_by[
iy]*sz_by[
iz]*
410 by_arr(lo.
x+j_by+
ix, lo.
y+k_by+
iy, lo.
z+l_by+
iz);
415 for (
int iz=0;
iz<= depos_order - galerkin_interpolation;
iz++){
416 for (
int iy=0;
iy<= depos_order - galerkin_interpolation;
iy++){
417 for (
int ix=0;
ix<=depos_order;
ix++){
418 Bxp += sx_bx[
ix]*sy_bx[
iy]*sz_bx[
iz]*
419 bx_arr(lo.
x+j_bx+
ix, lo.
y+k_bx+
iy, lo.
z+l_bx+
iz);
444 template <
int depos_order>
447 [[maybe_unused]]
const amrex::ParticleReal xp_n,
448 [[maybe_unused]]
const amrex::ParticleReal yp_n,
449 const amrex::ParticleReal zp_n,
450 [[maybe_unused]]
const amrex::ParticleReal xp_nph,
451 [[maybe_unused]]
const amrex::ParticleReal yp_nph,
452 const amrex::ParticleReal zp_nph,
453 amrex::ParticleReal& Exp,
454 amrex::ParticleReal& Eyp,
455 amrex::ParticleReal& Ezp,
456 amrex::ParticleReal& Bxp,
457 amrex::ParticleReal& Byp,
458 amrex::ParticleReal& Bzp,
474 const int n_rz_azimuthal_modes)
476 using namespace amrex;
477 #if !defined(WARPX_DIM_RZ)
481 #if !defined(WARPX_DIM_1D_Z)
482 Real constexpr one_third = 1.0_rt / 3.0_rt;
483 Real constexpr one_sixth = 1.0_rt / 6.0_rt;
486 #if !defined(WARPX_DIM_1D_Z)
487 const ParticleReal xp_np1 = 2._prt*xp_nph - xp_n;
489 #if defined(WARPX_DIM_3D) || defined(WARPX_DIM_RZ)
490 const ParticleReal yp_np1 = 2._prt*yp_nph - yp_n;
492 const ParticleReal zp_np1 = 2._prt*zp_nph - zp_n;
495 #if defined(WARPX_DIM_RZ)
496 amrex::Real
const xp_new = xp_np1;
497 amrex::Real
const yp_new = yp_np1;
498 amrex::Real
const xp_mid = xp_nph;
499 amrex::Real
const yp_mid = yp_nph;
500 amrex::Real
const xp_old = xp_n;
501 amrex::Real
const yp_old = yp_n;
502 amrex::Real
const rp_new = std::sqrt(xp_new*xp_new + yp_new*yp_new);
503 amrex::Real
const rp_old = std::sqrt(xp_old*xp_old + yp_old*yp_old);
504 amrex::Real
const rp_mid = (rp_new + rp_old)/2._rt;
505 amrex::Real costheta_mid, sintheta_mid;
506 if (rp_mid > 0._rt) {
507 costheta_mid = xp_mid/rp_mid;
508 sintheta_mid = yp_mid/rp_mid;
510 costheta_mid = 1._rt;
511 sintheta_mid = 0._rt;
515 double const x_new = (rp_new - xyzmin.
x)*dinv.
x;
516 double const x_old = (rp_old - xyzmin.
x)*dinv.
x;
518 #if !defined(WARPX_DIM_1D_Z)
520 double const x_new = (xp_np1 - xyzmin.
x)*dinv.
x;
521 double const x_old = (xp_n - xyzmin.
x)*dinv.
x;
524 #if defined(WARPX_DIM_3D)
526 double const y_new = (yp_np1 - xyzmin.
y)*dinv.
y;
527 double const y_old = (yp_n - xyzmin.
y)*dinv.
y;
530 double const z_new = (zp_np1 - xyzmin.
z)*dinv.
z;
531 double const z_old = (zp_n - xyzmin.
z)*dinv.
z;
538 #if !defined(WARPX_DIM_1D_Z)
539 double sx_E_new[depos_order + 3] = {0.};
540 double sx_E_old[depos_order + 3] = {0.};
542 #if defined(WARPX_DIM_3D)
544 double sy_E_new[depos_order + 3] = {0.};
545 double sy_E_old[depos_order + 3] = {0.};
548 double sz_E_new[depos_order + 3] = {0.};
549 double sz_E_old[depos_order + 3] = {0.};
551 #if defined(WARPX_DIM_3D)
552 double sx_B_new[depos_order + 3] = {0.};
553 double sx_B_old[depos_order + 3] = {0.};
554 double sy_B_new[depos_order + 3] = {0.};
555 double sy_B_old[depos_order + 3] = {0.};
556 double sz_B_new[depos_order + 3] = {0.};
557 double sz_B_old[depos_order + 3] = {0.};
560 #if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
563 double sx_By_new[depos_order + 2] = {0.};
564 double sx_By_old[depos_order + 2] = {0.};
565 double sz_By_new[depos_order + 2] = {0.};
566 double sz_By_old[depos_order + 2] = {0.};
575 #if !defined(WARPX_DIM_1D_Z)
576 const int i_E_new = compute_shape_factor(sx_E_new+1, x_new);
577 const int i_E_old = compute_shifted_shape_factor(sx_E_old, x_old, i_E_new);
579 #if defined(WARPX_DIM_3D)
580 const int j_E_new = compute_shape_factor(sy_E_new+1, y_new);
581 const int j_E_old = compute_shifted_shape_factor(sy_E_old, y_old, j_E_new);
583 const int k_E_new = compute_shape_factor(sz_E_new+1, z_new);
584 const int k_E_old = compute_shifted_shape_factor(sz_E_old, z_old, k_E_new);
586 #if defined(WARPX_DIM_3D)
587 const int i_B_new = compute_shape_factor(sx_B_new+1, x_new - 0.5_rt);
588 const int i_B_old = compute_shifted_shape_factor(sx_B_old, x_old - 0.5_rt, i_B_new);
589 const int j_B_new = compute_shape_factor(sy_B_new+1, y_new - 0.5_rt);
590 const int j_B_old = compute_shifted_shape_factor(sy_B_old, y_old - 0.5_rt, j_B_new);
591 const int k_B_new = compute_shape_factor(sz_B_new+1, z_new - 0.5_rt);
592 const int k_B_old = compute_shifted_shape_factor(sz_B_old, z_old - 0.5_rt, k_B_new);
596 #if !defined(WARPX_DIM_1D_Z)
597 int dil_E = 1, diu_E = 1;
598 if (i_E_old < i_E_new) { dil_E = 0; }
599 if (i_E_old > i_E_new) { diu_E = 0; }
601 #if defined(WARPX_DIM_3D)
602 int djl_E = 1, dju_E = 1;
603 if (j_E_old < j_E_new) { djl_E = 0; }
604 if (j_E_old > j_E_new) { dju_E = 0; }
606 int dkl_E = 1, dku_E = 1;
607 if (k_E_old < k_E_new) { dkl_E = 0; }
608 if (k_E_old > k_E_new) { dku_E = 0; }
610 #if defined(WARPX_DIM_3D)
611 int dil_B = 1, diu_B = 1;
612 if (i_B_old < i_B_new) { dil_B = 0; }
613 if (i_B_old > i_B_new) { diu_B = 0; }
614 int djl_B = 1, dju_B = 1;
615 if (j_B_old < j_B_new) { djl_B = 0; }
616 if (j_B_old > j_B_new) { dju_B = 0; }
617 int dkl_B = 1, dku_B = 1;
618 if (k_B_old < k_B_new) { dkl_B = 0; }
619 if (k_B_old > k_B_new) { dku_B = 0; }
622 #if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
625 const int i_By_new = compute_shape_factor_By(sx_By_new+1, x_new - 0.5_rt);
626 const int i_By_old = compute_shifted_shape_factor_By(sx_By_old, x_old - 0.5_rt, i_By_new);
627 const int k_By_new = compute_shape_factor_By(sz_By_new+1, z_new - 0.5_rt);
628 const int k_By_old = compute_shifted_shape_factor_By(sz_By_old, z_old - 0.5_rt, k_By_new);
629 int dil_By = 1, diu_By = 1;
630 if (i_By_old < i_By_new) { dil_By = 0; }
631 if (i_By_old > i_By_new) { diu_By = 0; }
632 int dkl_By = 1, dku_By = 1;
633 if (k_By_old < k_By_new) { dkl_By = 0; }
634 if (k_By_old > k_By_new) { dku_By = 0; }
637 #if defined(WARPX_DIM_3D)
639 for (
int k=dkl_E; k<=depos_order+2-dku_E; k++) {
640 for (
int j=djl_E; j<=depos_order+2-dju_E; j++) {
641 const amrex::Real sdzjk = one_third*(sy_E_new[j]*sz_E_new[k] + sy_E_old[j]*sz_E_old[k])
642 +one_sixth*(sy_E_new[j]*sz_E_old[k] + sy_E_old[j]*sz_E_new[k]);
643 amrex::Real sdxi = 0._rt;
644 for (
int i=dil_E;
i<=depos_order+1-diu_E;
i++) {
645 sdxi += (sx_E_old[
i] - sx_E_new[
i]);
646 auto sdxiov =
static_cast<amrex::Real
>((x_new - x_old) == 0. ? 1. : sdxi/(x_new - x_old));
647 Exp += Ex_arr(lo.
x+i_E_new-1+
i, lo.
y+j_E_new-1+j, lo.
z+k_E_new-1+k)*sdxiov*sdzjk;
651 for (
int k=dkl_E; k<=depos_order+2-dku_E; k++) {
652 for (
int i=dil_E;
i<=depos_order+2-diu_E;
i++) {
653 const amrex::Real sdyik = one_third*(sx_E_new[
i]*sz_E_new[k] + sx_E_old[
i]*sz_E_old[k])
654 +one_sixth*(sx_E_new[
i]*sz_E_old[k] + sx_E_old[
i]*sz_E_new[k]);
655 amrex::Real sdyj = 0._rt;
656 for (
int j=djl_E; j<=depos_order+1-dju_E; j++) {
657 sdyj += (sy_E_old[j] - sy_E_new[j]);
658 auto sdyjov =
static_cast<amrex::Real
>((y_new - y_old) == 0. ? 1. : sdyj/(y_new - y_old));
659 Eyp += Ey_arr(lo.
x+i_E_new-1+
i, lo.
y+j_E_new-1+j, lo.
z+k_E_new-1+k)*sdyjov*sdyik;
663 for (
int j=djl_E; j<=depos_order+2-dju_E; j++) {
664 for (
int i=dil_E;
i<=depos_order+2-diu_E;
i++) {
665 const amrex::Real sdzij = one_third*(sx_E_new[
i]*sy_E_new[j] + sx_E_old[
i]*sy_E_old[j])
666 +one_sixth*(sx_E_new[
i]*sy_E_old[j] + sx_E_old[
i]*sy_E_new[j]);
667 amrex::Real sdzk = 0._rt;
668 for (
int k=dkl_E; k<=depos_order+1-dku_E; k++) {
669 sdzk += (sz_E_old[k] - sz_E_new[k]);
670 auto sdzkov =
static_cast<amrex::Real
>((z_new - z_old) == 0. ? 1. : sdzk/(z_new - z_old));
671 Ezp += Ez_arr(lo.
x+i_E_new-1+
i, lo.
y+j_E_new-1+j, lo.
z+k_E_new-1+k)*sdzkov*sdzij;
675 for (
int k=dkl_B; k<=depos_order+2-dku_B; k++) {
676 for (
int j=djl_B; j<=depos_order+2-dju_B; j++) {
677 const amrex::Real sdzjk = one_third*(sy_B_new[j]*sz_B_new[k] + sy_B_old[j]*sz_B_old[k])
678 +one_sixth*(sy_B_new[j]*sz_B_old[k] + sy_B_old[j]*sz_B_new[k]);
679 amrex::Real sdxi = 0._rt;
680 for (
int i=dil_B;
i<=depos_order+1-diu_B;
i++) {
681 sdxi += (sx_B_old[
i] - sx_B_new[
i]);
682 auto sdxiov =
static_cast<amrex::Real
>((x_new - x_old) == 0. ? 1. : sdxi/(x_new - x_old));
683 Bxp += Bx_arr(lo.
x+i_B_new-1+
i, lo.
y+j_B_new-1+j, lo.
z+k_B_new-1+k)*sdxiov*sdzjk;
687 for (
int k=dkl_B; k<=depos_order+2-dku_B; k++) {
688 for (
int i=dil_B;
i<=depos_order+2-diu_B;
i++) {
689 const amrex::Real sdyik = one_third*(sx_B_new[
i]*sz_B_new[k] + sx_B_old[
i]*sz_B_old[k])
690 +one_sixth*(sx_B_new[
i]*sz_B_old[k] + sx_B_old[
i]*sz_B_new[k]);
691 amrex::Real sdyj = 0._rt;
692 for (
int j=djl_B; j<=depos_order+1-dju_B; j++) {
693 sdyj += (sy_B_old[j] - sy_B_new[j]);
694 auto sdyjov =
static_cast<amrex::Real
>((y_new - y_old) == 0. ? 1. : sdyj/(y_new - y_old));
695 Byp += By_arr(lo.
x+i_B_new-1+
i, lo.
y+j_B_new-1+j, lo.
z+k_B_new-1+k)*sdyjov*sdyik;
699 for (
int j=djl_B; j<=depos_order+2-dju_B; j++) {
700 for (
int i=dil_B;
i<=depos_order+2-diu_B;
i++) {
701 const amrex::Real sdzij = one_third*(sx_B_new[
i]*sy_B_new[j] + sx_B_old[
i]*sy_B_old[j])
702 +one_sixth*(sx_B_new[
i]*sy_B_old[j] + sx_B_old[
i]*sy_B_new[j]);
703 amrex::Real sdzk = 0._rt;
704 for (
int k=dkl_B; k<=depos_order+1-dku_B; k++) {
705 sdzk += (sz_B_old[k] - sz_B_new[k]);
706 auto sdzkov =
static_cast<amrex::Real
>((z_new - z_old) == 0. ? 1. : sdzk/(z_new - z_old));
707 Bzp += Bz_arr(lo.
x+i_B_new-1+
i, lo.
y+j_B_new-1+j, lo.
z+k_E_new-1+k)*sdzkov*sdzij;
712 #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
714 for (
int k=dkl_E; k<=depos_order+2-dku_E; k++) {
715 const amrex::Real sdzk = 0.5_rt*(sz_E_new[k] + sz_E_old[k]);
716 amrex::Real sdxi = 0._rt;
717 for (
int i=dil_E;
i<=depos_order+1-diu_E;
i++) {
718 sdxi += (sx_E_old[
i] - sx_E_new[
i]);
719 auto sdxiov =
static_cast<amrex::Real
>((x_new - x_old) == 0. ? 1. : sdxi/(x_new - x_old));
720 Exp += Ex_arr(lo.
x+i_E_new-1+
i, lo.
y+k_E_new-1+k, 0, 0)*sdxiov*sdzk;
721 Bzp += Bz_arr(lo.
x+i_E_new-1+
i, lo.
y+k_E_new-1+k, 0, 0)*sdxiov*sdzk;
724 for (
int k=dkl_E; k<=depos_order+2-dku_E; k++) {
725 for (
int i=dil_E;
i<=depos_order+2-diu_E;
i++) {
727 one_third*(sx_E_new[
i]*sz_E_new[k] + sx_E_old[
i]*sz_E_old[k])
728 +one_sixth*(sx_E_new[
i]*sz_E_old[k] + sx_E_old[
i]*sz_E_new[k]));
729 Eyp += Ey_arr(lo.
x+i_E_new-1+
i, lo.
y+k_E_new-1+k, 0, 0)*sdyj;
732 for (
int i=dil_E;
i<=depos_order+2-diu_E;
i++) {
733 const amrex::Real sdxi = 0.5_rt*(sx_E_new[
i] + sx_E_old[
i]);
734 amrex::Real sdzk = 0._rt;
735 for (
int k=dkl_E; k<=depos_order+1-dku_E; k++) {
736 sdzk += (sz_E_old[k] - sz_E_new[k]);
737 auto sdzkov =
static_cast<amrex::Real
>((z_new - z_old) == 0. ? 1. : sdzk/(z_new - z_old));
738 Ezp += Ez_arr(lo.
x+i_E_new-1+
i, lo.
y+k_E_new-1+k, 0, 0)*sdzkov*sdxi;
739 Bxp += Bx_arr(lo.
x+i_E_new-1+
i, lo.
y+k_E_new-1+k, 0, 0)*sdzkov*sdxi;
742 for (
int k=dkl_By; k<=depos_order+1-dku_By; k++) {
743 for (
int i=dil_By;
i<=depos_order+1-diu_By;
i++) {
745 one_third*(sx_By_new[
i]*sz_By_new[k] + sx_By_old[
i]*sz_By_old[k])
746 +one_sixth*(sx_By_new[
i]*sz_By_old[k] + sx_By_old[
i]*sz_By_new[k]));
747 Byp += By_arr(lo.
x+i_By_new-1+
i, lo.
y+k_By_new-1+k, 0, 0)*sdyj;
754 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
758 for (
int k=dkl_E; k<=depos_order+2-dku_E; k++) {
759 const amrex::Real sdzk = 0.5_rt*(sz_E_new[k] + sz_E_old[k]);
760 amrex::Real sdxi = 0._rt;
761 for (
int i=dil_E;
i<=depos_order+1-diu_E;
i++) {
762 sdxi += (sx_E_old[
i] - sx_E_new[
i]);
763 auto sdxiov =
static_cast<amrex::Real
>((x_new - x_old) == 0. ? 1. : sdxi/(x_new - x_old));
764 const amrex::Real dEx = (+ Ex_arr(lo.
x+i_E_new-1+
i, lo.
y+k_E_new-1+k, 0, 2*imode-1)*xy_mid.
real()
765 - Ex_arr(lo.
x+i_E_new-1+
i, lo.
y+k_E_new-1+k, 0, 2*imode)*xy_mid.
imag());
766 const amrex::Real dBz = (+ Bz_arr(lo.
x+i_E_new-1+
i, lo.
y+k_E_new-1+k, 0, 2*imode-1)*xy_mid.
real()
767 - Bz_arr(lo.
x+i_E_new-1+
i, lo.
y+k_E_new-1+k, 0, 2*imode)*xy_mid.
imag());
768 Exp += dEx*sdxiov*sdzk;
769 Bzp += dBz*sdxiov*sdzk;
773 for (
int k=dkl_E; k<=depos_order+2-dku_E; k++) {
774 for (
int i=dil_E;
i<=depos_order+2-diu_E;
i++) {
776 one_third*(sx_E_new[
i]*sz_E_new[k] + sx_E_old[
i]*sz_E_old[k])
777 +one_sixth*(sx_E_new[
i]*sz_E_old[k] + sx_E_old[
i]*sz_E_new[k]));
778 const amrex::Real dEy = (+ Ey_arr(lo.
x+i_E_new-1+
i, lo.
y+k_E_new-1+k, 0, 2*imode-1)*xy_mid.
real()
779 - Ey_arr(lo.
x+i_E_new-1+
i, lo.
y+k_E_new-1+k, 0, 2*imode)*xy_mid.
imag());
785 for (
int i=dil_E;
i<=depos_order+2-diu_E;
i++) {
786 const amrex::Real sdxi = 0.5_rt*(sx_E_new[
i] + sx_E_old[
i]);
787 amrex::Real sdzk = 0._rt;
788 for (
int k=dkl_E; k<=depos_order+1-dku_E; k++) {
789 sdzk += (sz_E_old[k] - sz_E_new[k]);
790 auto sdzkov =
static_cast<amrex::Real
>((z_new - z_old) == 0. ? 1. : sdzk/(z_new - z_old));
791 const amrex::Real dEz = (+ Ez_arr(lo.
x+i_E_new-1+
i, lo.
y+k_E_new-1+k, 0, 2*imode-1)*xy_mid.
real()
792 - Ez_arr(lo.
x+i_E_new-1+
i, lo.
y+k_E_new-1+k, 0, 2*imode)*xy_mid.
imag());
793 const amrex::Real dBx = (+ Bx_arr(lo.
x+i_E_new-1+
i, lo.
y+k_E_new-1+k, 0, 2*imode-1)*xy_mid.
real()
794 - Bx_arr(lo.
x+i_E_new-1+
i, lo.
y+k_E_new-1+k, 0, 2*imode)*xy_mid.
imag());
795 Ezp += dEz*sdzkov*sdxi;
796 Bxp += dBx*sdzkov*sdxi;
800 for (
int k=dkl_By; k<=depos_order+1-dku_By; k++) {
801 for (
int i=dil_By;
i<=depos_order+1-diu_By;
i++) {
803 one_third*(sx_By_new[
i]*sz_By_new[k] + sx_By_old[
i]*sz_By_old[k])
804 +one_sixth*(sx_By_new[
i]*sz_By_old[k] + sx_By_old[
i]*sz_By_new[k]));
805 const amrex::Real dBy = (+ By_arr(lo.
x+i_By_new-1+
i, lo.
y+k_By_new-1+k, 0, 2*imode-1)*xy_mid.
real()
806 - By_arr(lo.
x+i_By_new-1+
i, lo.
y+k_By_new-1+k, 0, 2*imode)*xy_mid.
imag());
810 xy_mid = xy_mid*xy_mid0;
814 const amrex::Real Exp_save = Exp;
815 Exp = costheta_mid*Exp - sintheta_mid*Eyp;
816 Eyp = costheta_mid*Eyp + sintheta_mid*Exp_save;
817 const amrex::Real Bxp_save = Bxp;
818 Bxp = costheta_mid*Bxp - sintheta_mid*Byp;
819 Byp = costheta_mid*Byp + sintheta_mid*Bxp_save;
823 #elif defined(WARPX_DIM_1D_Z)
825 for (
int k=dkl_E; k<=depos_order+2-dku_E; k++) {
826 amrex::Real
const sdzk = 0.5_rt*(sz_E_old[k] + sz_E_new[k]);
827 Exp += Ex_arr(lo.
x+k_E_new-1+k, 0, 0, 0)*sdzk;
828 Eyp += Ey_arr(lo.
x+k_E_new-1+k, 0, 0, 0)*sdzk;
829 Bzp += Bz_arr(lo.
x+k_E_new-1+k, 0, 0, 0)*sdzk;
831 amrex::Real sdzk = 0._rt;
832 for (
int k=dkl_E; k<=depos_order+1-dku_E; k++) {
833 sdzk += (sz_E_old[k] - sz_E_new[k]);
834 auto sdzkov =
static_cast<amrex::Real
>((z_new - z_old) == 0. ? 1. : sdzk/(z_new - z_old));
835 Bxp += Bx_arr(lo.
x+k_E_new-1+k, 0, 0, 0)*sdzkov;
836 Byp += By_arr(lo.
x+k_E_new-1+k, 0, 0, 0)*sdzkov;
837 Ezp += Ez_arr(lo.
x+k_E_new-1+k, 0, 0, 0)*sdzkov;
861 template <
int depos_order>
864 [[maybe_unused]]
const amrex::ParticleReal xp_n,
865 [[maybe_unused]]
const amrex::ParticleReal yp_n,
866 const amrex::ParticleReal zp_n,
867 [[maybe_unused]]
const amrex::ParticleReal xp_nph,
868 [[maybe_unused]]
const amrex::ParticleReal yp_nph,
869 const amrex::ParticleReal zp_nph,
870 amrex::ParticleReal& Exp,
871 amrex::ParticleReal& Eyp,
872 amrex::ParticleReal& Ezp,
873 amrex::ParticleReal& Bxp,
874 amrex::ParticleReal& Byp,
875 amrex::ParticleReal& Bzp,
891 const int n_rz_azimuthal_modes)
893 using namespace amrex;
894 #if !defined(WARPX_DIM_RZ)
898 #if !defined(WARPX_DIM_1D_Z)
899 const ParticleReal xp_np1 = 2._prt*xp_nph - xp_n;
901 #if defined(WARPX_DIM_3D) || defined(WARPX_DIM_RZ)
902 const ParticleReal yp_np1 = 2._prt*yp_nph - yp_n;
904 const ParticleReal zp_np1 = 2._prt*zp_nph - zp_n;
906 #if !defined(WARPX_DIM_1D_Z)
907 Real constexpr one_third = 1.0_rt / 3.0_rt;
908 Real constexpr one_sixth = 1.0_rt / 6.0_rt;
912 #if defined(WARPX_DIM_RZ)
913 amrex::Real
const xp_new = xp_np1;
914 amrex::Real
const yp_new = yp_np1;
915 amrex::Real
const xp_mid = xp_nph;
916 amrex::Real
const yp_mid = yp_nph;
917 amrex::Real
const xp_old = xp_n;
918 amrex::Real
const yp_old = yp_n;
919 amrex::Real
const rp_new = std::sqrt(xp_new*xp_new + yp_new*yp_new);
920 amrex::Real
const rp_old = std::sqrt(xp_old*xp_old + yp_old*yp_old);
921 amrex::Real
const rp_mid = (rp_new + rp_old)/2._rt;
922 amrex::Real costheta_mid, sintheta_mid;
923 if (rp_mid > 0._rt) {
924 costheta_mid = xp_mid/rp_mid;
925 sintheta_mid = yp_mid/rp_mid;
927 costheta_mid = 1._rt;
928 sintheta_mid = 0._rt;
932 double const x_new = (rp_new - xyzmin.
x)*dinv.
x;
933 double const x_old = (rp_old - xyzmin.
x)*dinv.
x;
934 double const x_bar = (rp_mid - xyzmin.
x)*dinv.
x;
935 #elif !defined(WARPX_DIM_1D_Z)
937 double const x_new = (xp_np1 - xyzmin.
x)*dinv.
x;
938 double const x_old = (xp_n - xyzmin.
x)*dinv.
x;
939 double const x_bar = (xp_nph - xyzmin.
x)*dinv.
x;
941 #
if defined(WARPX_DIM_3D)
943 double const y_new = (yp_np1 - xyzmin.
y)*dinv.
y;
944 double const y_old = (yp_n - xyzmin.
y)*dinv.
y;
945 double const y_bar = (yp_nph - xyzmin.
y)*dinv.
y;
948 double const z_new = (zp_np1 - xyzmin.
z)*dinv.
z;
949 double const z_old = (zp_n - xyzmin.
z)*dinv.
z;
950 double const z_bar = (zp_nph - xyzmin.
z)*dinv.
z;
959 int num_segments = 1;
961 if ( (depos_order % 2) == 0 ) {
shift = 0.5; }
963 #if defined(WARPX_DIM_3D)
966 const auto i_old =
static_cast<int>(x_old-
shift);
967 const auto i_new =
static_cast<int>(x_new-
shift);
968 const int cell_crossings_x = std::abs(i_new-i_old);
969 num_segments += cell_crossings_x;
972 const auto j_old =
static_cast<int>(y_old-
shift);
973 const auto j_new =
static_cast<int>(y_new-
shift);
974 const int cell_crossings_y = std::abs(j_new-j_old);
975 num_segments += cell_crossings_y;
978 const auto k_old =
static_cast<int>(z_old-
shift);
979 const auto k_new =
static_cast<int>(z_new-
shift);
980 const int cell_crossings_z = std::abs(k_new-k_old);
981 num_segments += cell_crossings_z;
989 const double dxp = x_new - x_old;
990 const double dyp = y_new - y_old;
991 const double dzp = z_new - z_old;
992 const auto dirX_sign =
static_cast<double>(dxp < 0. ? -1. : 1.);
993 const auto dirY_sign =
static_cast<double>(dyp < 0. ? -1. : 1.);
994 const auto dirZ_sign =
static_cast<double>(dzp < 0. ? -1. : 1.);
995 double Xcell = 0., Ycell = 0., Zcell = 0.;
996 if (num_segments > 1) {
997 Xcell =
static_cast<double>(i_old) +
shift + 0.5*(1.-dirX_sign);
998 Ycell =
static_cast<double>(j_old) +
shift + 0.5*(1.-dirY_sign);
999 Zcell =
static_cast<double>(k_old) +
shift + 0.5*(1.-dirZ_sign);
1005 double dxp_seg, dyp_seg, dzp_seg;
1006 double x0_new, y0_new, z0_new;
1007 double x0_old = x_old;
1008 double y0_old = y_old;
1009 double z0_old = z_old;
1011 for (
int ns=0; ns<num_segments; ns++) {
1013 if (ns == num_segments-1) {
1018 dxp_seg = x0_new - x0_old;
1019 dyp_seg = y0_new - y0_old;
1020 dzp_seg = z0_new - z0_old;
1025 x0_new = Xcell + dirX_sign;
1026 y0_new = Ycell + dirY_sign;
1027 z0_new = Zcell + dirZ_sign;
1028 dxp_seg = x0_new - x0_old;
1029 dyp_seg = y0_new - y0_old;
1030 dzp_seg = z0_new - z0_old;
1032 if ( (dyp == 0. || std::abs(dxp_seg) < std::abs(dxp/dyp*dyp_seg))
1033 && (dzp == 0. || std::abs(dxp_seg) < std::abs(dxp/dzp*dzp_seg)) ) {
1035 dyp_seg = dyp/dxp*dxp_seg;
1036 dzp_seg = dzp/dxp*dxp_seg;
1037 y0_new = y0_old + dyp_seg;
1038 z0_new = z0_old + dzp_seg;
1040 else if (dzp == 0. || std::abs(dyp_seg) < std::abs(dyp/dzp*dzp_seg)) {
1042 dxp_seg = dxp/dyp*dyp_seg;
1043 dzp_seg = dzp/dyp*dyp_seg;
1044 x0_new = x0_old + dxp_seg;
1045 z0_new = z0_old + dzp_seg;
1049 dxp_seg = dxp/dzp*dzp_seg;
1050 dyp_seg = dyp/dzp*dzp_seg;
1051 x0_new = x0_old + dxp_seg;
1052 y0_new = y0_old + dyp_seg;
1058 const auto seg_factor_x =
static_cast<double>(dxp == 0. ? 1. : dxp_seg/dxp);
1059 const auto seg_factor_y =
static_cast<double>(dyp == 0. ? 1. : dyp_seg/dyp);
1060 const auto seg_factor_z =
static_cast<double>(dzp == 0. ? 1. : dzp_seg/dzp);
1063 double sx_cell[depos_order] = {0.};
1064 double sy_cell[depos_order] = {0.};
1065 double sz_cell[depos_order] = {0.};
1066 double const x0_bar = (x0_new + x0_old)/2.0;
1067 double const y0_bar = (y0_new + y0_old)/2.0;
1068 double const z0_bar = (z0_new + z0_old)/2.0;
1069 const int i0_cell = compute_shape_factor_cell( sx_cell, x0_bar-0.5 );
1070 const int j0_cell = compute_shape_factor_cell( sy_cell, y0_bar-0.5 );
1071 const int k0_cell = compute_shape_factor_cell( sz_cell, z0_bar-0.5 );
1073 if constexpr (depos_order >= 3) {
1075 double sx_old_cell[depos_order] = {0.};
1076 double sx_new_cell[depos_order] = {0.};
1077 double sy_old_cell[depos_order] = {0.};
1078 double sy_new_cell[depos_order] = {0.};
1079 double sz_old_cell[depos_order] = {0.};
1080 double sz_new_cell[depos_order] = {0.};
1081 const int i0_cell_2 = compute_shape_factors_cell( sx_old_cell, sx_new_cell, x0_old-0.5, x0_new-0.5 );
1082 const int j0_cell_2 = compute_shape_factors_cell( sy_old_cell, sy_new_cell, y0_old-0.5, y0_new-0.5 );
1083 const int k0_cell_2 = compute_shape_factors_cell( sz_old_cell, sz_new_cell, z0_old-0.5, z0_new-0.5 );
1085 for (
int m=0; m<depos_order; m++) {
1086 sx_cell[m] = (4.0*sx_cell[m] + sx_old_cell[m] + sx_new_cell[m])/6.0;
1087 sy_cell[m] = (4.0*sy_cell[m] + sy_old_cell[m] + sy_new_cell[m])/6.0;
1088 sz_cell[m] = (4.0*sz_cell[m] + sz_old_cell[m] + sz_new_cell[m])/6.0;
1093 double sx_old_node[depos_order+1] = {0.};
1094 double sx_new_node[depos_order+1] = {0.};
1095 double sy_old_node[depos_order+1] = {0.};
1096 double sy_new_node[depos_order+1] = {0.};
1097 double sz_old_node[depos_order+1] = {0.};
1098 double sz_new_node[depos_order+1] = {0.};
1099 const int i0_node = compute_shape_factors_node( sx_old_node, sx_new_node, x0_old, x0_new );
1100 const int j0_node = compute_shape_factors_node( sy_old_node, sy_new_node, y0_old, y0_new );
1101 const int k0_node = compute_shape_factors_node( sz_old_node, sz_new_node, z0_old, z0_new );
1105 for (
int i=0;
i<=depos_order-1;
i++) {
1106 for (
int j=0; j<=depos_order; j++) {
1107 for (
int k=0; k<=depos_order; k++) {
1108 weight = sx_cell[
i]*( sy_old_node[j]*sz_old_node[k]*one_third
1109 + sy_old_node[j]*sz_new_node[k]*one_sixth
1110 + sy_new_node[j]*sz_old_node[k]*one_sixth
1111 + sy_new_node[j]*sz_new_node[k]*one_third )*seg_factor_x;
1112 Exp += Ex_arr(lo.
x+i0_cell+
i, lo.
y+j0_node+j, lo.
z+k0_node+k)*weight;
1118 for (
int i=0;
i<=depos_order;
i++) {
1119 for (
int j=0; j<=depos_order-1; j++) {
1120 for (
int k=0; k<=depos_order; k++) {
1121 weight = sy_cell[j]*( sx_old_node[
i]*sz_old_node[k]*one_third
1122 + sx_old_node[
i]*sz_new_node[k]*one_sixth
1123 + sx_new_node[
i]*sz_old_node[k]*one_sixth
1124 + sx_new_node[
i]*sz_new_node[k]*one_third )*seg_factor_y;
1125 Eyp += Ey_arr(lo.
x+i0_node+
i, lo.
y+j0_cell+j, lo.
z+k0_node+k)*weight;
1131 for (
int i=0;
i<=depos_order;
i++) {
1132 for (
int j=0; j<=depos_order; j++) {
1133 for (
int k=0; k<=depos_order-1; k++) {
1134 weight = sz_cell[k]*( sx_old_node[
i]*sy_old_node[j]*one_third
1135 + sx_old_node[
i]*sy_new_node[j]*one_sixth
1136 + sx_new_node[
i]*sy_old_node[j]*one_sixth
1137 + sx_new_node[
i]*sy_new_node[j]*one_third )*seg_factor_z;
1138 Ezp += Ez_arr(lo.
x+i0_node+
i, lo.
y+j0_node+j, lo.
z+k0_cell+k)*weight;
1144 if (ns < num_segments-1) {
1153 const int depos_order_B = 1;
1155 double sz_bar_node[depos_order_B+1] = {0.};
1156 double sz_bar_cell[depos_order_B+1] = {0.};
1157 const int k_bar_node = compute_shape_factor_B(sz_bar_node, z_bar);
1158 const int k_bar_cell = compute_shape_factor_B(sz_bar_cell, z_bar-0.5);
1159 double sy_bar_node[depos_order_B+1] = {0.};
1160 double sy_bar_cell[depos_order_B+1] = {0.};
1161 const int j_bar_node = compute_shape_factor_B(sy_bar_node, y_bar);
1162 const int j_bar_cell = compute_shape_factor_B(sy_bar_cell, y_bar-0.5);
1163 double sx_bar_node[depos_order_B+1] = {0.};
1164 double sx_bar_cell[depos_order_B+1] = {0.};
1165 const int i_bar_node = compute_shape_factor_B(sx_bar_node, x_bar);
1166 const int i_bar_cell = compute_shape_factor_B(sx_bar_cell, x_bar-0.5);
1169 for (
int i=0;
i<=depos_order_B;
i++) {
1170 for (
int j=0; j<=depos_order_B; j++) {
1171 for (
int k=0; k<=depos_order_B; k++) {
1172 weight =
static_cast<amrex::Real
>(sx_bar_node[
i]*sy_bar_cell[j]*sz_bar_cell[k]);
1173 Bxp += Bx_arr(lo.
x+i_bar_node+
i, lo.
y+j_bar_cell+j, lo.
z+k_bar_cell+k)*weight;
1175 weight =
static_cast<amrex::Real
>(sx_bar_cell[
i]*sy_bar_node[j]*sz_bar_cell[k]);
1176 Byp += By_arr(lo.
x+i_bar_cell+
i, lo.
y+j_bar_node+j, lo.
z+k_bar_cell+k)*weight;
1178 weight =
static_cast<amrex::Real
>(sx_bar_cell[
i]*sy_bar_cell[j]*sz_bar_node[k]);
1179 Bzp += Bz_arr(lo.
x+i_bar_cell+
i, lo.
y+j_bar_cell+j, lo.
z+k_bar_node+k)*weight;
1184 #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
1187 const auto i_old =
static_cast<int>(x_old-
shift);
1188 const auto i_new =
static_cast<int>(x_new-
shift);
1189 const int cell_crossings_x = std::abs(i_new-i_old);
1190 num_segments += cell_crossings_x;
1193 const auto k_old =
static_cast<int>(z_old-
shift);
1194 const auto k_new =
static_cast<int>(z_new-
shift);
1195 const int cell_crossings_z = std::abs(k_new-k_old);
1196 num_segments += cell_crossings_z;
1204 const double dxp = x_new - x_old;
1205 const double dzp = z_new - z_old;
1206 const auto dirX_sign =
static_cast<double>(dxp < 0. ? -1. : 1.);
1207 const auto dirZ_sign =
static_cast<double>(dzp < 0. ? -1. : 1.);
1208 double Xcell = 0., Zcell = 0.;
1209 if (num_segments > 1) {
1210 Xcell =
static_cast<double>(i_old) +
shift + 0.5*(1.-dirX_sign);
1211 Zcell =
static_cast<double>(k_old) +
shift + 0.5*(1.-dirZ_sign);
1217 double dxp_seg, dzp_seg;
1218 double x0_new, z0_new;
1219 double x0_old = x_old;
1220 double z0_old = z_old;
1222 for (
int ns=0; ns<num_segments; ns++) {
1224 if (ns == num_segments-1) {
1228 dxp_seg = x0_new - x0_old;
1229 dzp_seg = z0_new - z0_old;
1234 x0_new = Xcell + dirX_sign;
1235 z0_new = Zcell + dirZ_sign;
1236 dxp_seg = x0_new - x0_old;
1237 dzp_seg = z0_new - z0_old;
1239 if (dzp == 0. || std::abs(dxp_seg) < std::abs(dxp/dzp*dzp_seg)) {
1241 dzp_seg = dzp/dxp*dxp_seg;
1242 z0_new = z0_old + dzp_seg;
1246 dxp_seg = dxp/dzp*dzp_seg;
1247 x0_new = x0_old + dxp_seg;
1253 const auto seg_factor_x =
static_cast<double>(dxp == 0. ? 1. : dxp_seg/dxp);
1254 const auto seg_factor_z =
static_cast<double>(dzp == 0. ? 1. : dzp_seg/dzp);
1257 double sx_cell[depos_order] = {0.};
1258 double sz_cell[depos_order] = {0.};
1259 double const x0_bar = (x0_new + x0_old)/2.0;
1260 double const z0_bar = (z0_new + z0_old)/2.0;
1261 const int i0_cell = compute_shape_factor_cell(sx_cell, x0_bar-0.5);
1262 const int k0_cell = compute_shape_factor_cell(sz_cell, z0_bar-0.5);
1264 if constexpr (depos_order >= 3) {
1266 double sx_old_cell[depos_order] = {0.};
1267 double sx_new_cell[depos_order] = {0.};
1268 double sz_old_cell[depos_order] = {0.};
1269 double sz_new_cell[depos_order] = {0.};
1270 const int i0_cell_2 = compute_shape_factors_cell( sx_old_cell, sx_new_cell, x0_old-0.5, x0_new-0.5 );
1271 const int k0_cell_2 = compute_shape_factors_cell( sz_old_cell, sz_new_cell, z0_old-0.5, z0_new-0.5 );
1273 for (
int m=0; m<depos_order; m++) {
1274 sx_cell[m] = (4.0*sx_cell[m] + sx_old_cell[m] + sx_new_cell[m])/6.0;
1275 sz_cell[m] = (4.0*sz_cell[m] + sz_old_cell[m] + sz_new_cell[m])/6.0;
1280 double sx_old_node[depos_order+1] = {0.};
1281 double sx_new_node[depos_order+1] = {0.};
1282 double sz_old_node[depos_order+1] = {0.};
1283 double sz_new_node[depos_order+1] = {0.};
1284 const int i0_node = compute_shape_factors_node( sx_old_node, sx_new_node, x0_old, x0_new );
1285 const int k0_node = compute_shape_factors_node( sz_old_node, sz_new_node, z0_old, z0_new );
1289 for (
int i=0;
i<=depos_order-1;
i++) {
1290 for (
int k=0; k<=depos_order; k++) {
1291 weight = sx_cell[
i]*(sz_old_node[k] + sz_new_node[k])/2.0_rt*seg_factor_x;
1292 Exp += Ex_arr(lo.
x+i0_cell+
i, lo.
y+k0_node+k, 0, 0)*weight;
1293 #if defined(WARPX_DIM_RZ)
1295 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
1296 const auto dEx = (+ Ex_arr(lo.
x+i0_cell+
i, lo.
y+k0_node+k, 0, 2*imode-1)*xy_mid.
real()
1297 - Ex_arr(lo.
x+i0_cell+
i, lo.
y+k0_node+k, 0, 2*imode)*xy_mid.
imag());
1299 xy_mid = xy_mid*xy_mid0;
1306 const auto seg_factor_y = std::min(seg_factor_x,seg_factor_z);
1307 for (
int i=0;
i<=depos_order;
i++) {
1308 for (
int k=0; k<=depos_order; k++) {
1309 weight = ( sx_old_node[
i]*sz_old_node[k]*one_third
1310 + sx_old_node[
i]*sz_new_node[k]*one_sixth
1311 + sx_new_node[
i]*sz_old_node[k]*one_sixth
1312 + sx_new_node[
i]*sz_new_node[k]*one_third )*seg_factor_y;
1313 Eyp += Ey_arr(lo.
x+i0_node+
i, lo.
y+k0_node+k, 0, 0)*weight;
1314 #if defined(WARPX_DIM_RZ)
1316 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
1317 const auto dEy = (+ Ey_arr(lo.
x+i0_node+
i, lo.
y+k0_node+k, 0, 2*imode-1)*xy_mid.
real()
1318 - Ey_arr(lo.
x+i0_node+
i, lo.
y+k0_node+k, 0, 2*imode)*xy_mid.
imag());
1320 xy_mid = xy_mid*xy_mid0;
1327 for (
int i=0;
i<=depos_order;
i++) {
1328 for (
int k=0; k<=depos_order-1; k++) {
1329 weight = sz_cell[k]*(sx_old_node[
i] + sx_new_node[
i])/2.0_rt*seg_factor_z;
1330 Ezp += Ez_arr(lo.
x+i0_node+
i, lo.
y+k0_cell+k, 0, 0)*weight;
1331 #if defined(WARPX_DIM_RZ)
1333 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
1334 const auto dEz = (+ Ez_arr(lo.
x+i0_node+
i, lo.
y+k0_cell+k, 0, 2*imode-1)*xy_mid.
real()
1335 - Ez_arr(lo.
x+i0_node+
i, lo.
y+k0_cell+k, 0, 2*imode)*xy_mid.
imag());
1337 xy_mid = xy_mid*xy_mid0;
1344 if (ns < num_segments-1) {
1352 const int depos_order_B = 1;
1354 double sz_bar_node[depos_order_B+1] = {0.};
1355 double sz_bar_cell[depos_order_B+1] = {0.};
1356 const int k_bar_node = compute_shape_factor_B(sz_bar_node, z_bar);
1357 const int k_bar_cell = compute_shape_factor_B(sz_bar_cell, z_bar-0.5);
1358 double sx_bar_node[depos_order_B+1] = {0.};
1359 double sx_bar_cell[depos_order_B+1] = {0.};
1360 const int i_bar_node = compute_shape_factor_B(sx_bar_node, x_bar);
1361 const int i_bar_cell = compute_shape_factor_B(sx_bar_cell, x_bar-0.5);
1363 for (
int i=0;
i<=depos_order_B;
i++) {
1364 for (
int k=0; k<=depos_order_B; k++) {
1365 const auto weight_Bz =
static_cast<amrex::Real
>(sx_bar_cell[
i]*sz_bar_node[k]);
1366 Bzp += Bz_arr(lo.
x+i_bar_cell+
i, lo.
y+k_bar_node+k, 0, 0)*weight_Bz;
1368 const auto weight_Bx =
static_cast<amrex::Real
>(sx_bar_node[
i]*sz_bar_cell[k]);
1369 Bxp += Bx_arr(lo.
x+i_bar_node+
i, lo.
y+k_bar_cell+k, 0, 0)*weight_Bx;
1371 const auto weight_By =
static_cast<amrex::Real
>(sx_bar_cell[
i]*sz_bar_cell[k]);
1372 Byp += By_arr(lo.
x+i_bar_cell+
i, lo.
y+k_bar_cell+k, 0, 0)*weight_By;
1373 #if defined(WARPX_DIM_RZ)
1375 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
1376 const auto dBx = (+ Bx_arr(lo.
x+i_bar_node+
i, lo.
y+k_bar_cell+k, 0, 2*imode-1)*xy_mid.
real()
1377 - Bx_arr(lo.
x+i_bar_node+
i, lo.
y+k_bar_cell+k, 0, 2*imode)*xy_mid.
imag());
1378 const auto dBy = (+ By_arr(lo.
x+i_bar_cell+
i, lo.
y+k_bar_cell+k, 0, 2*imode-1)*xy_mid.
real()
1379 - By_arr(lo.
x+i_bar_cell+
i, lo.
y+k_bar_cell+k, 0, 2*imode)*xy_mid.
imag());
1380 const auto dBz = (+ Bz_arr(lo.
x+i_bar_cell+
i, lo.
y+k_bar_node+k, 0, 2*imode-1)*xy_mid.
real()
1381 - Bz_arr(lo.
x+i_bar_cell+
i, lo.
y+k_bar_node+k, 0, 2*imode)*xy_mid.
imag());
1382 Bxp += weight_Bx*dBx;
1383 Byp += weight_By*dBy;
1384 Bzp += weight_Bz*dBz;
1385 xy_mid = xy_mid*xy_mid0;
1394 const amrex::Real Exp_save = Exp;
1395 Exp = costheta_mid*Exp - sintheta_mid*Eyp;
1396 Eyp = costheta_mid*Eyp + sintheta_mid*Exp_save;
1397 const amrex::Real Bxp_save = Bxp;
1398 Bxp = costheta_mid*Bxp - sintheta_mid*Byp;
1399 Byp = costheta_mid*Byp + sintheta_mid*Bxp_save;
1403 #elif defined(WARPX_DIM_1D_Z)
1406 const auto k_old =
static_cast<int>(z_old-
shift);
1407 const auto k_new =
static_cast<int>(z_new-
shift);
1408 const int cell_crossings_z = std::abs(k_new-k_old);
1409 num_segments += cell_crossings_z;
1416 double const dzp = z_new - z_old;
1417 const auto dirZ_sign =
static_cast<double>(dzp < 0. ? -1. : 1.);
1418 double Zcell =
static_cast<double>(k_old) +
shift + 0.5*(1.-dirZ_sign);
1425 double z0_old = z_old;
1427 for (
int ns=0; ns<num_segments; ns++) {
1429 if (ns == num_segments-1) {
1431 dzp_seg = z0_new - z0_old;
1434 Zcell = Zcell + dirZ_sign;
1436 dzp_seg = z0_new - z0_old;
1440 const auto seg_factor =
static_cast<double>(dzp == 0. ? 1. : dzp_seg/dzp);
1443 double sz_cell[depos_order] = {0.};
1444 double const z0_bar = (z0_new + z0_old)/2.0;
1445 const int k0_cell = compute_shape_factor_cell( sz_cell, z0_bar-0.5 );
1447 if constexpr (depos_order >= 3) {
1449 double sz_old_cell[depos_order] = {0.};
1450 double sz_new_cell[depos_order] = {0.};
1451 const int k0_cell_2 = compute_shape_factors_cell( sz_old_cell, sz_new_cell, z0_old-0.5, z0_new-0.5 );
1453 for (
int m=0; m<depos_order; m++) {
1454 sz_cell[m] = (4.0*sz_cell[m] + sz_old_cell[m] + sz_new_cell[m])/6.0;
1459 double sz_old_node[depos_order+1] = {0.};
1460 double sz_new_node[depos_order+1] = {0.};
1461 const int k0_node = compute_shape_factors_node( sz_old_node, sz_new_node, z0_old, z0_new );
1464 for (
int k=0; k<=depos_order; k++) {
1465 auto weight = 0.5_rt*(sz_old_node[k] + sz_new_node[k])*seg_factor;
1466 Exp += Ex_arr(lo.
x+k0_node+k, 0, 0)*weight;
1467 Eyp += Ey_arr(lo.
x+k0_node+k, 0, 0)*weight;
1471 for (
int k=0; k<=depos_order-1; k++) {
1472 auto weight = sz_cell[k]*seg_factor;
1473 Ezp += Ez_arr(lo.
x+k0_cell+k, 0, 0)*weight;
1477 if (ns < num_segments-1) {
1484 const int depos_order_B = 1;
1486 double sz_bar_node[depos_order_B+1] = {0.};
1487 double sz_bar_cell[depos_order_B+1] = {0.};
1488 const int k_bar_node = compute_shape_factor_B(sz_bar_node, z_bar);
1489 const int k_bar_cell = compute_shape_factor_B(sz_bar_cell, z_bar-0.5_rt);
1492 for (
int k=0; k<=depos_order_B; k++) {
1493 weight =
static_cast<amrex::Real
>(sz_bar_node[k]);
1494 Bzp += Bz_arr(lo.
x+k_bar_node+k, 0, 0)*weight;
1496 weight =
static_cast<amrex::Real
>(sz_bar_cell[k]);
1497 Bxp += Bx_arr(lo.
x+k_bar_cell+k, 0, 0)*weight;
1498 Byp += By_arr(lo.
x+k_bar_cell+k, 0, 0)*weight;
1521 template <
int depos_order,
int lower_in_v>
1524 amrex::ParticleReal *
const Exp, amrex::ParticleReal *
const Eyp,
1525 amrex::ParticleReal *
const Ezp, amrex::ParticleReal *
const Bxp,
1526 amrex::ParticleReal *
const Byp, amrex::ParticleReal *
const Bzp,
1533 const long np_to_gather,
1537 const int n_rz_azimuthal_modes)
1560 amrex::ParticleReal xp, yp, zp;
1561 getPosition(ip, xp, yp, zp);
1562 getExternalEB(ip, Exp[ip], Eyp[ip], Ezp[ip], Bxp[ip], Byp[ip], Bzp[ip]);
1564 doGatherShapeN<depos_order, lower_in_v>(
1565 xp, yp, zp, Exp[ip], Eyp[ip], Ezp[ip], Bxp[ip], Byp[ip], Bzp[ip],
1566 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1567 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1568 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1592 const amrex::ParticleReal yp,
1593 const amrex::ParticleReal zp,
1594 amrex::ParticleReal& Exp,
1595 amrex::ParticleReal& Eyp,
1596 amrex::ParticleReal& Ezp,
1597 amrex::ParticleReal& Bxp,
1598 amrex::ParticleReal& Byp,
1599 amrex::ParticleReal& Bzp,
1615 const int n_rz_azimuthal_modes,
1617 const bool galerkin_interpolation)
1619 if (galerkin_interpolation) {
1621 doGatherShapeN<1,1>(xp, yp, zp, Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1622 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1623 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1624 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1625 }
else if (nox == 2) {
1626 doGatherShapeN<2,1>(xp, yp, zp, Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1627 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1628 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1629 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1630 }
else if (nox == 3) {
1631 doGatherShapeN<3,1>(xp, yp, zp, Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1632 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1633 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1634 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1635 }
else if (nox == 4) {
1636 doGatherShapeN<4,1>(xp, yp, zp, Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1637 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1638 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1639 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1643 doGatherShapeN<1,0>(xp, yp, zp, Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1644 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1645 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1646 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1647 }
else if (nox == 2) {
1648 doGatherShapeN<2,0>(xp, yp, zp, Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1649 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1650 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1651 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1652 }
else if (nox == 3) {
1653 doGatherShapeN<3,0>(xp, yp, zp, Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1654 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1655 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1656 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1657 }
else if (nox == 4) {
1658 doGatherShapeN<4,0>(xp, yp, zp, Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1659 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1660 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1661 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1688 const amrex::ParticleReal xp_n,
1689 const amrex::ParticleReal yp_n,
1690 const amrex::ParticleReal zp_n,
1691 const amrex::ParticleReal xp_nph,
1692 const amrex::ParticleReal yp_nph,
1693 const amrex::ParticleReal zp_nph,
1694 amrex::ParticleReal& Exp,
1695 amrex::ParticleReal& Eyp,
1696 amrex::ParticleReal& Ezp,
1697 amrex::ParticleReal& Bxp,
1698 amrex::ParticleReal& Byp,
1699 amrex::ParticleReal& Bzp,
1715 const int n_rz_azimuthal_modes,
1717 const int depos_type )
1719 if (depos_type==0) {
1721 doGatherShapeNEsirkepovStencilImplicit<1>(xp_n, yp_n, zp_n, xp_nph, yp_nph, zp_nph,
1722 Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1723 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1724 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1725 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1726 }
else if (nox == 2) {
1727 doGatherShapeNEsirkepovStencilImplicit<2>(xp_n, yp_n, zp_n, xp_nph, yp_nph, zp_nph,
1728 Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1729 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1730 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1731 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1732 }
else if (nox == 3) {
1733 doGatherShapeNEsirkepovStencilImplicit<3>(xp_n, yp_n, zp_n, xp_nph, yp_nph, zp_nph,
1734 Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1735 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1736 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1737 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1738 }
else if (nox == 4) {
1739 doGatherShapeNEsirkepovStencilImplicit<4>(xp_n, yp_n, zp_n, xp_nph, yp_nph, zp_nph,
1740 Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1741 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1742 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1743 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1746 else if (depos_type==3) {
1748 doGatherPicnicShapeN<1>(xp_n, yp_n, zp_n, xp_nph, yp_nph, zp_nph,
1749 Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1750 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1751 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1752 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1753 }
else if (nox == 2) {
1754 doGatherPicnicShapeN<2>(xp_n, yp_n, zp_n, xp_nph, yp_nph, zp_nph,
1755 Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1756 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1757 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1758 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1759 }
else if (nox == 3) {
1760 doGatherPicnicShapeN<3>(xp_n, yp_n, zp_n, xp_nph, yp_nph, zp_nph,
1761 Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1762 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1763 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1764 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1765 }
else if (nox == 4) {
1766 doGatherPicnicShapeN<4>(xp_n, yp_n, zp_n, xp_nph, yp_nph, zp_nph,
1767 Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1768 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1769 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1770 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1773 else if (depos_type==1) {
1775 doGatherShapeN<1,0>(xp_nph, yp_nph, zp_nph, Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1776 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1777 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1778 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1779 }
else if (nox == 2) {
1780 doGatherShapeN<2,0>(xp_nph, yp_nph, zp_nph, Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1781 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1782 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1783 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1784 }
else if (nox == 3) {
1785 doGatherShapeN<3,0>(xp_nph, yp_nph, zp_nph, Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1786 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1787 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1788 dinv, xyzmin, lo, n_rz_azimuthal_modes);
1789 }
else if (nox == 4) {
1790 doGatherShapeN<4,0>(xp_nph, yp_nph, zp_nph, Exp, Eyp, Ezp, Bxp, Byp, Bzp,
1791 ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
1792 ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
1793 dinv, xyzmin, lo, n_rz_azimuthal_modes);
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void doGatherPicnicShapeN([[maybe_unused]] const amrex::ParticleReal xp_n, [[maybe_unused]] const amrex::ParticleReal yp_n, const amrex::ParticleReal zp_n, [[maybe_unused]] const amrex::ParticleReal xp_nph, [[maybe_unused]] const amrex::ParticleReal yp_nph, const amrex::ParticleReal zp_nph, amrex::ParticleReal &Exp, amrex::ParticleReal &Eyp, amrex::ParticleReal &Ezp, amrex::ParticleReal &Bxp, amrex::ParticleReal &Byp, amrex::ParticleReal &Bzp, amrex::Array4< amrex::Real const > const &Ex_arr, amrex::Array4< amrex::Real const > const &Ey_arr, amrex::Array4< amrex::Real const > const &Ez_arr, amrex::Array4< amrex::Real const > const &Bx_arr, amrex::Array4< amrex::Real const > const &By_arr, amrex::Array4< amrex::Real const > const &Bz_arr, [[maybe_unused]] const amrex::IndexType Ex_type, [[maybe_unused]] const amrex::IndexType Ey_type, [[maybe_unused]] const amrex::IndexType Ez_type, [[maybe_unused]] const amrex::IndexType Bx_type, [[maybe_unused]] const amrex::IndexType By_type, [[maybe_unused]] const amrex::IndexType Bz_type, const amrex::XDim3 &dinv, const amrex::XDim3 &xyzmin, const amrex::Dim3 &lo, const int n_rz_azimuthal_modes)
Energy conserving field gather for thread thread_num for the implicit scheme This uses the same stenc...
Definition: FieldGather.H:863
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void doGatherShapeNImplicit(const amrex::ParticleReal xp_n, const amrex::ParticleReal yp_n, const amrex::ParticleReal zp_n, const amrex::ParticleReal xp_nph, const amrex::ParticleReal yp_nph, const amrex::ParticleReal zp_nph, amrex::ParticleReal &Exp, amrex::ParticleReal &Eyp, amrex::ParticleReal &Ezp, amrex::ParticleReal &Bxp, amrex::ParticleReal &Byp, amrex::ParticleReal &Bzp, amrex::Array4< amrex::Real const > const &ex_arr, amrex::Array4< amrex::Real const > const &ey_arr, amrex::Array4< amrex::Real const > const &ez_arr, amrex::Array4< amrex::Real const > const &bx_arr, amrex::Array4< amrex::Real const > const &by_arr, amrex::Array4< amrex::Real const > const &bz_arr, const amrex::IndexType ex_type, const amrex::IndexType ey_type, const amrex::IndexType ez_type, const amrex::IndexType bx_type, const amrex::IndexType by_type, const amrex::IndexType bz_type, const amrex::XDim3 &dinv, const amrex::XDim3 &xyzmin, const amrex::Dim3 &lo, const int n_rz_azimuthal_modes, const int nox, const int depos_type)
Field gather for a single particle.
Definition: FieldGather.H:1687
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void doGatherShapeNEsirkepovStencilImplicit([[maybe_unused]] const amrex::ParticleReal xp_n, [[maybe_unused]] const amrex::ParticleReal yp_n, const amrex::ParticleReal zp_n, [[maybe_unused]] const amrex::ParticleReal xp_nph, [[maybe_unused]] const amrex::ParticleReal yp_nph, const amrex::ParticleReal zp_nph, amrex::ParticleReal &Exp, amrex::ParticleReal &Eyp, amrex::ParticleReal &Ezp, amrex::ParticleReal &Bxp, amrex::ParticleReal &Byp, amrex::ParticleReal &Bzp, amrex::Array4< amrex::Real const > const &Ex_arr, amrex::Array4< amrex::Real const > const &Ey_arr, amrex::Array4< amrex::Real const > const &Ez_arr, amrex::Array4< amrex::Real const > const &Bx_arr, amrex::Array4< amrex::Real const > const &By_arr, amrex::Array4< amrex::Real const > const &Bz_arr, [[maybe_unused]] const amrex::IndexType Ex_type, [[maybe_unused]] const amrex::IndexType Ey_type, [[maybe_unused]] const amrex::IndexType Ez_type, [[maybe_unused]] const amrex::IndexType Bx_type, [[maybe_unused]] const amrex::IndexType By_type, [[maybe_unused]] const amrex::IndexType Bz_type, const amrex::XDim3 &dinv, const amrex::XDim3 &xyzmin, const amrex::Dim3 &lo, const int n_rz_azimuthal_modes)
Energy conserving field gather for thread thread_num for the implicit scheme This uses the same stenc...
Definition: FieldGather.H:446
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void doGatherShapeN([[maybe_unused]] const amrex::ParticleReal xp, [[maybe_unused]] const amrex::ParticleReal yp, [[maybe_unused]] const amrex::ParticleReal zp, amrex::ParticleReal &Exp, amrex::ParticleReal &Eyp, amrex::ParticleReal &Ezp, amrex::ParticleReal &Bxp, amrex::ParticleReal &Byp, amrex::ParticleReal &Bzp, amrex::Array4< amrex::Real const > const &ex_arr, amrex::Array4< amrex::Real const > const &ey_arr, amrex::Array4< amrex::Real const > const &ez_arr, amrex::Array4< amrex::Real const > const &bx_arr, amrex::Array4< amrex::Real const > const &by_arr, amrex::Array4< amrex::Real const > const &bz_arr, const amrex::IndexType ex_type, const amrex::IndexType ey_type, const amrex::IndexType ez_type, const amrex::IndexType bx_type, const amrex::IndexType by_type, const amrex::IndexType bz_type, const amrex::XDim3 &dinv, const amrex::XDim3 &xyzmin, const amrex::Dim3 &lo, [[maybe_unused]] const int n_rz_azimuthal_modes)
Field gather for a single particle.
Definition: FieldGather.H:38
AMREX_FORCE_INLINE Array4< Real const > array() const noexcept
const Box & box() const noexcept
AMREX_GPU_HOST_DEVICE IndexTypeND< dim > ixType() const noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > shift(const BoxND< dim > &b, int dir, int nzones) noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
std::enable_if_t< std::is_integral_v< T > > ParallelFor(TypeList< CTOs... >, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
i
Definition: check_interp_points_and_weights.py:174
Definition: ShapeFactors.H:168
Definition: ShapeFactors.H:29
Definition: ShapeFactors.H:95
Functor class that assigns external field values (E and B) to particles.
Definition: GetExternalFields.H:25
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T real() const noexcept
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T imag() const noexcept