8 #ifndef CURRENTDEPOSITION_H_ 9 #define CURRENTDEPOSITION_H_ 52 template <
int depos_order>
54 const amrex::ParticleReal *
const wp,
55 const amrex::ParticleReal *
const uxp,
56 const amrex::ParticleReal *
const uyp,
57 const amrex::ParticleReal *
const uzp,
58 const int *
const ion_lev,
62 const long np_to_depose,
63 const amrex::Real relative_time,
64 const std::array<amrex::Real,3>&
dx,
65 const std::array<amrex::Real,3>& xyzmin,
68 const int n_rz_azimuthal_modes,
70 const long load_balance_costs_update_algo)
72 #if !defined(WARPX_DIM_RZ) 76 #if !defined(AMREX_USE_GPU) 82 const bool do_ionization = ion_lev;
83 const amrex::Real dzi = 1.0_rt/dx[2];
84 #if defined(WARPX_DIM_1D_Z) 85 const amrex::Real invvol = dzi;
87 #if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) 88 const amrex::Real dxi = 1.0_rt/dx[0];
89 const amrex::Real invvol = dxi*dzi;
90 #elif defined(WARPX_DIM_3D) 91 const amrex::Real dxi = 1.0_rt/dx[0];
92 const amrex::Real dyi = 1.0_rt/dx[1];
93 const amrex::Real invvol = dxi*dyi*dzi;
96 #if (AMREX_SPACEDIM >= 2) 97 const amrex::Real xmin = xyzmin[0];
99 #if defined(WARPX_DIM_3D) 100 const amrex::Real ymin = xyzmin[1];
102 const amrex::Real zmin = xyzmin[2];
113 constexpr
int zdir = WARPX_ZINDEX;
118 #if defined(WARPX_USE_GPUCLOCK) 119 amrex::Real* cost_real =
nullptr;
128 #if defined(WARPX_USE_GPUCLOCK) 129 KernelTimer kernelTimer(cost && load_balance_costs_update_algo
134 const amrex::Real gaminv = 1.0_rt/std::sqrt(1.0_rt + uxp[ip]*uxp[ip]*clightsq
135 + uyp[ip]*uyp[ip]*clightsq
136 + uzp[ip]*uzp[ip]*clightsq);
137 amrex::Real wq = q*wp[ip];
142 amrex::ParticleReal xp, yp, zp;
143 GetPosition(ip, xp, yp, zp);
145 const amrex::Real vx = uxp[ip]*gaminv;
146 const amrex::Real vy = uyp[ip]*gaminv;
147 const amrex::Real vz = uzp[ip]*gaminv;
149 #if defined(WARPX_DIM_RZ) 152 const amrex::Real xpmid = xp + relative_time*vx;
153 const amrex::Real ypmid = yp + relative_time*vy;
154 const amrex::Real rpmid = std::sqrt(xpmid*xpmid + ypmid*ypmid);
155 amrex::Real costheta;
156 amrex::Real sintheta;
158 costheta = xpmid/rpmid;
159 sintheta = ypmid/rpmid;
165 const amrex::Real wqx = wq*invvol*(+vx*costheta + vy*sintheta);
166 const amrex::Real wqy = wq*invvol*(-vx*sintheta + vy*costheta);
168 const amrex::Real wqx = wq*invvol*vx;
169 const amrex::Real wqy = wq*invvol*vy;
171 const amrex::Real wqz = wq*invvol*vz;
175 #if (AMREX_SPACEDIM >= 2) 178 #if defined(WARPX_DIM_RZ) 180 const double xmid = (rpmid - xmin)*dxi;
182 const double xmid = ((xp - xmin) + relative_time*vx)*dxi;
189 double sx_node[depos_order + 1] = {0.};
190 double sx_cell[depos_order + 1] = {0.};
193 if (jx_type[0] == NODE || jy_type[0] == NODE || jz_type[0] == NODE) {
194 j_node = compute_shape_factor(sx_node, xmid);
196 if (jx_type[0] == CELL || jy_type[0] == CELL || jz_type[0] == CELL) {
197 j_cell = compute_shape_factor(sx_cell, xmid - 0.5);
200 amrex::Real sx_jx[depos_order + 1] = {0._rt};
201 amrex::Real sx_jy[depos_order + 1] = {0._rt};
202 amrex::Real sx_jz[depos_order + 1] = {0._rt};
203 for (
int ix=0; ix<=depos_order; ix++)
205 sx_jx[ix] = ((jx_type[0] == NODE) ? amrex::Real(sx_node[ix]) : amrex::Real(sx_cell[ix]));
206 sx_jy[ix] = ((jy_type[0] == NODE) ? amrex::Real(sx_node[ix]) : amrex::Real(sx_cell[ix]));
207 sx_jz[ix] = ((jz_type[0] == NODE) ? amrex::Real(sx_node[ix]) : amrex::Real(sx_cell[ix]));
210 int const j_jx = ((jx_type[0] == NODE) ? j_node : j_cell);
211 int const j_jy = ((jy_type[0] == NODE) ? j_node : j_cell);
212 int const j_jz = ((jz_type[0] == NODE) ? j_node : j_cell);
213 #endif //AMREX_SPACEDIM >= 2 215 #if defined(WARPX_DIM_3D) 218 const double ymid = ((yp - ymin) + relative_time*vy)*dyi;
219 double sy_node[depos_order + 1] = {0.};
220 double sy_cell[depos_order + 1] = {0.};
223 if (jx_type[1] == NODE || jy_type[1] == NODE || jz_type[1] == NODE) {
224 k_node = compute_shape_factor(sy_node, ymid);
226 if (jx_type[1] == CELL || jy_type[1] == CELL || jz_type[1] == CELL) {
227 k_cell = compute_shape_factor(sy_cell, ymid - 0.5);
229 amrex::Real sy_jx[depos_order + 1] = {0._rt};
230 amrex::Real sy_jy[depos_order + 1] = {0._rt};
231 amrex::Real sy_jz[depos_order + 1] = {0._rt};
232 for (
int iy=0; iy<=depos_order; iy++)
234 sy_jx[iy] = ((jx_type[1] == NODE) ? amrex::Real(sy_node[iy]) : amrex::Real(sy_cell[iy]));
235 sy_jy[iy] = ((jy_type[1] == NODE) ? amrex::Real(sy_node[iy]) : amrex::Real(sy_cell[iy]));
236 sy_jz[iy] = ((jz_type[1] == NODE) ? amrex::Real(sy_node[iy]) : amrex::Real(sy_cell[iy]));
238 int const k_jx = ((jx_type[1] == NODE) ? k_node : k_cell);
239 int const k_jy = ((jy_type[1] == NODE) ? k_node : k_cell);
240 int const k_jz = ((jz_type[1] == NODE) ? k_node : k_cell);
245 const double zmid = ((zp - zmin) + relative_time*vz)*dzi;
246 double sz_node[depos_order + 1] = {0.};
247 double sz_cell[depos_order + 1] = {0.};
250 if (jx_type[zdir] == NODE || jy_type[zdir] == NODE || jz_type[zdir] == NODE) {
251 l_node = compute_shape_factor(sz_node, zmid);
253 if (jx_type[zdir] == CELL || jy_type[zdir] == CELL || jz_type[zdir] == CELL) {
254 l_cell = compute_shape_factor(sz_cell, zmid - 0.5);
256 amrex::Real sz_jx[depos_order + 1] = {0._rt};
257 amrex::Real sz_jy[depos_order + 1] = {0._rt};
258 amrex::Real sz_jz[depos_order + 1] = {0._rt};
259 for (
int iz=0; iz<=depos_order; iz++)
261 sz_jx[iz] = ((jx_type[zdir] == NODE) ? amrex::Real(sz_node[iz]) : amrex::Real(sz_cell[iz]));
262 sz_jy[iz] = ((jy_type[zdir] == NODE) ? amrex::Real(sz_node[iz]) : amrex::Real(sz_cell[iz]));
263 sz_jz[iz] = ((jz_type[zdir] == NODE) ? amrex::Real(sz_node[iz]) : amrex::Real(sz_cell[iz]));
265 int const l_jx = ((jx_type[zdir] == NODE) ? l_node : l_cell);
266 int const l_jy = ((jy_type[zdir] == NODE) ? l_node : l_cell);
267 int const l_jz = ((jz_type[zdir] == NODE) ? l_node : l_cell);
270 #if defined(WARPX_DIM_1D_Z) 271 for (
int iz=0; iz<=depos_order; iz++){
273 &jx_arr(lo.
x+l_jx+iz, 0, 0, 0),
276 &jy_arr(lo.
x+l_jy+iz, 0, 0, 0),
279 &jz_arr(lo.
x+l_jz+iz, 0, 0, 0),
283 #if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) 284 for (
int iz=0; iz<=depos_order; iz++){
285 for (
int ix=0; ix<=depos_order; ix++){
287 &jx_arr(lo.
x+j_jx+ix, lo.
y+l_jx+iz, 0, 0),
288 sx_jx[ix]*sz_jx[iz]*wqx);
290 &jy_arr(lo.
x+j_jy+ix, lo.
y+l_jy+iz, 0, 0),
291 sx_jy[ix]*sz_jy[iz]*wqy);
293 &jz_arr(lo.
x+j_jz+ix, lo.
y+l_jz+iz, 0, 0),
294 sx_jz[ix]*sz_jz[iz]*wqz);
295 #if defined(WARPX_DIM_RZ) 297 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
310 #elif defined(WARPX_DIM_3D) 311 for (
int iz=0; iz<=depos_order; iz++){
312 for (
int iy=0; iy<=depos_order; iy++){
313 for (
int ix=0; ix<=depos_order; ix++){
315 &jx_arr(lo.
x+j_jx+ix, lo.
y+k_jx+iy, lo.
z+l_jx+iz),
316 sx_jx[ix]*sy_jx[iy]*sz_jx[iz]*wqx);
318 &jy_arr(lo.
x+j_jy+ix, lo.
y+k_jy+iy, lo.
z+l_jy+iz),
319 sx_jy[ix]*sy_jy[iy]*sz_jy[iz]*wqy);
321 &jz_arr(lo.
x+j_jz+ix, lo.
y+k_jz+iy, lo.
z+l_jz+iz),
322 sx_jz[ix]*sy_jz[iy]*sz_jz[iz]*wqz);
329 #if defined(WARPX_USE_GPUCLOCK) 364 template <
int depos_order>
366 const amrex::ParticleReal *
const wp,
367 const amrex::ParticleReal *
const uxp,
368 const amrex::ParticleReal *
const uyp,
369 const amrex::ParticleReal *
const uzp,
370 const int *
const ion_lev,
374 const long np_to_depose,
375 const amrex::Real
dt,
376 const amrex::Real relative_time,
377 const std::array<amrex::Real,3>&
dx,
378 const std::array<amrex::Real, 3> xyzmin,
381 const int n_rz_azimuthal_modes,
382 amrex::Real *
const cost,
383 const long load_balance_costs_update_algo)
385 using namespace amrex;
386 #if !defined(WARPX_DIM_RZ) 390 #if !defined(AMREX_USE_GPU) 396 bool const do_ionization = ion_lev;
397 #if !defined(WARPX_DIM_1D_Z) 398 Real
const dxi = 1.0_rt / dx[0];
400 #if !defined(WARPX_DIM_1D_Z) 401 Real
const xmin = xyzmin[0];
403 #if defined(WARPX_DIM_3D) 404 Real
const dyi = 1.0_rt / dx[1];
405 Real
const ymin = xyzmin[1];
407 Real
const dzi = 1.0_rt / dx[2];
408 Real
const zmin = xyzmin[2];
410 #if defined(WARPX_DIM_3D) 411 Real
const invdtdx = 1.0_rt / (dt*dx[1]*dx[2]);
412 Real
const invdtdy = 1.0_rt / (dt*dx[0]*dx[2]);
413 Real
const invdtdz = 1.0_rt / (dt*dx[0]*dx[1]);
414 #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) 415 Real
const invdtdx = 1.0_rt / (dt*dx[2]);
416 Real
const invdtdz = 1.0_rt / (dt*dx[0]);
417 Real
const invvol = 1.0_rt / (dx[0]*dx[2]);
418 #elif defined(WARPX_DIM_1D_Z) 419 Real
const invdtdz = 1.0_rt / (dt*dx[0]);
420 Real
const invvol = 1.0_rt / (dx[2]);
423 #if defined(WARPX_DIM_RZ) 428 #if !defined(WARPX_DIM_1D_Z) 429 Real constexpr one_third = 1.0_rt / 3.0_rt;
430 Real constexpr one_sixth = 1.0_rt / 6.0_rt;
434 #if defined(WARPX_USE_GPUCLOCK) 435 amrex::Real* cost_real =
nullptr;
444 #if defined(WARPX_USE_GPUCLOCK) 445 KernelTimer kernelTimer(cost && load_balance_costs_update_algo
450 Real
const gaminv = 1.0_rt/std::sqrt(1.0_rt + uxp[ip]*uxp[ip]*clightsq
451 + uyp[ip]*uyp[ip]*clightsq
452 + uzp[ip]*uzp[ip]*clightsq);
460 ParticleReal xp, yp, zp;
461 GetPosition(ip, xp, yp, zp);
463 #if !defined(WARPX_DIM_1D_Z) 464 Real
const wqx = wq*invdtdx;
466 #if defined(WARPX_DIM_3D) 467 Real
const wqy = wq*invdtdy;
469 Real
const wqz = wq*invdtdz;
472 #if defined(WARPX_DIM_RZ) 473 Real
const xp_new = xp + (relative_time + 0.5_rt*
dt)*uxp[ip]*gaminv;
474 Real
const yp_new = yp + (relative_time + 0.5_rt*
dt)*uyp[ip]*gaminv;
475 Real
const xp_mid = xp_new - 0.5_rt*dt*uxp[ip]*gaminv;
476 Real
const yp_mid = yp_new - 0.5_rt*dt*uyp[ip]*gaminv;
477 Real
const xp_old = xp_new - dt*uxp[ip]*gaminv;
478 Real
const yp_old = yp_new - dt*uyp[ip]*gaminv;
479 Real
const rp_new = std::sqrt(xp_new*xp_new + yp_new*yp_new);
480 Real
const rp_mid = std::sqrt(xp_mid*xp_mid + yp_mid*yp_mid);
481 Real
const rp_old = std::sqrt(xp_old*xp_old + yp_old*yp_old);
482 Real costheta_new, sintheta_new;
483 if (rp_new > 0._rt) {
484 costheta_new = xp_new/rp_new;
485 sintheta_new = yp_new/rp_new;
487 costheta_new = 1._rt;
488 sintheta_new = 0._rt;
490 amrex::Real costheta_mid, sintheta_mid;
491 if (rp_mid > 0._rt) {
492 costheta_mid = xp_mid/rp_mid;
493 sintheta_mid = yp_mid/rp_mid;
495 costheta_mid = 1._rt;
496 sintheta_mid = 0._rt;
498 amrex::Real costheta_old, sintheta_old;
499 if (rp_old > 0._rt) {
500 costheta_old = xp_old/rp_old;
501 sintheta_old = yp_old/rp_old;
503 costheta_old = 1._rt;
504 sintheta_old = 0._rt;
510 double const x_new = (rp_new - xmin)*dxi;
511 double const x_old = (rp_old - xmin)*dxi;
513 #if !defined(WARPX_DIM_1D_Z) 515 double const x_new = (xp - xmin + (relative_time + 0.5_rt*
dt)*uxp[ip]*gaminv)*dxi;
516 double const x_old = x_new - dt*dxi*uxp[ip]*gaminv;
519 #if defined(WARPX_DIM_3D) 521 double const y_new = (yp - ymin + (relative_time + 0.5_rt*
dt)*uyp[ip]*gaminv)*dyi;
522 double const y_old = y_new - dt*dyi*uyp[ip]*gaminv;
525 double const z_new = (zp - zmin + (relative_time + 0.5_rt*
dt)*uzp[ip]*gaminv)*dzi;
526 double const z_old = z_new - dt*dzi*uzp[ip]*gaminv;
528 #if defined(WARPX_DIM_RZ) 529 Real
const vy = (-uxp[ip]*sintheta_mid + uyp[ip]*costheta_mid)*gaminv;
530 #elif defined(WARPX_DIM_XZ) 531 Real
const vy = uyp[ip]*gaminv;
532 #elif defined(WARPX_DIM_1D_Z) 533 Real
const vx = uxp[ip]*gaminv;
534 Real
const vy = uyp[ip]*gaminv;
542 #if !defined(WARPX_DIM_1D_Z) 543 double sx_new[depos_order + 3] = {0.};
544 double sx_old[depos_order + 3] = {0.};
546 #if defined(WARPX_DIM_3D) 548 double sy_new[depos_order + 3] = {0.};
549 double sy_old[depos_order + 3] = {0.};
552 double sz_new[depos_order + 3] = {0.};
553 double sz_old[depos_order + 3] = {0.};
561 #if !defined(WARPX_DIM_1D_Z) 562 const int i_new = compute_shape_factor(sx_new+1, x_new);
563 const int i_old = compute_shifted_shape_factor(sx_old, x_old, i_new);
565 #if defined(WARPX_DIM_3D) 566 const int j_new = compute_shape_factor(sy_new+1, y_new);
567 const int j_old = compute_shifted_shape_factor(sy_old, y_old, j_new);
569 const int k_new = compute_shape_factor(sz_new+1, z_new);
570 const int k_old = compute_shifted_shape_factor(sz_old, z_old, k_new);
573 #if !defined(WARPX_DIM_1D_Z) 574 int dil = 1, diu = 1;
575 if (i_old < i_new) dil = 0;
576 if (i_old > i_new) diu = 0;
578 #if defined(WARPX_DIM_3D) 579 int djl = 1, dju = 1;
580 if (j_old < j_new) djl = 0;
581 if (j_old > j_new) dju = 0;
583 int dkl = 1, dku = 1;
584 if (k_old < k_new) dkl = 0;
585 if (k_old > k_new) dku = 0;
587 #if defined(WARPX_DIM_3D) 589 for (
int k=dkl; k<=depos_order+2-dku; k++) {
590 for (
int j=djl; j<=depos_order+2-dju; j++) {
591 amrex::Real sdxi = 0._rt;
592 for (
int i=dil;
i<=depos_order+1-diu;
i++) {
593 sdxi += wqx*(sx_old[
i] - sx_new[
i])*(
594 one_third*(sy_new[j]*sz_new[k] + sy_old[j]*sz_old[k])
595 +one_sixth*(sy_new[j]*sz_old[k] + sy_old[j]*sz_new[k]));
600 for (
int k=dkl; k<=depos_order+2-dku; k++) {
601 for (
int i=dil;
i<=depos_order+2-diu;
i++) {
602 amrex::Real sdyj = 0._rt;
603 for (
int j=djl; j<=depos_order+1-dju; j++) {
604 sdyj += wqy*(sy_old[j] - sy_new[j])*(
605 one_third*(sx_new[
i]*sz_new[k] + sx_old[
i]*sz_old[k])
606 +one_sixth*(sx_new[
i]*sz_old[k] + sx_old[
i]*sz_new[k]));
611 for (
int j=djl; j<=depos_order+2-dju; j++) {
612 for (
int i=dil;
i<=depos_order+2-diu;
i++) {
613 amrex::Real sdzk = 0._rt;
614 for (
int k=dkl; k<=depos_order+1-dku; k++) {
615 sdzk += wqz*(sz_old[k] - sz_new[k])*(
616 one_third*(sx_new[
i]*sy_new[j] + sx_old[
i]*sy_old[j])
617 +one_sixth*(sx_new[
i]*sy_old[j] + sx_old[
i]*sy_new[j]));
623 #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) 625 for (
int k=dkl; k<=depos_order+2-dku; k++) {
626 amrex::Real sdxi = 0._rt;
627 for (
int i=dil;
i<=depos_order+1-diu;
i++) {
628 sdxi += wqx*(sx_old[
i] - sx_new[
i])*0.5_rt*(sz_new[k] + sz_old[k]);
630 #if defined(WARPX_DIM_RZ) 632 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
634 const Complex djr_cmplx = 2._rt *sdxi*xy_mid;
637 xy_mid = xy_mid*xy_mid0;
642 for (
int k=dkl; k<=depos_order+2-dku; k++) {
643 for (
int i=dil;
i<=depos_order+2-diu;
i++) {
644 Real
const sdyj = wq*vy*invvol*(
645 one_third*(sx_new[
i]*sz_new[k] + sx_old[
i]*sz_old[k])
646 +one_sixth*(sx_new[
i]*sz_old[k] + sx_old[
i]*sz_new[k]));
648 #if defined(WARPX_DIM_RZ) 653 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
656 const Complex djt_cmplx = -2._rt * I*(i_new-1 +
i + xmin*dxi)*wq*invdtdx/(amrex::Real)imode
657 *(
Complex(sx_new[
i]*sz_new[k], 0._rt)*(xy_new - xy_mid)
658 +
Complex(sx_old[
i]*sz_old[k], 0._rt)*(xy_mid - xy_old));
661 xy_new = xy_new*xy_new0;
662 xy_mid = xy_mid*xy_mid0;
663 xy_old = xy_old*xy_old0;
668 for (
int i=dil;
i<=depos_order+2-diu;
i++) {
670 for (
int k=dkl; k<=depos_order+1-dku; k++) {
671 sdzk += wqz*(sz_old[k] - sz_new[k])*0.5_rt*(sx_new[
i] + sx_old[
i]);
673 #if defined(WARPX_DIM_RZ) 675 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
677 const Complex djz_cmplx = 2._rt * sdzk * xy_mid;
680 xy_mid = xy_mid*xy_mid0;
685 #elif defined(WARPX_DIM_1D_Z) 687 for (
int k=dkl; k<=depos_order+2-dku; k++) {
688 amrex::Real sdxi = 0._rt;
689 sdxi += wq*vx*invvol*0.5_rt*(sz_old[k] + sz_new[k]);
692 for (
int k=dkl; k<=depos_order+2-dku; k++) {
693 amrex::Real sdyj = 0._rt;
694 sdyj += wq*vy*invvol*0.5_rt*(sz_old[k] + sz_new[k]);
697 for (
int k=dkl; k<=depos_order+1-dku; k++) {
698 amrex::Real sdzk = 0._rt;
699 sdzk += wqz*(sz_old[k] - sz_new[k]);
705 #if defined(WARPX_USE_GPUCLOCK) 743 template <
int depos_order>
745 const amrex::ParticleReal*
const wp,
746 const amrex::ParticleReal*
const uxp,
747 const amrex::ParticleReal*
const uyp,
748 const amrex::ParticleReal*
const uzp,
749 const int*
const ion_lev,
753 const long np_to_depose,
754 const amrex::Real
dt,
755 const amrex::Real relative_time,
756 const std::array<amrex::Real,3>&
dx,
757 const std::array<amrex::Real,3>& xyzmin,
760 const int n_rz_azimuthal_modes,
762 const long load_balance_costs_update_algo)
764 #if defined(WARPX_DIM_RZ) 766 wp, uxp, uyp, uzp, ion_lev, jx_fab, jy_fab, jz_fab,
767 np_to_depose, dt, relative_time, dx, xyzmin, lo, q, n_rz_azimuthal_modes);
768 amrex::Abort(
"Vay deposition not implemented in RZ geometry");
771 #if defined(WARPX_DIM_1D_Z) 773 wp, uxp, uyp, uzp, ion_lev, jx_fab, jy_fab, jz_fab,
774 np_to_depose, dt, relative_time, dx, xyzmin, lo, q, n_rz_azimuthal_modes);
775 amrex::Abort(
"Vay deposition not implemented in cartesian 1D geometry");
778 #if !defined(AMREX_USE_GPU) 782 #if !(defined WARPX_DIM_RZ || defined WARPX_DIM_1D_Z) 786 const bool do_ionization = ion_lev;
789 const amrex::Real dxi = 1._rt / dx[0];
790 const amrex::Real dzi = 1._rt / dx[2];
791 #if defined(WARPX_DIM_3D) 792 const amrex::Real dyi = 1._rt / dx[1];
796 const amrex::Real invdt = 1._rt /
dt;
799 #if defined(WARPX_DIM_XZ) 800 const amrex::Real invvol = dxi * dzi;
801 #elif defined(WARPX_DIM_3D) 802 const amrex::Real invvol = dxi * dyi * dzi;
806 const amrex::Real xmin = xyzmin[0];
807 const amrex::Real zmin = xyzmin[2];
808 #if defined(WARPX_DIM_3D) 809 const amrex::Real ymin = xyzmin[1];
813 #if defined(WARPX_DIM_3D) 814 const amrex::Real onethird = 1._rt / 3._rt;
815 const amrex::Real onesixth = 1._rt / 6._rt;
827 #if defined(WARPX_USE_GPUCLOCK) 828 amrex::Real* cost_real =
nullptr;
836 #if defined(WARPX_USE_GPUCLOCK) 837 KernelTimer kernelTimer(cost && load_balance_costs_update_algo
842 const amrex::Real invgam = 1._rt / std::sqrt(1._rt + uxp[ip] * uxp[ip] * invcsq
843 + uyp[ip] * uyp[ip] * invcsq
844 + uzp[ip] * uzp[ip] * invcsq);
846 amrex::Real wq = q * wp[ip];
847 if (do_ionization) wq *= ion_lev[ip];
850 amrex::ParticleReal xp, yp, zp;
851 GetPosition(ip, xp, yp, zp);
854 const amrex::Real vx = uxp[ip] * invgam;
855 const amrex::Real vy = uyp[ip] * invgam;
856 const amrex::Real vz = uzp[ip] * invgam;
859 xp += relative_time * vx;
860 yp += relative_time * vy;
861 zp += relative_time * vz;
864 #if defined(WARPX_DIM_XZ) 865 const amrex::Real wqy = wq * vy * invvol;
870 double const x_new = (xp - xmin + 0.5_rt*dt*vx) * dxi;
871 double const x_old = (xp - xmin - 0.5_rt*dt*vx) * dxi;
872 #if defined(WARPX_DIM_3D) 874 double const y_new = (yp - ymin + 0.5_rt*dt*vy) * dyi;
875 double const y_old = (yp - ymin - 0.5_rt*dt*vy) * dyi;
878 double const z_new = (zp - zmin + 0.5_rt*dt*vz) * dzi;
879 double const z_old = (zp - zmin - 0.5_rt*dt*vz) * dzi;
883 double sx_new[depos_order+1] = {0.};
884 double sx_old[depos_order+1] = {0.};
885 #if defined(WARPX_DIM_3D) 887 double sy_new[depos_order+1] = {0.};
888 double sy_old[depos_order+1] = {0.};
891 double sz_new[depos_order+1] = {0.};
892 double sz_old[depos_order+1] = {0.};
899 const int i_new = compute_shape_factor(sx_new, x_new);
900 #if defined(WARPX_DIM_3D) 903 const int j_new = compute_shape_factor(sy_new, y_new);
907 const int k_new = compute_shape_factor(sz_new, z_new);
913 const int i_old = compute_shape_factor(sx_old, x_old);
914 #if defined(WARPX_DIM_3D) 917 const int j_old = compute_shape_factor(sy_old, y_old);
921 const int k_old = compute_shape_factor(sz_old, z_old);
924 #if defined(WARPX_DIM_XZ) 926 for (
int k=0; k<=depos_order; k++) {
927 for (
int i=0;
i<=depos_order;
i++) {
931 auto const sxn_szn =
static_cast<amrex::Real
>(sx_new[
i] * sz_new[k]);
932 auto const sxo_szn =
static_cast<amrex::Real
>(sx_old[
i] * sz_new[k]);
933 auto const sxn_szo =
static_cast<amrex::Real
>(sx_new[
i] * sz_old[k]);
934 auto const sxo_szo =
static_cast<amrex::Real
>(sx_old[
i] * sz_old[k]);
938 wq * invvol * invdt * 0.5_rt * sxn_szn);
941 - wq * invvol * invdt * 0.5_rt * sxo_szn);
944 wq * invvol * invdt * 0.5_rt * sxn_szo);
947 - wq * invvol * invdt * 0.5_rt * sxo_szo);
951 wqy * 0.25_rt * sxn_szn);
954 wqy * 0.25_rt * sxn_szo);
957 wqy * 0.25_rt * sxo_szn);
960 wqy * 0.25_rt * sxo_szo);
964 wq * invvol * invdt * 0.5_rt * sxn_szn);
967 - wq * invvol * invdt * 0.5_rt * sxn_szo);
970 wq * invvol * invdt * 0.5_rt * sxo_szn);
973 - wq * invvol * invdt * 0.5_rt * sxo_szo);
977 #elif defined(WARPX_DIM_3D) 979 for (
int k=0; k<=depos_order; k++) {
980 for (
int j=0; j<=depos_order; j++) {
982 auto const syn_szn =
static_cast<amrex::Real
>(sy_new[j] * sz_new[k]);
983 auto const syo_szn =
static_cast<amrex::Real
>(sy_old[j] * sz_new[k]);
984 auto const syn_szo =
static_cast<amrex::Real
>(sy_new[j] * sz_old[k]);
985 auto const syo_szo =
static_cast<amrex::Real
>(sy_old[j] * sz_old[k]);
987 for (
int i=0;
i<=depos_order;
i++) {
989 auto const sxn_syn_szn =
static_cast<amrex::Real
>(sx_new[
i]) * syn_szn;
990 auto const sxo_syn_szn =
static_cast<amrex::Real
>(sx_old[
i]) * syn_szn;
991 auto const sxn_syo_szn =
static_cast<amrex::Real
>(sx_new[
i]) * syo_szn;
992 auto const sxo_syo_szn =
static_cast<amrex::Real
>(sx_old[
i]) * syo_szn;
993 auto const sxn_syn_szo =
static_cast<amrex::Real
>(sx_new[
i]) * syn_szo;
994 auto const sxo_syn_szo =
static_cast<amrex::Real
>(sx_old[
i]) * syn_szo;
995 auto const sxn_syo_szo =
static_cast<amrex::Real
>(sx_new[
i]) * syo_szo;
996 auto const sxo_syo_szo =
static_cast<amrex::Real
>(sx_old[
i]) * syo_szo;
1000 wq * invvol * invdt * onethird * sxn_syn_szn);
1003 - wq * invvol * invdt * onethird * sxo_syn_szn);
1006 wq * invvol * invdt * onesixth * sxn_syo_szn);
1009 - wq * invvol * invdt * onesixth * sxo_syo_szn);
1012 wq * invvol * invdt * onesixth * sxn_syn_szo);
1015 - wq * invvol * invdt * onesixth * sxo_syn_szo);
1018 wq * invvol * invdt * onethird * sxn_syo_szo);
1021 - wq * invvol * invdt * onethird * sxo_syo_szo);
1025 wq * invvol * invdt * onethird * sxn_syn_szn);
1028 - wq * invvol * invdt * onethird * sxn_syo_szn);
1031 wq * invvol * invdt * onesixth * sxo_syn_szn);
1034 - wq * invvol * invdt * onesixth * sxo_syo_szn);
1037 wq * invvol * invdt * onesixth * sxn_syn_szo);
1040 - wq * invvol * invdt * onesixth * sxn_syo_szo);
1043 wq * invvol * invdt * onethird * sxo_syn_szo);
1046 - wq * invvol * invdt * onethird * sxo_syo_szo);
1050 wq * invvol * invdt * onethird * sxn_syn_szn);
1053 - wq * invvol * invdt * onethird * sxn_syn_szo);
1056 wq * invvol * invdt * onesixth * sxo_syn_szn);
1059 - wq * invvol * invdt * onesixth * sxo_syn_szo);
1062 wq * invvol * invdt * onesixth * sxn_syo_szn);
1065 - wq * invvol * invdt * onesixth * sxn_syo_szo);
1068 wq * invvol * invdt * onethird * sxo_syo_szn);
1071 - wq * invvol * invdt * onethird * sxo_syo_szo);
1077 # if defined(WARPX_USE_GPUCLOCK) 1080 *cost += *cost_real;
1084 #endif // #if !(defined WARPX_DIM_RZ || defined WARPX_DIM_1D_Z) 1086 #endif // CURRENTDEPOSITION_H_
const Box & box() const noexcept
amrex::GpuComplex< amrex::Real > Complex
Definition: WarpX_Complex.H:22
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void AddNoRet(T *const sum, T const value) noexcept
AMREX_FORCE_INLINE Array4< T const > array() const noexcept
Definition: WarpXAlgorithmSelection.H:107
static constexpr auto c
vacuum speed of light [m/s]
Definition: constant.H:44
int dx
Definition: compute_domain.py:35
int dt
Definition: Stencil.py:468
void doDepositionShapeN(const GetParticlePosition &GetPosition, const amrex::ParticleReal *const wp, const amrex::ParticleReal *const uxp, const amrex::ParticleReal *const uyp, const amrex::ParticleReal *const uzp, const int *const ion_lev, amrex::FArrayBox &jx_fab, amrex::FArrayBox &jy_fab, amrex::FArrayBox &jz_fab, const long np_to_depose, const amrex::Real relative_time, const std::array< amrex::Real, 3 > &dx, const std::array< amrex::Real, 3 > &xyzmin, const amrex::Dim3 lo, const amrex::Real q, const int n_rz_azimuthal_modes, amrex::Real *cost, const long load_balance_costs_update_algo)
Current Deposition for thread thread_num.
Definition: CurrentDeposition.H:53
void doEsirkepovDepositionShapeN(const GetParticlePosition &GetPosition, const amrex::ParticleReal *const wp, const amrex::ParticleReal *const uxp, const amrex::ParticleReal *const uyp, const amrex::ParticleReal *const uzp, const int *const ion_lev, const amrex::Array4< amrex::Real > &Jx_arr, const amrex::Array4< amrex::Real > &Jy_arr, const amrex::Array4< amrex::Real > &Jz_arr, const long np_to_depose, const amrex::Real dt, const amrex::Real relative_time, const std::array< amrex::Real, 3 > &dx, const std::array< amrex::Real, 3 > xyzmin, const amrex::Dim3 lo, const amrex::Real q, const int n_rz_azimuthal_modes, amrex::Real *const cost, const long load_balance_costs_update_algo)
Esirkepov Current Deposition for thread thread_num.
Definition: CurrentDeposition.H:365
Definition: ShapeFactors.H:81
virtual void free(void *pt)=0
void doVayDepositionShapeN(const GetParticlePosition &GetPosition, const amrex::ParticleReal *const wp, const amrex::ParticleReal *const uxp, const amrex::ParticleReal *const uyp, const amrex::ParticleReal *const uzp, const int *const ion_lev, amrex::FArrayBox &jx_fab, amrex::FArrayBox &jy_fab, amrex::FArrayBox &jz_fab, const long np_to_depose, const amrex::Real dt, const amrex::Real relative_time, const std::array< amrex::Real, 3 > &dx, const std::array< amrex::Real, 3 > &xyzmin, const amrex::Dim3 lo, const amrex::Real q, const int n_rz_azimuthal_modes, amrex::Real *cost, const long load_balance_costs_update_algo)
Vay current deposition (Vay et al, 2013) for thread thread_num: deposit D in real space and store the...
Definition: CurrentDeposition.H:744
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
Definition: ShapeFactors.H:26
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T imag() const noexcept
std::enable_if_t< std::is_integral< T >::value > ParallelFor(TypeList< CTOs... >, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
void Abort(const std::string &msg)
i
Definition: check_interp_points_and_weights.py:173
virtual void * alloc(std::size_t sz)=0
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T real() const noexcept
Functor that can be used to extract the positions of the macroparticles inside a ParallelFor kernel...
Definition: GetAndSetPosition.H:52
void streamSynchronize() noexcept
Defines a timer object to be used on GPU; measures summed thread cycles.
Definition: KernelTimer.H:23
AMREX_GPU_HOST_DEVICE IntVect type() const noexcept
Arena * The_Managed_Arena()