8 #ifndef WARPX_CURRENTDEPOSITION_H_
9 #define WARPX_CURRENTDEPOSITION_H_
48 template <
int depos_order>
51 [[maybe_unused]]
const amrex::ParticleReal yp,
52 [[maybe_unused]]
const amrex::ParticleReal zp,
53 const amrex::ParticleReal wq,
54 const amrex::ParticleReal vx,
55 const amrex::ParticleReal vy,
56 const amrex::ParticleReal vz,
63 const amrex::Real relative_time,
66 const amrex::Real invvol,
68 [[maybe_unused]]
const int n_rz_azimuthal_modes)
70 using namespace amrex::literals;
76 #if defined(WARPX_DIM_RZ)
79 const amrex::Real xpmid = xp + relative_time*vx;
80 const amrex::Real ypmid = yp + relative_time*vy;
81 const amrex::Real rpmid = std::sqrt(xpmid*xpmid + ypmid*ypmid);
82 const amrex::Real costheta = (rpmid > 0._rt ? xpmid/rpmid : 1._rt);
83 const amrex::Real sintheta = (rpmid > 0._rt ? ypmid/rpmid : 0._rt);
85 const amrex::Real wqx = wq*invvol*(+vx*costheta + vy*sintheta);
86 const amrex::Real wqy = wq*invvol*(-vx*sintheta + vy*costheta);
88 const amrex::Real wqx = wq*invvol*vx;
89 const amrex::Real wqy = wq*invvol*vy;
91 const amrex::Real wqz = wq*invvol*vz;
95 #if (AMREX_SPACEDIM >= 2)
99 #if defined(WARPX_DIM_RZ)
100 const double xmid = (rpmid - xyzmin.
x)*dinv.
x;
102 const double xmid = ((xp - xyzmin.
x) + relative_time*vx)*dinv.
x;
110 double sx_node[depos_order + 1] = {0.};
111 double sx_cell[depos_order + 1] = {0.};
114 if (jx_type[0] == NODE || jy_type[0] == NODE || jz_type[0] == NODE) {
115 j_node = compute_shape_factor(sx_node, xmid);
117 if (jx_type[0] == CELL || jy_type[0] == CELL || jz_type[0] == CELL) {
118 j_cell = compute_shape_factor(sx_cell, xmid - 0.5);
121 amrex::Real sx_jx[depos_order + 1] = {0._rt};
122 amrex::Real sx_jy[depos_order + 1] = {0._rt};
123 amrex::Real sx_jz[depos_order + 1] = {0._rt};
124 for (
int ix=0;
ix<=depos_order;
ix++)
126 sx_jx[
ix] = ((jx_type[0] ==
NODE) ? amrex::Real(sx_node[ix]) : amrex::Real(sx_cell[ix]));
127 sx_jy[
ix] = ((jy_type[0] ==
NODE) ? amrex::Real(sx_node[ix]) : amrex::Real(sx_cell[ix]));
128 sx_jz[
ix] = ((jz_type[0] ==
NODE) ? amrex::Real(sx_node[ix]) : amrex::Real(sx_cell[ix]));
131 int const j_jx = ((jx_type[0] ==
NODE) ? j_node : j_cell);
132 int const j_jy = ((jy_type[0] ==
NODE) ? j_node : j_cell);
133 int const j_jz = ((jz_type[0] ==
NODE) ? j_node : j_cell);
136 #if defined(WARPX_DIM_3D)
139 const double ymid = ((yp - xyzmin.y) + relative_time*vy)*dinv.y;
140 double sy_node[depos_order + 1] = {0.};
141 double sy_cell[depos_order + 1] = {0.};
144 if (jx_type[1] == NODE || jy_type[1] == NODE || jz_type[1] == NODE) {
145 k_node = compute_shape_factor(sy_node, ymid);
147 if (jx_type[1] == CELL || jy_type[1] == CELL || jz_type[1] == CELL) {
148 k_cell = compute_shape_factor(sy_cell, ymid - 0.5);
150 amrex::Real sy_jx[depos_order + 1] = {0._rt};
151 amrex::Real sy_jy[depos_order + 1] = {0._rt};
152 amrex::Real sy_jz[depos_order + 1] = {0._rt};
153 for (
int iy=0;
iy<=depos_order;
iy++)
155 sy_jx[
iy] = ((jx_type[1] ==
NODE) ? amrex::Real(sy_node[iy]) : amrex::Real(sy_cell[iy]));
156 sy_jy[
iy] = ((jy_type[1] ==
NODE) ? amrex::Real(sy_node[iy]) : amrex::Real(sy_cell[iy]));
157 sy_jz[
iy] = ((jz_type[1] ==
NODE) ? amrex::Real(sy_node[iy]) : amrex::Real(sy_cell[iy]));
159 int const k_jx = ((jx_type[1] ==
NODE) ? k_node : k_cell);
160 int const k_jy = ((jy_type[1] ==
NODE) ? k_node : k_cell);
161 int const k_jz = ((jz_type[1] ==
NODE) ? k_node : k_cell);
166 constexpr
int zdir = WARPX_ZINDEX;
167 const double zmid = ((zp - xyzmin.z) + relative_time*vz)*dinv.z;
168 double sz_node[depos_order + 1] = {0.};
169 double sz_cell[depos_order + 1] = {0.};
172 if (jx_type[zdir] == NODE || jy_type[zdir] == NODE || jz_type[zdir] == NODE) {
173 l_node = compute_shape_factor(sz_node, zmid);
175 if (jx_type[zdir] == CELL || jy_type[zdir] == CELL || jz_type[zdir] == CELL) {
176 l_cell = compute_shape_factor(sz_cell, zmid - 0.5);
178 amrex::Real sz_jx[depos_order + 1] = {0._rt};
179 amrex::Real sz_jy[depos_order + 1] = {0._rt};
180 amrex::Real sz_jz[depos_order + 1] = {0._rt};
181 for (
int iz=0;
iz<=depos_order;
iz++)
183 sz_jx[
iz] = ((jx_type[zdir] ==
NODE) ? amrex::Real(sz_node[iz]) : amrex::Real(sz_cell[iz]));
184 sz_jy[
iz] = ((jy_type[zdir] ==
NODE) ? amrex::Real(sz_node[iz]) : amrex::Real(sz_cell[iz]));
185 sz_jz[
iz] = ((jz_type[zdir] ==
NODE) ? amrex::Real(sz_node[iz]) : amrex::Real(sz_cell[iz]));
187 int const l_jx = ((jx_type[zdir] ==
NODE) ? l_node : l_cell);
188 int const l_jy = ((jy_type[zdir] ==
NODE) ? l_node : l_cell);
189 int const l_jz = ((jz_type[zdir] ==
NODE) ? l_node : l_cell);
192 #if defined(WARPX_DIM_1D_Z)
193 for (
int iz=0;
iz<=depos_order;
iz++){
195 &jx_arr(lo.x+l_jx+iz, 0, 0, 0),
198 &jy_arr(lo.x+l_jy+iz, 0, 0, 0),
201 &jz_arr(lo.x+l_jz+iz, 0, 0, 0),
205 #if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
206 for (
int iz=0;
iz<=depos_order;
iz++){
207 for (
int ix=0;
ix<=depos_order;
ix++){
209 &jx_arr(lo.x+j_jx+ix, lo.y+l_jx+iz, 0, 0),
210 sx_jx[ix]*sz_jx[iz]*wqx);
212 &jy_arr(lo.x+j_jy+ix, lo.y+l_jy+iz, 0, 0),
213 sx_jy[ix]*sz_jy[iz]*wqy);
215 &jz_arr(lo.x+j_jz+ix, lo.y+l_jz+iz, 0, 0),
216 sx_jz[ix]*sz_jz[iz]*wqz);
217 #if defined(WARPX_DIM_RZ)
219 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
232 #elif defined(WARPX_DIM_3D)
233 for (
int iz=0;
iz<=depos_order;
iz++){
234 for (
int iy=0;
iy<=depos_order;
iy++){
235 for (
int ix=0;
ix<=depos_order;
ix++){
237 &jx_arr(lo.x+j_jx+ix, lo.y+k_jx+iy, lo.z+l_jx+iz),
238 sx_jx[ix]*sy_jx[iy]*sz_jx[iz]*wqx);
240 &jy_arr(lo.x+j_jy+ix, lo.y+k_jy+iy, lo.z+l_jy+iz),
241 sx_jy[ix]*sy_jy[iy]*sz_jy[iz]*wqy);
243 &jz_arr(lo.x+j_jz+ix, lo.y+k_jz+iy, lo.z+l_jz+iz),
244 sx_jz[ix]*sy_jz[iy]*sz_jz[iz]*wqz);
273 template <
int depos_order>
275 const amrex::ParticleReal *
const wp,
276 const amrex::ParticleReal *
const uxp,
277 const amrex::ParticleReal *
const uyp,
278 const amrex::ParticleReal *
const uzp,
284 amrex::Real relative_time,
289 [[maybe_unused]]
int n_rz_azimuthal_modes)
291 using namespace amrex::literals;
295 const bool do_ionization = ion_lev;
297 const amrex::Real invvol = dinv.
x*dinv.
y*dinv.
z;
312 amrex::ParticleReal xp, yp, zp;
313 GetPosition(ip, xp, yp, zp);
316 const amrex::Real gaminv = 1.0_rt/std::sqrt(1.0_rt + uxp[ip]*uxp[ip]*clightsq
317 + uyp[ip]*uyp[ip]*clightsq
318 + uzp[ip]*uzp[ip]*clightsq);
319 const amrex::Real vx = uxp[ip]*gaminv;
320 const amrex::Real vy = uyp[ip]*gaminv;
321 const amrex::Real vz = uzp[ip]*gaminv;
323 amrex::Real wq = q*wp[ip];
328 doDepositionShapeNKernel<depos_order>(xp, yp, zp, wq, vx, vy, vz, jx_arr, jy_arr, jz_arr,
329 jx_type, jy_type, jz_type,
330 relative_time, dinv, xyzmin,
331 invvol, lo, n_rz_azimuthal_modes);
358 template <
int depos_order>
360 const amrex::ParticleReal *
const wp,
361 const amrex::ParticleReal *
const uxp_n,
362 const amrex::ParticleReal *
const uyp_n,
363 const amrex::ParticleReal *
const uzp_n,
364 const amrex::ParticleReal *
const uxp,
365 const amrex::ParticleReal *
const uyp,
366 const amrex::ParticleReal *
const uzp,
367 const int *
const ion_lev,
371 const long np_to_deposit,
376 [[maybe_unused]]
const int n_rz_azimuthal_modes)
378 using namespace amrex::literals;
382 const bool do_ionization = ion_lev;
384 const amrex::Real invvol = dinv.
x*dinv.
y*dinv.
z;
397 amrex::ParticleReal xp, yp, zp;
398 GetPosition(ip, xp, yp, zp);
404 const amrex::ParticleReal uxp_np1 = 2._prt*uxp[ip] - uxp_n[ip];
405 const amrex::ParticleReal uyp_np1 = 2._prt*uyp[ip] - uyp_n[ip];
406 const amrex::ParticleReal uzp_np1 = 2._prt*uzp[ip] - uzp_n[ip];
407 const amrex::ParticleReal gamma_n = std::sqrt(1._prt + (uxp_n[ip]*uxp_n[ip] + uyp_n[ip]*uyp_n[ip] + uzp_n[ip]*uzp_n[ip])*inv_c2);
408 const amrex::ParticleReal gamma_np1 = std::sqrt(1._prt + (uxp_np1*uxp_np1 + uyp_np1*uyp_np1 + uzp_np1*uzp_np1)*inv_c2);
409 const amrex::ParticleReal gaminv = 2.0_prt/(gamma_n + gamma_np1);
411 const amrex::Real vx = uxp[ip]*gaminv;
412 const amrex::Real vy = uyp[ip]*gaminv;
413 const amrex::Real vz = uzp[ip]*gaminv;
415 amrex::Real wq = q*wp[ip];
420 const amrex::Real relative_time = 0._rt;
421 doDepositionShapeNKernel<depos_order>(xp, yp, zp, wq, vx, vy, vz, jx_arr, jy_arr, jz_arr,
422 jx_type, jy_type, jz_type,
423 relative_time, dinv, xyzmin,
424 invvol, lo, n_rz_azimuthal_modes);
453 template <
int depos_order>
455 const amrex::ParticleReal *
const wp,
456 const amrex::ParticleReal *
const uxp,
457 const amrex::ParticleReal *
const uyp,
458 const amrex::ParticleReal *
const uzp,
464 const amrex::Real relative_time,
469 int n_rz_azimuthal_modes,
475 using namespace amrex::literals;
477 #if defined(AMREX_USE_HIP) || defined(AMREX_USE_CUDA)
478 using namespace amrex;
489 constexpr
int zdir = WARPX_ZINDEX;
496 const auto domain = geom.
Domain();
499 sample_tbox.
grow(depos_order);
507 const int nblocks = a_bins.
numBins();
511 const std::size_t shared_mem_bytes = npts*
sizeof(amrex::Real);
515 "Tile size too big for GPU shared memory current deposition");
522 const int bin_id = blockIdx.x;
523 const unsigned int bin_start = offsets_ptr[bin_id];
524 const unsigned int bin_stop = offsets_ptr[bin_id+1];
526 if (bin_start == bin_stop) {
return; }
531 ParticleReal xp, yp, zp;
532 GetPosition(permutation[bin_start], xp, yp, zp);
533 #if defined(WARPX_DIM_3D)
534 IntVect iv =
IntVect(
int( amrex::Math::floor((xp-plo[0]) * dxiarr[0]) ),
535 int( amrex::Math::floor((yp-plo[1]) * dxiarr[1]) ),
536 int( amrex::Math::floor((zp-plo[2]) * dxiarr[2]) ));
537 #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
538 IntVect iv =
IntVect(
int( amrex::Math::floor((xp-plo[0]) * dxiarr[0]) ),
539 int( amrex::Math::floor((zp-plo[1]) * dxiarr[1]) ));
540 #elif defined(WARPX_DIM_1D_Z)
541 IntVect iv =
IntVect(
int( amrex::Math::floor((zp-plo[0]) * dxiarr[0]) ));
543 iv += domain.smallEnd();
547 buffer_box.
grow(depos_order);
553 amrex::Real*
const shared = gsm.
dataPtr();
563 volatile amrex::Real* vs = shared;
564 for (
int i = threadIdx.x;
i < npts;
i += blockDim.x){
568 for (
unsigned int ip_orig = bin_start+threadIdx.x; ip_orig<bin_stop; ip_orig += blockDim.x)
570 const unsigned int ip = permutation[ip_orig];
571 depositComponent<depos_order>(GetPosition, wp, uxp, uyp, uzp, ion_lev, jx_buff, jx_type,
572 relative_time, dinv, xyzmin, lo, q, n_rz_azimuthal_modes,
573 ip, zdir,
NODE, CELL, 0);
577 addLocalToGlobal(tbox_x, jx_arr, jx_buff);
578 for (
int i = threadIdx.x;
i < npts;
i += blockDim.x){
583 for (
unsigned int ip_orig = bin_start+threadIdx.x; ip_orig<bin_stop; ip_orig += blockDim.x)
585 const unsigned int ip = permutation[ip_orig];
586 depositComponent<depos_order>(GetPosition, wp, uxp, uyp, uzp, ion_lev, jy_buff, jy_type,
587 relative_time, dinv, xyzmin, lo, q, n_rz_azimuthal_modes,
588 ip, zdir,
NODE, CELL, 1);
592 addLocalToGlobal(tbox_y, jy_arr, jy_buff);
593 for (
int i = threadIdx.x;
i < npts;
i += blockDim.x){
598 for (
unsigned int ip_orig = bin_start+threadIdx.x; ip_orig<bin_stop; ip_orig += blockDim.x)
600 const unsigned int ip = permutation[ip_orig];
601 depositComponent<depos_order>(GetPosition, wp, uxp, uyp, uzp, ion_lev, jz_buff, jz_type,
602 relative_time, dinv, xyzmin, lo, q, n_rz_azimuthal_modes,
603 ip, zdir,
NODE, CELL, 2);
607 addLocalToGlobal(tbox_z, jz_arr, jz_buff);
613 ignore_unused(GetPosition, wp, uxp, uyp, uzp, ion_lev, jx_fab, jy_fab, jz_fab, np_to_deposit, relative_time, dinv, xyzmin, lo, q, n_rz_azimuthal_modes, a_bins, box, geom, a_tbox_max_size);
642 template <
int depos_order>
644 const amrex::ParticleReal *
const wp,
645 const amrex::ParticleReal *
const uxp,
646 const amrex::ParticleReal *
const uyp,
647 const amrex::ParticleReal *
const uzp,
654 amrex::Real relative_time,
659 [[maybe_unused]]
int n_rz_azimuthal_modes)
661 using namespace amrex;
662 using namespace amrex::literals;
666 bool const do_ionization = ion_lev;
667 #if !defined(WARPX_DIM_3D)
668 const amrex::Real invvol = dinv.
x*dinv.
y*dinv.
z;
672 (1.0_rt/
dt)*dinv.
x*dinv.
z,
673 (1.0_rt/
dt)*dinv.
x*dinv.
y};
677 #if !defined(WARPX_DIM_1D_Z)
678 Real constexpr one_third = 1.0_rt / 3.0_rt;
679 Real constexpr one_sixth = 1.0_rt / 6.0_rt;
687 Real
const gaminv = 1.0_rt/std::sqrt(1.0_rt + uxp[ip]*uxp[ip]*clightsq
688 + uyp[ip]*uyp[ip]*clightsq
689 + uzp[ip]*uzp[ip]*clightsq);
696 ParticleReal xp, yp, zp;
697 GetPosition(ip, xp, yp, zp);
700 #if defined(WARPX_DIM_RZ)
701 Real
const xp_new = xp + (relative_time + 0.5_rt*
dt)*uxp[ip]*gaminv;
702 Real
const yp_new = yp + (relative_time + 0.5_rt*
dt)*uyp[ip]*gaminv;
703 Real
const xp_mid = xp_new - 0.5_rt*
dt*uxp[ip]*gaminv;
704 Real
const yp_mid = yp_new - 0.5_rt*
dt*uyp[ip]*gaminv;
705 Real
const xp_old = xp_new -
dt*uxp[ip]*gaminv;
706 Real
const yp_old = yp_new -
dt*uyp[ip]*gaminv;
707 Real
const rp_new = std::sqrt(xp_new*xp_new + yp_new*yp_new);
708 Real
const rp_mid = std::sqrt(xp_mid*xp_mid + yp_mid*yp_mid);
709 Real
const rp_old = std::sqrt(xp_old*xp_old + yp_old*yp_old);
710 const amrex::Real costheta_mid = (rp_mid > 0._rt ? xp_mid/rp_mid : 1._rt);
711 const amrex::Real sintheta_mid = (rp_mid > 0._rt ? yp_mid/rp_mid : 0._rt);
712 const amrex::Real costheta_new = (rp_new > 0._rt ? xp_new/rp_new : 1._rt);
713 const amrex::Real sintheta_new = (rp_new > 0._rt ? yp_new/rp_new : 0._rt);
714 const amrex::Real costheta_old = (rp_old > 0._rt ? xp_old/rp_old : 1._rt);
715 const amrex::Real sintheta_old = (rp_old > 0._rt ? yp_old/rp_old : 0._rt);
720 double const x_new = (rp_new - xyzmin.
x)*dinv.
x;
721 double const x_old = (rp_old - xyzmin.
x)*dinv.
x;
723 #if !defined(WARPX_DIM_1D_Z)
725 double const x_new = (xp - xyzmin.
x + (relative_time + 0.5_rt*
dt)*uxp[ip]*gaminv)*dinv.
x;
726 double const x_old = x_new -
dt*dinv.
x*uxp[ip]*gaminv;
729 #if defined(WARPX_DIM_3D)
731 double const y_new = (yp - xyzmin.
y + (relative_time + 0.5_rt*
dt)*uyp[ip]*gaminv)*dinv.
y;
732 double const y_old = y_new -
dt*dinv.
y*uyp[ip]*gaminv;
735 double const z_new = (zp - xyzmin.
z + (relative_time + 0.5_rt*
dt)*uzp[ip]*gaminv)*dinv.
z;
736 double const z_old = z_new -
dt*dinv.
z*uzp[ip]*gaminv;
738 #if defined(WARPX_DIM_RZ)
739 Real
const vy = (-uxp[ip]*sintheta_mid + uyp[ip]*costheta_mid)*gaminv;
740 #elif defined(WARPX_DIM_XZ)
741 Real
const vy = uyp[ip]*gaminv;
742 #elif defined(WARPX_DIM_1D_Z)
743 Real
const vx = uxp[ip]*gaminv;
744 Real
const vy = uyp[ip]*gaminv;
758 #if !defined(WARPX_DIM_1D_Z)
759 double sx_new[depos_order + 3] = {0.};
760 double sx_old[depos_order + 3] = {0.};
761 const int i_new = compute_shape_factor(sx_new+1, x_new);
762 const int i_old = compute_shifted_shape_factor(sx_old, x_old, i_new);
764 #if defined(WARPX_DIM_3D)
765 double sy_new[depos_order + 3] = {0.};
766 double sy_old[depos_order + 3] = {0.};
767 const int j_new = compute_shape_factor(sy_new+1, y_new);
768 const int j_old = compute_shifted_shape_factor(sy_old, y_old, j_new);
770 double sz_new[depos_order + 3] = {0.};
771 double sz_old[depos_order + 3] = {0.};
772 const int k_new = compute_shape_factor(sz_new+1, z_new);
773 const int k_old = compute_shifted_shape_factor(sz_old, z_old, k_new);
776 #if !defined(WARPX_DIM_1D_Z)
777 int dil = 1, diu = 1;
778 if (i_old < i_new) { dil = 0; }
779 if (i_old > i_new) { diu = 0; }
781 #if defined(WARPX_DIM_3D)
782 int djl = 1, dju = 1;
783 if (j_old < j_new) { djl = 0; }
784 if (j_old > j_new) { dju = 0; }
786 int dkl = 1, dku = 1;
787 if (k_old < k_new) { dkl = 0; }
788 if (k_old > k_new) { dku = 0; }
790 #if defined(WARPX_DIM_3D)
792 for (
int k=dkl; k<=depos_order+2-dku; k++) {
793 for (
int j=djl; j<=depos_order+2-dju; j++) {
794 amrex::Real sdxi = 0._rt;
795 for (
int i=dil;
i<=depos_order+1-diu;
i++) {
796 sdxi += wq*invdtd.
x*(sx_old[
i] - sx_new[
i])*(
797 one_third*(sy_new[j]*sz_new[k] + sy_old[j]*sz_old[k])
798 +one_sixth*(sy_new[j]*sz_old[k] + sy_old[j]*sz_new[k]));
803 for (
int k=dkl; k<=depos_order+2-dku; k++) {
804 for (
int i=dil;
i<=depos_order+2-diu;
i++) {
805 amrex::Real sdyj = 0._rt;
806 for (
int j=djl; j<=depos_order+1-dju; j++) {
807 sdyj += wq*invdtd.
y*(sy_old[j] - sy_new[j])*(
808 one_third*(sx_new[
i]*sz_new[k] + sx_old[
i]*sz_old[k])
809 +one_sixth*(sx_new[
i]*sz_old[k] + sx_old[
i]*sz_new[k]));
814 for (
int j=djl; j<=depos_order+2-dju; j++) {
815 for (
int i=dil;
i<=depos_order+2-diu;
i++) {
816 amrex::Real sdzk = 0._rt;
817 for (
int k=dkl; k<=depos_order+1-dku; k++) {
818 sdzk += wq*invdtd.
z*(sz_old[k] - sz_new[k])*(
819 one_third*(sx_new[
i]*sy_new[j] + sx_old[
i]*sy_old[j])
820 +one_sixth*(sx_new[
i]*sy_old[j] + sx_old[
i]*sy_new[j]));
826 #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
828 for (
int k=dkl; k<=depos_order+2-dku; k++) {
829 amrex::Real sdxi = 0._rt;
830 for (
int i=dil;
i<=depos_order+1-diu;
i++) {
831 sdxi += wq*invdtd.
x*(sx_old[
i] - sx_new[
i])*0.5_rt*(sz_new[k] + sz_old[k]);
833 #if defined(WARPX_DIM_RZ)
835 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
837 const Complex djr_cmplx = 2._rt *sdxi*xy_mid;
840 xy_mid = xy_mid*xy_mid0;
845 for (
int k=dkl; k<=depos_order+2-dku; k++) {
846 for (
int i=dil;
i<=depos_order+2-diu;
i++) {
847 Real
const sdyj = wq*vy*invvol*(
848 one_third*(sx_new[
i]*sz_new[k] + sx_old[
i]*sz_old[k])
849 +one_sixth*(sx_new[
i]*sz_old[k] + sx_old[
i]*sz_new[k]));
851 #if defined(WARPX_DIM_RZ)
857 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
860 const Complex djt_cmplx = -2._rt * I*(i_new-1 +
i + xyzmin.
x*dinv.
x)*wq*invdtd.
x/(amrex::Real)imode
861 *(
Complex(sx_new[
i]*sz_new[k], 0._rt)*(xy_new - xy_mid)
862 +
Complex(sx_old[
i]*sz_old[k], 0._rt)*(xy_mid - xy_old));
865 xy_new = xy_new*xy_new0;
866 xy_mid = xy_mid*xy_mid0;
867 xy_old = xy_old*xy_old0;
872 for (
int i=dil;
i<=depos_order+2-diu;
i++) {
874 for (
int k=dkl; k<=depos_order+1-dku; k++) {
875 sdzk += wq*invdtd.
z*(sz_old[k] - sz_new[k])*0.5_rt*(sx_new[
i] + sx_old[
i]);
877 #if defined(WARPX_DIM_RZ)
879 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
881 const Complex djz_cmplx = 2._rt * sdzk * xy_mid;
884 xy_mid = xy_mid*xy_mid0;
889 #elif defined(WARPX_DIM_1D_Z)
891 for (
int k=dkl; k<=depos_order+2-dku; k++) {
892 amrex::Real
const sdxi = wq*vx*invvol*0.5_rt*(sz_old[k] + sz_new[k]);
895 for (
int k=dkl; k<=depos_order+2-dku; k++) {
896 amrex::Real
const sdyj = wq*vy*invvol*0.5_rt*(sz_old[k] + sz_new[k]);
899 amrex::Real sdzk = 0._rt;
900 for (
int k=dkl; k<=depos_order+1-dku; k++) {
901 sdzk += wq*invdtd.
z*(sz_old[k] - sz_new[k]);
933 template <
int depos_order>
935 [[maybe_unused]]
const amrex::ParticleReal *
const yp_n,
936 [[maybe_unused]]
const amrex::ParticleReal *
const zp_n,
938 const amrex::ParticleReal *
const wp,
939 [[maybe_unused]]
const amrex::ParticleReal *
const uxp_n,
940 [[maybe_unused]]
const amrex::ParticleReal *
const uyp_n,
941 [[maybe_unused]]
const amrex::ParticleReal *
const uzp_n,
942 [[maybe_unused]]
const amrex::ParticleReal *
const uxp_nph,
943 [[maybe_unused]]
const amrex::ParticleReal *
const uyp_nph,
944 [[maybe_unused]]
const amrex::ParticleReal *
const uzp_nph,
945 const int *
const ion_lev,
949 const long np_to_deposit,
950 const amrex::Real
dt,
955 [[maybe_unused]]
const int n_rz_azimuthal_modes)
957 using namespace amrex;
961 bool const do_ionization = ion_lev;
963 #if !defined(WARPX_DIM_3D)
964 const amrex::Real invvol = dinv.
x*dinv.
y*dinv.
z;
968 (1.0_rt/
dt)*dinv.
x*dinv.
z,
969 (1.0_rt/
dt)*dinv.
x*dinv.
y};
971 #if !defined(WARPX_DIM_1D_Z)
972 Real constexpr one_third = 1.0_rt / 3.0_rt;
973 Real constexpr one_sixth = 1.0_rt / 6.0_rt;
980 #if !defined(WARPX_DIM_3D)
985 const amrex::ParticleReal uxp_np1 = 2._prt*uxp_nph[ip] - uxp_n[ip];
986 const amrex::ParticleReal uyp_np1 = 2._prt*uyp_nph[ip] - uyp_n[ip];
987 const amrex::ParticleReal uzp_np1 = 2._prt*uzp_nph[ip] - uzp_n[ip];
988 const amrex::ParticleReal gamma_n = std::sqrt(1._prt + (uxp_n[ip]*uxp_n[ip] + uyp_n[ip]*uyp_n[ip] + uzp_n[ip]*uzp_n[ip])*inv_c2);
989 const amrex::ParticleReal gamma_np1 = std::sqrt(1._prt + (uxp_np1*uxp_np1 + uyp_np1*uyp_np1 + uzp_np1*uzp_np1)*inv_c2);
990 const amrex::ParticleReal gaminv = 2.0_prt/(gamma_n + gamma_np1);
998 ParticleReal xp_nph, yp_nph, zp_nph;
999 GetPosition(ip, xp_nph, yp_nph, zp_nph);
1001 #if !defined(WARPX_DIM_1D_Z)
1002 ParticleReal
const xp_np1 = 2._prt*xp_nph - xp_n[ip];
1004 #if defined(WARPX_DIM_3D) || defined(WARPX_DIM_RZ)
1005 ParticleReal
const yp_np1 = 2._prt*yp_nph - yp_n[ip];
1007 ParticleReal
const zp_np1 = 2._prt*zp_nph - zp_n[ip];
1010 #if defined(WARPX_DIM_RZ)
1011 amrex::Real
const xp_new = xp_np1;
1012 amrex::Real
const yp_new = yp_np1;
1013 amrex::Real
const xp_mid = xp_nph;
1014 amrex::Real
const yp_mid = yp_nph;
1015 amrex::Real
const xp_old = xp_n[ip];
1016 amrex::Real
const yp_old = yp_n[ip];
1017 amrex::Real
const rp_new = std::sqrt(xp_new*xp_new + yp_new*yp_new);
1018 amrex::Real
const rp_old = std::sqrt(xp_old*xp_old + yp_old*yp_old);
1019 amrex::Real
const rp_mid = (rp_new + rp_old)/2._rt;
1020 const amrex::Real costheta_mid = (rp_mid > 0._rt ? xp_mid/rp_mid : 1._rt);
1021 const amrex::Real sintheta_mid = (rp_mid > 0._rt ? yp_mid/rp_mid : 0._rt);
1022 const amrex::Real costheta_new = (rp_new > 0._rt ? xp_new/rp_new : 1._rt);
1023 const amrex::Real sintheta_new = (rp_new > 0._rt ? yp_new/rp_new : 0._rt);
1024 const amrex::Real costheta_old = (rp_old > 0._rt ? xp_old/rp_old : 1._rt);
1025 const amrex::Real sintheta_old = (rp_old > 0._rt ? yp_old/rp_old : 0._rt);
1030 double const x_new = (rp_new - xyzmin.
x)*dinv.
x;
1031 double const x_old = (rp_old - xyzmin.
x)*dinv.
x;
1033 #if !defined(WARPX_DIM_1D_Z)
1035 double const x_new = (xp_np1 - xyzmin.
x)*dinv.
x;
1036 double const x_old = (xp_n[ip] - xyzmin.
x)*dinv.
x;
1039 #if defined(WARPX_DIM_3D)
1041 double const y_new = (yp_np1 - xyzmin.
y)*dinv.
y;
1042 double const y_old = (yp_n[ip] - xyzmin.
y)*dinv.
y;
1045 double const z_new = (zp_np1 - xyzmin.
z)*dinv.
z;
1046 double const z_old = (zp_n[ip] - xyzmin.
z)*dinv.
z;
1048 #if defined(WARPX_DIM_RZ)
1049 amrex::Real
const vy = (-uxp_nph[ip]*sintheta_mid + uyp_nph[ip]*costheta_mid)*gaminv;
1050 #elif defined(WARPX_DIM_XZ)
1051 amrex::Real
const vy = uyp_nph[ip]*gaminv;
1052 #elif defined(WARPX_DIM_1D_Z)
1053 amrex::Real
const vx = uxp_nph[ip]*gaminv;
1054 amrex::Real
const vy = uyp_nph[ip]*gaminv;
1068 #if !defined(WARPX_DIM_1D_Z)
1069 double sx_new[depos_order + 3] = {0.};
1070 double sx_old[depos_order + 3] = {0.};
1071 const int i_new = compute_shape_factor(sx_new+1, x_new);
1072 const int i_old = compute_shifted_shape_factor(sx_old, x_old, i_new);
1074 #if defined(WARPX_DIM_3D)
1075 double sy_new[depos_order + 3] = {0.};
1076 double sy_old[depos_order + 3] = {0.};
1077 const int j_new = compute_shape_factor(sy_new+1, y_new);
1078 const int j_old = compute_shifted_shape_factor(sy_old, y_old, j_new);
1080 double sz_new[depos_order + 3] = {0.};
1081 double sz_old[depos_order + 3] = {0.};
1082 const int k_new = compute_shape_factor(sz_new+1, z_new);
1083 const int k_old = compute_shifted_shape_factor(sz_old, z_old, k_new);
1086 #if !defined(WARPX_DIM_1D_Z)
1087 int dil = 1, diu = 1;
1088 if (i_old < i_new) { dil = 0; }
1089 if (i_old > i_new) { diu = 0; }
1091 #if defined(WARPX_DIM_3D)
1092 int djl = 1, dju = 1;
1093 if (j_old < j_new) { djl = 0; }
1094 if (j_old > j_new) { dju = 0; }
1096 int dkl = 1, dku = 1;
1097 if (k_old < k_new) { dkl = 0; }
1098 if (k_old > k_new) { dku = 0; }
1100 #if defined(WARPX_DIM_3D)
1102 for (
int k=dkl; k<=depos_order+2-dku; k++) {
1103 for (
int j=djl; j<=depos_order+2-dju; j++) {
1104 amrex::Real sdxi = 0._rt;
1105 for (
int i=dil;
i<=depos_order+1-diu;
i++) {
1106 sdxi += wq*invdtd.
x*(sx_old[
i] - sx_new[
i])*(
1107 one_third*(sy_new[j]*sz_new[k] + sy_old[j]*sz_old[k])
1108 +one_sixth*(sy_new[j]*sz_old[k] + sy_old[j]*sz_new[k]));
1113 for (
int k=dkl; k<=depos_order+2-dku; k++) {
1114 for (
int i=dil;
i<=depos_order+2-diu;
i++) {
1115 amrex::Real sdyj = 0._rt;
1116 for (
int j=djl; j<=depos_order+1-dju; j++) {
1117 sdyj += wq*invdtd.
y*(sy_old[j] - sy_new[j])*(
1118 one_third*(sx_new[
i]*sz_new[k] + sx_old[
i]*sz_old[k])
1119 +one_sixth*(sx_new[
i]*sz_old[k] + sx_old[
i]*sz_new[k]));
1124 for (
int j=djl; j<=depos_order+2-dju; j++) {
1125 for (
int i=dil;
i<=depos_order+2-diu;
i++) {
1126 amrex::Real sdzk = 0._rt;
1127 for (
int k=dkl; k<=depos_order+1-dku; k++) {
1128 sdzk += wq*invdtd.
z*(sz_old[k] - sz_new[k])*(
1129 one_third*(sx_new[
i]*sy_new[j] + sx_old[
i]*sy_old[j])
1130 +one_sixth*(sx_new[
i]*sy_old[j] + sx_old[
i]*sy_new[j]));
1136 #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
1138 for (
int k=dkl; k<=depos_order+2-dku; k++) {
1139 amrex::Real sdxi = 0._rt;
1140 for (
int i=dil;
i<=depos_order+1-diu;
i++) {
1141 sdxi += wq*invdtd.
x*(sx_old[
i] - sx_new[
i])*0.5_rt*(sz_new[k] + sz_old[k]);
1143 #if defined(WARPX_DIM_RZ)
1145 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
1147 const Complex djr_cmplx = 2._rt *sdxi*xy_mid;
1150 xy_mid = xy_mid*xy_mid0;
1155 for (
int k=dkl; k<=depos_order+2-dku; k++) {
1156 for (
int i=dil;
i<=depos_order+2-diu;
i++) {
1157 Real
const sdyj = wq*vy*invvol*(
1158 one_third*(sx_new[
i]*sz_new[k] + sx_old[
i]*sz_old[k])
1159 +one_sixth*(sx_new[
i]*sz_old[k] + sx_old[
i]*sz_new[k]));
1161 #if defined(WARPX_DIM_RZ)
1167 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
1170 const Complex djt_cmplx = -2._rt * I*(i_new-1 +
i + xyzmin.
x*dinv.
x)*wq*invdtd.
x/(amrex::Real)imode
1171 *(
Complex(sx_new[
i]*sz_new[k], 0._rt)*(xy_new - xy_mid)
1172 +
Complex(sx_old[
i]*sz_old[k], 0._rt)*(xy_mid - xy_old));
1175 xy_new = xy_new*xy_new0;
1176 xy_mid = xy_mid*xy_mid0;
1177 xy_old = xy_old*xy_old0;
1182 for (
int i=dil;
i<=depos_order+2-diu;
i++) {
1184 for (
int k=dkl; k<=depos_order+1-dku; k++) {
1185 sdzk += wq*invdtd.
z*(sz_old[k] - sz_new[k])*0.5_rt*(sx_new[
i] + sx_old[
i]);
1187 #if defined(WARPX_DIM_RZ)
1189 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
1191 const Complex djz_cmplx = 2._rt * sdzk * xy_mid;
1194 xy_mid = xy_mid*xy_mid0;
1199 #elif defined(WARPX_DIM_1D_Z)
1201 for (
int k=dkl; k<=depos_order+2-dku; k++) {
1202 amrex::Real
const sdxi = wq*vx*invvol*0.5_rt*(sz_old[k] + sz_new[k]);
1205 for (
int k=dkl; k<=depos_order+2-dku; k++) {
1206 amrex::Real
const sdyj = wq*vy*invvol*0.5_rt*(sz_old[k] + sz_new[k]);
1209 amrex::Real sdzk = 0._rt;
1210 for (
int k=dkl; k<=depos_order+1-dku; k++) {
1211 sdzk += wq*invdtd.
z*(sz_old[k] - sz_new[k]);
1245 template <
int depos_order>
1247 [[maybe_unused]]
const amrex::ParticleReal *
const yp_n,
1248 [[maybe_unused]]
const amrex::ParticleReal *
const zp_n,
1250 const amrex::ParticleReal *
const wp,
1251 [[maybe_unused]]
const amrex::ParticleReal *
const uxp_n,
1252 [[maybe_unused]]
const amrex::ParticleReal *
const uyp_n,
1253 [[maybe_unused]]
const amrex::ParticleReal *
const uzp_n,
1254 [[maybe_unused]]
const amrex::ParticleReal *
const uxp_nph,
1255 [[maybe_unused]]
const amrex::ParticleReal *
const uyp_nph,
1256 [[maybe_unused]]
const amrex::ParticleReal *
const uzp_nph,
1257 const int *
const ion_lev,
1261 const long np_to_deposit,
1262 const amrex::Real
dt,
1266 const amrex::Real q,
1267 [[maybe_unused]]
const int n_rz_azimuthal_modes)
1269 using namespace amrex;
1273 bool const do_ionization = ion_lev;
1275 const amrex::Real invvol = dinv.
x*dinv.
y*dinv.
z;
1277 #if (AMREX_SPACEDIM > 1)
1278 Real constexpr one_third = 1.0_rt / 3.0_rt;
1279 Real constexpr one_sixth = 1.0_rt / 6.0_rt;
1287 #if !defined(WARPX_DIM_3D)
1292 const amrex::ParticleReal uxp_np1 = 2._prt*uxp_nph[ip] - uxp_n[ip];
1293 const amrex::ParticleReal uyp_np1 = 2._prt*uyp_nph[ip] - uyp_n[ip];
1294 const amrex::ParticleReal uzp_np1 = 2._prt*uzp_nph[ip] - uzp_n[ip];
1295 const amrex::ParticleReal gamma_n = std::sqrt(1._prt + (uxp_n[ip]*uxp_n[ip] + uyp_n[ip]*uyp_n[ip] + uzp_n[ip]*uzp_n[ip])*inv_c2);
1296 const amrex::ParticleReal gamma_np1 = std::sqrt(1._prt + (uxp_np1*uxp_np1 + uyp_np1*uyp_np1 + uzp_np1*uzp_np1)*inv_c2);
1297 const amrex::ParticleReal gaminv = 2.0_prt/(gamma_n + gamma_np1);
1305 ParticleReal xp_nph, yp_nph, zp_nph;
1306 GetPosition(ip, xp_nph, yp_nph, zp_nph);
1308 #if !defined(WARPX_DIM_1D_Z)
1309 ParticleReal
const xp_np1 = 2._prt*xp_nph - xp_n[ip];
1311 #if defined(WARPX_DIM_3D) || defined(WARPX_DIM_RZ)
1312 ParticleReal
const yp_np1 = 2._prt*yp_nph - yp_n[ip];
1314 ParticleReal
const zp_np1 = 2._prt*zp_nph - zp_n[ip];
1317 #if defined(WARPX_DIM_RZ)
1318 amrex::Real
const xp_new = xp_np1;
1319 amrex::Real
const yp_new = yp_np1;
1320 amrex::Real
const xp_mid = xp_nph;
1321 amrex::Real
const yp_mid = yp_nph;
1322 amrex::Real
const xp_old = xp_n[ip];
1323 amrex::Real
const yp_old = yp_n[ip];
1324 amrex::Real
const rp_new = std::sqrt(xp_new*xp_new + yp_new*yp_new);
1325 amrex::Real
const rp_old = std::sqrt(xp_old*xp_old + yp_old*yp_old);
1326 amrex::Real
const rp_mid = (rp_new + rp_old)/2._rt;
1327 amrex::Real costheta_mid, sintheta_mid;
1328 if (rp_mid > 0._rt) {
1329 costheta_mid = xp_mid/rp_mid;
1330 sintheta_mid = yp_mid/rp_mid;
1332 costheta_mid = 1._rt;
1333 sintheta_mid = 0._rt;
1338 double const x_new = (rp_new - xyzmin.
x)*dinv.
x;
1339 double const x_old = (rp_old - xyzmin.
x)*dinv.
x;
1340 amrex::Real
const vx = (rp_new - rp_old)/
dt;
1341 amrex::Real
const vy = (-uxp_nph[ip]*sintheta_mid + uyp_nph[ip]*costheta_mid)*gaminv;
1342 #elif defined(WARPX_DIM_XZ)
1344 double const x_new = (xp_np1 - xyzmin.
x)*dinv.
x;
1345 double const x_old = (xp_n[ip] - xyzmin.
x)*dinv.
x;
1346 amrex::Real
const vx = (xp_np1 - xp_n[ip])/
dt;
1347 amrex::Real
const vy = uyp_nph[ip]*gaminv;
1348 #elif defined(WARPX_DIM_1D_Z)
1349 amrex::Real
const vx = uxp_nph[ip]*gaminv;
1350 amrex::Real
const vy = uyp_nph[ip]*gaminv;
1351 #elif defined(WARPX_DIM_3D)
1353 double const x_new = (xp_np1 - xyzmin.
x)*dinv.
x;
1354 double const x_old = (xp_n[ip] - xyzmin.
x)*dinv.
x;
1355 double const y_new = (yp_np1 - xyzmin.
y)*dinv.
y;
1356 double const y_old = (yp_n[ip] - xyzmin.
y)*dinv.
y;
1357 amrex::Real
const vx = (xp_np1 - xp_n[ip])/
dt;
1358 amrex::Real
const vy = (yp_np1 - yp_n[ip])/
dt;
1362 double const z_new = (zp_np1 - xyzmin.
z)*dinv.
z;
1363 double const z_old = (zp_n[ip] - xyzmin.
z)*dinv.
z;
1364 amrex::Real
const vz = (zp_np1 - zp_n[ip])/
dt;
1367 amrex::Real
const wqx = wq*vx*invvol;
1368 amrex::Real
const wqy = wq*vy*invvol;
1369 amrex::Real
const wqz = wq*vz*invvol;
1377 int num_segments = 1;
1379 if ( (depos_order % 2) == 0 ) {
shift = 0.5; }
1381 #if defined(WARPX_DIM_3D)
1384 const auto i_old =
static_cast<int>(x_old-
shift);
1385 const auto i_new =
static_cast<int>(x_new-
shift);
1386 const int cell_crossings_x = std::abs(i_new-i_old);
1387 num_segments += cell_crossings_x;
1390 const auto j_old =
static_cast<int>(y_old-
shift);
1391 const auto j_new =
static_cast<int>(y_new-
shift);
1392 const int cell_crossings_y = std::abs(j_new-j_old);
1393 num_segments += cell_crossings_y;
1396 const auto k_old =
static_cast<int>(z_old-
shift);
1397 const auto k_new =
static_cast<int>(z_new-
shift);
1398 const int cell_crossings_z = std::abs(k_new-k_old);
1399 num_segments += cell_crossings_z;
1407 const double dxp = x_new - x_old;
1408 const double dyp = y_new - y_old;
1409 const double dzp = z_new - z_old;
1410 const auto dirX_sign =
static_cast<double>(dxp < 0. ? -1. : 1.);
1411 const auto dirY_sign =
static_cast<double>(dyp < 0. ? -1. : 1.);
1412 const auto dirZ_sign =
static_cast<double>(dzp < 0. ? -1. : 1.);
1413 double Xcell = 0., Ycell = 0., Zcell = 0.;
1414 if (num_segments > 1) {
1415 Xcell =
static_cast<double>(i_old) +
shift + 0.5*(1.-dirX_sign);
1416 Ycell =
static_cast<double>(j_old) +
shift + 0.5*(1.-dirY_sign);
1417 Zcell =
static_cast<double>(k_old) +
shift + 0.5*(1.-dirZ_sign);
1423 double dxp_seg, dyp_seg, dzp_seg;
1424 double x0_new, y0_new, z0_new;
1425 double x0_old = x_old;
1426 double y0_old = y_old;
1427 double z0_old = z_old;
1429 for (
int ns=0; ns<num_segments; ns++) {
1431 if (ns == num_segments-1) {
1436 dxp_seg = x0_new - x0_old;
1437 dyp_seg = y0_new - y0_old;
1438 dzp_seg = z0_new - z0_old;
1443 x0_new = Xcell + dirX_sign;
1444 y0_new = Ycell + dirY_sign;
1445 z0_new = Zcell + dirZ_sign;
1446 dxp_seg = x0_new - x0_old;
1447 dyp_seg = y0_new - y0_old;
1448 dzp_seg = z0_new - z0_old;
1450 if ( (dyp == 0. || std::abs(dxp_seg) < std::abs(dxp/dyp*dyp_seg))
1451 && (dzp == 0. || std::abs(dxp_seg) < std::abs(dxp/dzp*dzp_seg)) ) {
1453 dyp_seg = dyp/dxp*dxp_seg;
1454 dzp_seg = dzp/dxp*dxp_seg;
1455 y0_new = y0_old + dyp_seg;
1456 z0_new = z0_old + dzp_seg;
1458 else if (dzp == 0. || std::abs(dyp_seg) < std::abs(dyp/dzp*dzp_seg)) {
1460 dxp_seg = dxp/dyp*dyp_seg;
1461 dzp_seg = dzp/dyp*dyp_seg;
1462 x0_new = x0_old + dxp_seg;
1463 z0_new = z0_old + dzp_seg;
1467 dxp_seg = dxp/dzp*dzp_seg;
1468 dyp_seg = dyp/dzp*dzp_seg;
1469 x0_new = x0_old + dxp_seg;
1470 y0_new = y0_old + dyp_seg;
1476 const auto seg_factor_x =
static_cast<double>(dxp == 0. ? 1. : dxp_seg/dxp);
1477 const auto seg_factor_y =
static_cast<double>(dyp == 0. ? 1. : dyp_seg/dyp);
1478 const auto seg_factor_z =
static_cast<double>(dzp == 0. ? 1. : dzp_seg/dzp);
1481 double sx_cell[depos_order] = {0.};
1482 double sy_cell[depos_order] = {0.};
1483 double sz_cell[depos_order] = {0.};
1484 double const x0_bar = (x0_new + x0_old)/2.0;
1485 double const y0_bar = (y0_new + y0_old)/2.0;
1486 double const z0_bar = (z0_new + z0_old)/2.0;
1487 const int i0_cell = compute_shape_factor_cell( sx_cell, x0_bar-0.5 );
1488 const int j0_cell = compute_shape_factor_cell( sy_cell, y0_bar-0.5 );
1489 const int k0_cell = compute_shape_factor_cell( sz_cell, z0_bar-0.5 );
1491 if constexpr (depos_order >= 3) {
1493 double sx_old_cell[depos_order] = {0.};
1494 double sx_new_cell[depos_order] = {0.};
1495 double sy_old_cell[depos_order] = {0.};
1496 double sy_new_cell[depos_order] = {0.};
1497 double sz_old_cell[depos_order] = {0.};
1498 double sz_new_cell[depos_order] = {0.};
1499 const int i0_cell_2 = compute_shape_factors_cell( sx_old_cell, sx_new_cell, x0_old-0.5, x0_new-0.5 );
1500 const int j0_cell_2 = compute_shape_factors_cell( sy_old_cell, sy_new_cell, y0_old-0.5, y0_new-0.5 );
1501 const int k0_cell_2 = compute_shape_factors_cell( sz_old_cell, sz_new_cell, z0_old-0.5, z0_new-0.5 );
1503 for (
int m=0; m<depos_order; m++) {
1504 sx_cell[m] = (4.0*sx_cell[m] + sx_old_cell[m] + sx_new_cell[m])/6.0;
1505 sy_cell[m] = (4.0*sy_cell[m] + sy_old_cell[m] + sy_new_cell[m])/6.0;
1506 sz_cell[m] = (4.0*sz_cell[m] + sz_old_cell[m] + sz_new_cell[m])/6.0;
1511 double sx_old_node[depos_order+1] = {0.};
1512 double sx_new_node[depos_order+1] = {0.};
1513 double sy_old_node[depos_order+1] = {0.};
1514 double sy_new_node[depos_order+1] = {0.};
1515 double sz_old_node[depos_order+1] = {0.};
1516 double sz_new_node[depos_order+1] = {0.};
1517 const int i0_node = compute_shape_factors_node( sx_old_node, sx_new_node, x0_old, x0_new );
1518 const int j0_node = compute_shape_factors_node( sy_old_node, sy_new_node, y0_old, y0_new );
1519 const int k0_node = compute_shape_factors_node( sz_old_node, sz_new_node, z0_old, z0_new );
1522 amrex::Real this_Jx;
1523 for (
int i=0;
i<=depos_order-1;
i++) {
1524 for (
int j=0; j<=depos_order; j++) {
1525 for (
int k=0; k<=depos_order; k++) {
1526 this_Jx = wqx*sx_cell[
i]*( sy_old_node[j]*sz_old_node[k]*one_third
1527 + sy_old_node[j]*sz_new_node[k]*one_sixth
1528 + sy_new_node[j]*sz_old_node[k]*one_sixth
1529 + sy_new_node[j]*sz_new_node[k]*one_third )*seg_factor_x;
1536 amrex::Real this_Jy;
1537 for (
int i=0;
i<=depos_order;
i++) {
1538 for (
int j=0; j<=depos_order-1; j++) {
1539 for (
int k=0; k<=depos_order; k++) {
1540 this_Jy = wqy*sy_cell[j]*( sx_old_node[
i]*sz_old_node[k]*one_third
1541 + sx_old_node[
i]*sz_new_node[k]*one_sixth
1542 + sx_new_node[
i]*sz_old_node[k]*one_sixth
1543 + sx_new_node[
i]*sz_new_node[k]*one_third )*seg_factor_y;
1550 amrex::Real this_Jz;
1551 for (
int i=0;
i<=depos_order;
i++) {
1552 for (
int j=0; j<=depos_order; j++) {
1553 for (
int k=0; k<=depos_order-1; k++) {
1554 this_Jz = wqz*sz_cell[k]*( sx_old_node[
i]*sy_old_node[j]*one_third
1555 + sx_old_node[
i]*sy_new_node[j]*one_sixth
1556 + sx_new_node[
i]*sy_old_node[j]*one_sixth
1557 + sx_new_node[
i]*sy_new_node[j]*one_third )*seg_factor_z;
1564 if (ns < num_segments-1) {
1572 #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
1575 const auto i_old =
static_cast<int>(x_old-
shift);
1576 const auto i_new =
static_cast<int>(x_new-
shift);
1577 const int cell_crossings_x = std::abs(i_new-i_old);
1578 num_segments += cell_crossings_x;
1581 const auto k_old =
static_cast<int>(z_old-
shift);
1582 const auto k_new =
static_cast<int>(z_new-
shift);
1583 const int cell_crossings_z = std::abs(k_new-k_old);
1584 num_segments += cell_crossings_z;
1592 const double dxp = x_new - x_old;
1593 const double dzp = z_new - z_old;
1594 const auto dirX_sign =
static_cast<double>(dxp < 0. ? -1. : 1.);
1595 const auto dirZ_sign =
static_cast<double>(dzp < 0. ? -1. : 1.);
1596 double Xcell = 0., Zcell = 0.;
1597 if (num_segments > 1) {
1598 Xcell =
static_cast<double>(i_old) +
shift + 0.5*(1.-dirX_sign);
1599 Zcell =
static_cast<double>(k_old) +
shift + 0.5*(1.-dirZ_sign);
1605 double dxp_seg, dzp_seg;
1606 double x0_new, z0_new;
1607 double x0_old = x_old;
1608 double z0_old = z_old;
1610 for (
int ns=0; ns<num_segments; ns++) {
1612 if (ns == num_segments-1) {
1616 dxp_seg = x0_new - x0_old;
1617 dzp_seg = z0_new - z0_old;
1622 x0_new = Xcell + dirX_sign;
1623 z0_new = Zcell + dirZ_sign;
1624 dxp_seg = x0_new - x0_old;
1625 dzp_seg = z0_new - z0_old;
1627 if (dzp == 0. || std::abs(dxp_seg) < std::abs(dxp/dzp*dzp_seg)) {
1629 dzp_seg = dzp/dxp*dxp_seg;
1630 z0_new = z0_old + dzp_seg;
1634 dxp_seg = dxp/dzp*dzp_seg;
1635 x0_new = x0_old + dxp_seg;
1641 const auto seg_factor_x =
static_cast<double>(dxp == 0. ? 1. : dxp_seg/dxp);
1642 const auto seg_factor_z =
static_cast<double>(dzp == 0. ? 1. : dzp_seg/dzp);
1645 double sx_cell[depos_order] = {0.};
1646 double sz_cell[depos_order] = {0.};
1647 double const x0_bar = (x0_new + x0_old)/2.0;
1648 double const z0_bar = (z0_new + z0_old)/2.0;
1649 const int i0_cell = compute_shape_factor_cell( sx_cell, x0_bar-0.5 );
1650 const int k0_cell = compute_shape_factor_cell( sz_cell, z0_bar-0.5 );
1652 if constexpr (depos_order >= 3) {
1654 double sx_old_cell[depos_order] = {0.};
1655 double sx_new_cell[depos_order] = {0.};
1656 double sz_old_cell[depos_order] = {0.};
1657 double sz_new_cell[depos_order] = {0.};
1658 const int i0_cell_2 = compute_shape_factors_cell( sx_old_cell, sx_new_cell, x0_old-0.5, x0_new-0.5 );
1659 const int k0_cell_2 = compute_shape_factors_cell( sz_old_cell, sz_new_cell, z0_old-0.5, z0_new-0.5 );
1661 for (
int m=0; m<depos_order; m++) {
1662 sx_cell[m] = (4.0*sx_cell[m] + sx_old_cell[m] + sx_new_cell[m])/6.0;
1663 sz_cell[m] = (4.0*sz_cell[m] + sz_old_cell[m] + sz_new_cell[m])/6.0;
1668 double sx_old_node[depos_order+1] = {0.};
1669 double sx_new_node[depos_order+1] = {0.};
1670 double sz_old_node[depos_order+1] = {0.};
1671 double sz_new_node[depos_order+1] = {0.};
1672 const int i0_node = compute_shape_factors_node( sx_old_node, sx_new_node, x0_old, x0_new );
1673 const int k0_node = compute_shape_factors_node( sz_old_node, sz_new_node, z0_old, z0_new );
1676 amrex::Real this_Jx;
1677 for (
int i=0;
i<=depos_order-1;
i++) {
1678 for (
int k=0; k<=depos_order; k++) {
1679 this_Jx = wqx*sx_cell[
i]*(sz_old_node[k] + sz_new_node[k])/2.0_rt*seg_factor_x;
1681 #if defined(WARPX_DIM_RZ)
1683 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
1685 const Complex djr_cmplx = 2._rt*this_Jx*xy_mid;
1688 xy_mid = xy_mid*xy_mid0;
1695 const auto seg_factor_y = std::min(seg_factor_x,seg_factor_z);
1696 amrex::Real this_Jy;
1697 for (
int i=0;
i<=depos_order;
i++) {
1698 for (
int k=0; k<=depos_order; k++) {
1699 this_Jy = wqy*( sx_old_node[
i]*sz_old_node[k]*one_third
1700 + sx_old_node[
i]*sz_new_node[k]*one_sixth
1701 + sx_new_node[
i]*sz_old_node[k]*one_sixth
1702 + sx_new_node[
i]*sz_new_node[k]*one_third )*seg_factor_y;
1704 #if defined(WARPX_DIM_RZ)
1707 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
1709 const Complex djy_cmplx = 2._rt*this_Jy*xy_mid;
1712 xy_mid = xy_mid*xy_mid0;
1719 amrex::Real this_Jz;
1720 for (
int i=0;
i<=depos_order;
i++) {
1721 for (
int k=0; k<=depos_order-1; k++) {
1722 this_Jz = wqz*sz_cell[k]*(sx_old_node[
i] + sx_new_node[
i])/2.0_rt*seg_factor_z;
1724 #if defined(WARPX_DIM_RZ)
1726 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
1728 const Complex djz_cmplx = 2._rt*this_Jz*xy_mid;
1731 xy_mid = xy_mid*xy_mid0;
1738 if (ns < num_segments-1) {
1745 #elif defined(WARPX_DIM_1D_Z)
1748 const auto k_old =
static_cast<int>(z_old-
shift);
1749 const auto k_new =
static_cast<int>(z_new-
shift);
1750 const int cell_crossings_z = std::abs(k_new-k_old);
1751 num_segments += cell_crossings_z;
1758 double const dzp = z_new - z_old;
1759 const auto dirZ_sign =
static_cast<double>(dzp < 0. ? -1. : 1.);
1760 double Zcell =
static_cast<double>(k_old) +
shift + 0.5*(1.-dirZ_sign);
1767 double z0_old = z_old;
1769 for (
int ns=0; ns<num_segments; ns++) {
1771 if (ns == num_segments-1) {
1773 dzp_seg = z0_new - z0_old;
1776 Zcell = Zcell + dirZ_sign;
1778 dzp_seg = z0_new - z0_old;
1782 const auto seg_factor =
static_cast<double>(dzp == 0. ? 1. : dzp_seg/dzp);
1785 double sz_cell[depos_order] = {0.};
1786 double const z0_bar = (z0_new + z0_old)/2.0;
1787 const int k0_cell = compute_shape_factor_cell( sz_cell, z0_bar-0.5 );
1789 if constexpr (depos_order >= 3) {
1791 double sz_old_cell[depos_order] = {0.};
1792 double sz_new_cell[depos_order] = {0.};
1793 const int k0_cell_2 = compute_shape_factors_cell( sz_old_cell, sz_new_cell, z0_old-0.5, z0_new-0.5 );
1795 for (
int m=0; m<depos_order; m++) {
1796 sz_cell[m] = (4.0*sz_cell[m] + sz_old_cell[m] + sz_new_cell[m])/6.0;
1801 double sz_old_node[depos_order+1] = {0.};
1802 double sz_new_node[depos_order+1] = {0.};
1803 const int k0_node = compute_shape_factors_node( sz_old_node, sz_new_node, z0_old, z0_new );
1806 for (
int k=0; k<=depos_order; k++) {
1807 const amrex::Real weight = 0.5_rt*(sz_old_node[k] + sz_new_node[k])*seg_factor;
1813 for (
int k=0; k<=depos_order-1; k++) {
1814 const amrex::Real this_Jz = wqz*sz_cell[k]*seg_factor;
1819 if (ns < num_segments-1) {
1856 template <
int depos_order>
1858 const amrex::ParticleReal*
const wp,
1859 const amrex::ParticleReal*
const uxp,
1860 const amrex::ParticleReal*
const uyp,
1861 const amrex::ParticleReal*
const uzp,
1862 const int*
const ion_lev,
1868 amrex::Real relative_time,
1873 [[maybe_unused]]
int n_rz_azimuthal_modes)
1875 using namespace amrex::literals;
1877 #if defined(WARPX_DIM_RZ)
1879 wp, uxp, uyp, uzp, ion_lev, Dx_fab, Dy_fab, Dz_fab,
1880 np_to_deposit,
dt, relative_time, dinv, xyzmin, lo, q);
1884 #if defined(WARPX_DIM_1D_Z)
1886 wp, uxp, uyp, uzp, ion_lev, Dx_fab, Dy_fab, Dz_fab,
1887 np_to_deposit,
dt, relative_time, dinv, xyzmin, lo, q);
1891 #if !(defined WARPX_DIM_RZ || defined WARPX_DIM_1D_Z)
1894 const bool do_ionization = ion_lev;
1897 const amrex::Real invdt = 1._rt /
dt;
1899 const amrex::Real invvol = dinv.
x*dinv.
y*dinv.
z;
1902 #if defined(WARPX_DIM_3D)
1905 #elif defined(WARPX_DIM_XZ)
1924 const amrex::Real invgam = 1._rt / std::sqrt(1._rt + uxp[ip] * uxp[ip] * invcsq
1925 + uyp[ip] * uyp[ip] * invcsq
1926 + uzp[ip] * uzp[ip] * invcsq);
1928 amrex::Real wq = q * wp[ip];
1929 if (do_ionization) { wq *= ion_lev[ip]; }
1932 amrex::ParticleReal xp, yp, zp;
1933 GetPosition(ip, xp, yp, zp);
1936 const amrex::Real vx = uxp[ip] * invgam;
1937 const amrex::Real vy = uyp[ip] * invgam;
1938 const amrex::Real vz = uzp[ip] * invgam;
1941 xp += relative_time * vx;
1942 yp += relative_time * vy;
1943 zp += relative_time * vz;
1947 double const x_new = (xp - xyzmin.
x + 0.5_rt*
dt*vx) * dinv.
x;
1948 double const x_old = (xp - xyzmin.
x - 0.5_rt*
dt*vx) * dinv.
x;
1949 #if defined(WARPX_DIM_3D)
1951 double const y_new = (yp - xyzmin.
y + 0.5_rt*
dt*vy) * dinv.
y;
1952 double const y_old = (yp - xyzmin.
y - 0.5_rt*
dt*vy) * dinv.
y;
1955 double const z_new = (zp - xyzmin.
z + 0.5_rt*
dt*vz) * dinv.
z;
1956 double const z_old = (zp - xyzmin.
z - 0.5_rt*
dt*vz) * dinv.
z;
1960 double sx_new[depos_order+1] = {0.};
1961 double sx_old[depos_order+1] = {0.};
1962 #if defined(WARPX_DIM_3D)
1964 double sy_new[depos_order+1] = {0.};
1965 double sy_old[depos_order+1] = {0.};
1968 double sz_new[depos_order+1] = {0.};
1969 double sz_old[depos_order+1] = {0.};
1976 const int i_new = compute_shape_factor(sx_new, x_new);
1977 #if defined(WARPX_DIM_3D)
1980 const int j_new = compute_shape_factor(sy_new, y_new);
1984 const int k_new = compute_shape_factor(sz_new, z_new);
1990 const int i_old = compute_shape_factor(sx_old, x_old);
1991 #if defined(WARPX_DIM_3D)
1994 const int j_old = compute_shape_factor(sy_old, y_old);
1998 const int k_old = compute_shape_factor(sz_old, z_old);
2001 #if defined(WARPX_DIM_XZ)
2003 const amrex::Real wqy = wq * vy * invvol;
2004 for (
int k=0; k<=depos_order; k++) {
2005 for (
int i=0;
i<=depos_order;
i++) {
2009 auto const sxn_szn =
static_cast<amrex::Real
>(sx_new[
i] * sz_new[k]);
2010 auto const sxo_szn =
static_cast<amrex::Real
>(sx_old[
i] * sz_new[k]);
2011 auto const sxn_szo =
static_cast<amrex::Real
>(sx_new[
i] * sz_old[k]);
2012 auto const sxo_szo =
static_cast<amrex::Real
>(sx_old[
i] * sz_old[k]);
2014 if (i_new == i_old && k_new == k_old) {
2017 wq * invvol * invdt * (sxn_szn - sxo_szo));
2020 wq * invvol * invdt * (sxn_szo - sxo_szn));
2024 wqy * 0.25_rt * (sxn_szn + sxn_szo + sxo_szn + sxo_szo));
2028 wq * invvol * invdt * sxn_szn);
2031 - wq * invvol * invdt * sxo_szo);
2034 wq * invvol * invdt * sxn_szo);
2037 - wq * invvol * invdt * sxo_szn);
2041 wqy * 0.25_rt * sxn_szn);
2044 wqy * 0.25_rt * sxn_szo);
2047 wqy * 0.25_rt * sxo_szn);
2050 wqy * 0.25_rt * sxo_szo);
2056 #elif defined(WARPX_DIM_3D)
2058 for (
int k=0; k<=depos_order; k++) {
2059 for (
int j=0; j<=depos_order; j++) {
2061 auto const syn_szn =
static_cast<amrex::Real
>(sy_new[j] * sz_new[k]);
2062 auto const syo_szn =
static_cast<amrex::Real
>(sy_old[j] * sz_new[k]);
2063 auto const syn_szo =
static_cast<amrex::Real
>(sy_new[j] * sz_old[k]);
2064 auto const syo_szo =
static_cast<amrex::Real
>(sy_old[j] * sz_old[k]);
2066 for (
int i=0;
i<=depos_order;
i++) {
2068 auto const sxn_syn_szn =
static_cast<amrex::Real
>(sx_new[
i]) * syn_szn;
2069 auto const sxo_syn_szn =
static_cast<amrex::Real
>(sx_old[
i]) * syn_szn;
2070 auto const sxn_syo_szn =
static_cast<amrex::Real
>(sx_new[
i]) * syo_szn;
2071 auto const sxo_syo_szn =
static_cast<amrex::Real
>(sx_old[
i]) * syo_szn;
2072 auto const sxn_syn_szo =
static_cast<amrex::Real
>(sx_new[
i]) * syn_szo;
2073 auto const sxo_syn_szo =
static_cast<amrex::Real
>(sx_old[
i]) * syn_szo;
2074 auto const sxn_syo_szo =
static_cast<amrex::Real
>(sx_new[
i]) * syo_szo;
2075 auto const sxo_syo_szo =
static_cast<amrex::Real
>(sx_old[
i]) * syo_szo;
2077 if (i_new == i_old && j_new == j_old && k_new == k_old) {
2080 wq * invvol * invdt * (sxn_syn_szn - sxo_syo_szo));
2083 wq * invvol * invdt * (sxn_syn_szo - sxo_syo_szn));
2086 wq * invvol * invdt * (sxn_syo_szn - sxo_syn_szo));
2089 wq * invvol * invdt * (sxo_syn_szn - sxn_syo_szo));
2093 wq * invvol * invdt * sxn_syn_szn);
2096 - wq * invvol * invdt * sxo_syo_szo);
2099 wq * invvol * invdt * sxn_syn_szo);
2102 - wq * invvol * invdt * sxo_syo_szn);
2105 wq * invvol * invdt * sxn_syo_szn);
2108 - wq * invvol * invdt * sxo_syn_szo);
2111 wq * invvol * invdt * sxo_syn_szn);
2114 - wq * invvol * invdt * sxn_syo_szo);
2122 #if defined(WARPX_DIM_3D)
2125 const amrex::Real t_a = temp_arr(
i,j,k,0);
2126 const amrex::Real t_b = temp_arr(
i,j,k,1);
2127 const amrex::Real t_c = temp_arr(
i,j,k,2);
2128 const amrex::Real t_d = temp_arr(
i,j,k,3);
2129 Dx_arr(
i,j,k) += (1._rt/6._rt)*(2_rt*t_a + t_b + t_c - 2._rt*t_d);
2130 Dy_arr(
i,j,k) += (1._rt/6._rt)*(2_rt*t_a + t_b - 2._rt*t_c + t_d);
2131 Dz_arr(
i,j,k) += (1._rt/6._rt)*(2_rt*t_a - 2._rt*t_b + t_c + t_d);
2133 #elif defined(WARPX_DIM_XZ)
2136 const amrex::Real t_a = temp_arr(
i,j,0,0);
2137 const amrex::Real t_b = temp_arr(
i,j,0,1);
2138 Dx_arr(
i,j,0) += (0.5_rt)*(t_a + t_b);
2139 Dz_arr(
i,j,0) += (0.5_rt)*(t_a - t_b);
#define AMREX_ALWAYS_ASSERT(EX)
#define AMREX_GPU_HOST_DEVICE
#define AMREX_D_DECL(a, b, c)
void doVayDepositionShapeN(const GetParticlePosition< PIdx > &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 &Dx_fab, amrex::FArrayBox &Dy_fab, amrex::FArrayBox &Dz_fab, long np_to_deposit, amrex::Real dt, amrex::Real relative_time, const amrex::XDim3 &dinv, const amrex::XDim3 &xyzmin, amrex::Dim3 lo, amrex::Real q, [[maybe_unused]]int n_rz_azimuthal_modes)
Vay current deposition (Vay et al, 2013) for thread thread_num: deposit D in real space and store the...
Definition: CurrentDeposition.H:1857
void doDepositionShapeNImplicit(const GetParticlePosition< PIdx > &GetPosition, const amrex::ParticleReal *const wp, const amrex::ParticleReal *const uxp_n, const amrex::ParticleReal *const uyp_n, const amrex::ParticleReal *const uzp_n, 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_deposit, const amrex::XDim3 &dinv, const amrex::XDim3 &xyzmin, const amrex::Dim3 lo, const amrex::Real q, [[maybe_unused]]const int n_rz_azimuthal_modes)
Direct current deposition for thread thread_num for the implicit scheme The only difference from doDe...
Definition: CurrentDeposition.H:359
AMREX_GPU_HOST_DEVICE AMREX_INLINE void doDepositionShapeNKernel([[maybe_unused]] const amrex::ParticleReal xp, [[maybe_unused]] const amrex::ParticleReal yp, [[maybe_unused]] const amrex::ParticleReal zp, const amrex::ParticleReal wq, const amrex::ParticleReal vx, const amrex::ParticleReal vy, const amrex::ParticleReal vz, amrex::Array4< amrex::Real > const &jx_arr, amrex::Array4< amrex::Real > const &jy_arr, amrex::Array4< amrex::Real > const &jz_arr, amrex::IntVect const &jx_type, amrex::IntVect const &jy_type, amrex::IntVect const &jz_type, const amrex::Real relative_time, const amrex::XDim3 &dinv, const amrex::XDim3 &xyzmin, const amrex::Real invvol, const amrex::Dim3 lo, [[maybe_unused]] const int n_rz_azimuthal_modes)
Kernel for the direct current deposition for thread thread_num.
Definition: CurrentDeposition.H:50
void doChargeConservingDepositionShapeNImplicit([[maybe_unused]]const amrex::ParticleReal *const xp_n, [[maybe_unused]]const amrex::ParticleReal *const yp_n, [[maybe_unused]]const amrex::ParticleReal *const zp_n, const GetParticlePosition< PIdx > &GetPosition, const amrex::ParticleReal *const wp, [[maybe_unused]]const amrex::ParticleReal *const uxp_n, [[maybe_unused]]const amrex::ParticleReal *const uyp_n, [[maybe_unused]]const amrex::ParticleReal *const uzp_n, [[maybe_unused]]const amrex::ParticleReal *const uxp_nph, [[maybe_unused]]const amrex::ParticleReal *const uyp_nph, [[maybe_unused]]const amrex::ParticleReal *const uzp_nph, 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_deposit, const amrex::Real dt, const amrex::XDim3 &dinv, const amrex::XDim3 &xyzmin, const amrex::Dim3 lo, const amrex::Real q, [[maybe_unused]] const int n_rz_azimuthal_modes)
Esirkepov Current Deposition for thread thread_num for implicit scheme The difference from doEsirkepo...
Definition: CurrentDeposition.H:934
void doDepositionSharedShapeN(const GetParticlePosition< PIdx > &GetPosition, const amrex::ParticleReal *const wp, const amrex::ParticleReal *const uxp, const amrex::ParticleReal *const uyp, const amrex::ParticleReal *const uzp, const int *ion_lev, amrex::FArrayBox &jx_fab, amrex::FArrayBox &jy_fab, amrex::FArrayBox &jz_fab, long np_to_deposit, const amrex::Real relative_time, const amrex::XDim3 &dinv, const amrex::XDim3 &xyzmin, amrex::Dim3 lo, amrex::Real q, int n_rz_azimuthal_modes, const amrex::DenseBins< WarpXParticleContainer::ParticleTileType::ParticleTileDataType > &a_bins, const amrex::Box &box, const amrex::Geometry &geom, const amrex::IntVect &a_tbox_max_size)
Current Deposition for thread thread_num using shared memory.
Definition: CurrentDeposition.H:454
void doDepositionShapeN(const GetParticlePosition< PIdx > &GetPosition, const amrex::ParticleReal *const wp, const amrex::ParticleReal *const uxp, const amrex::ParticleReal *const uyp, const amrex::ParticleReal *const uzp, const int *ion_lev, amrex::FArrayBox &jx_fab, amrex::FArrayBox &jy_fab, amrex::FArrayBox &jz_fab, long np_to_deposit, amrex::Real relative_time, const amrex::XDim3 &dinv, const amrex::XDim3 &xyzmin, amrex::Dim3 lo, amrex::Real q, [[maybe_unused]]int n_rz_azimuthal_modes)
Current Deposition for thread thread_num.
Definition: CurrentDeposition.H:274
void doEsirkepovDepositionShapeN(const GetParticlePosition< PIdx > &GetPosition, const amrex::ParticleReal *const wp, const amrex::ParticleReal *const uxp, const amrex::ParticleReal *const uyp, const amrex::ParticleReal *const uzp, const int *ion_lev, const amrex::Array4< amrex::Real > &Jx_arr, const amrex::Array4< amrex::Real > &Jy_arr, const amrex::Array4< amrex::Real > &Jz_arr, long np_to_deposit, amrex::Real dt, amrex::Real relative_time, const amrex::XDim3 &dinv, const amrex::XDim3 &xyzmin, amrex::Dim3 lo, amrex::Real q, [[maybe_unused]]int n_rz_azimuthal_modes)
Esirkepov Current Deposition for thread thread_num.
Definition: CurrentDeposition.H:643
void doVillasenorDepositionShapeNImplicit([[maybe_unused]]const amrex::ParticleReal *const xp_n, [[maybe_unused]]const amrex::ParticleReal *const yp_n, [[maybe_unused]]const amrex::ParticleReal *const zp_n, const GetParticlePosition< PIdx > &GetPosition, const amrex::ParticleReal *const wp, [[maybe_unused]]const amrex::ParticleReal *const uxp_n, [[maybe_unused]]const amrex::ParticleReal *const uyp_n, [[maybe_unused]]const amrex::ParticleReal *const uzp_n, [[maybe_unused]]const amrex::ParticleReal *const uxp_nph, [[maybe_unused]]const amrex::ParticleReal *const uyp_nph, [[maybe_unused]]const amrex::ParticleReal *const uzp_nph, 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_deposit, const amrex::Real dt, const amrex::XDim3 &dinv, const amrex::XDim3 &xyzmin, const amrex::Dim3 lo, const amrex::Real q, [[maybe_unused]] const int n_rz_azimuthal_modes)
Villasenor and Buneman Current Deposition for thread thread_num for implicit scheme....
Definition: CurrentDeposition.H:1246
#define WARPX_ABORT_WITH_MESSAGE(MSG)
Definition: TextMsg.H:15
#define WARPX_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition: TextMsg.H:13
amrex::GpuComplex< amrex::Real > Complex
Definition: WarpX_Complex.H:22
static amrex::IntVect shared_tilesize
tileSize to use for shared current deposition operations
Definition: WarpX.H:255
static int shared_mem_current_tpb
number of threads to use per block in shared deposition
Definition: WarpX.H:252
AMREX_FORCE_INLINE Array4< Real const > array() const noexcept
const Box & box() const noexcept
AMREX_GPU_HOST_DEVICE BoxND & grow(int i) noexcept
AMREX_GPU_HOST_DEVICE IntVectND< dim > type() const noexcept
AMREX_GPU_HOST_DEVICE Long numPts() const noexcept
GpuArray< Real, AMREX_SPACEDIM > InvCellSizeArray() const noexcept
index_type * offsetsPtr() noexcept
index_type * permutationPtr() noexcept
Long numBins() const noexcept
GpuArray< Real, AMREX_SPACEDIM > ProbLoArray() const noexcept
const Box & Domain() const noexcept
static std::size_t sharedMemPerBlock() noexcept
static constexpr auto c
vacuum speed of light [m/s]
Definition: constant.H:44
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void AddNoRet(T *sum, T value) noexcept
void streamSynchronize() noexcept
gpuStream_t gpuStream() noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > shift(const BoxND< dim > &b, int dir, int nzones) noexcept
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE const T & max(const T &a, const T &b) noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > convert(const BoxND< dim > &b, const IntVectND< dim > &typ) noexcept
void launch(T const &n, L &&f) noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 end(BoxND< dim > const &box) noexcept
IntVectND< AMREX_SPACEDIM > IntVect
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 begin(BoxND< dim > const &box) noexcept
std::enable_if_t< std::is_integral_v< T > > ParallelFor(TypeList< CTOs... >, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int getTileIndex(const IntVect &iv, const Box &box, const bool a_do_tiling, const IntVect &a_tile_size, Box &tbx)
i
Definition: check_interp_points_and_weights.py:174
float dt
Definition: stencil.py:442
Definition: ShapeFactors.H:168
Definition: ShapeFactors.H:29
Definition: ShapeFactors.H:95
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T real() const noexcept
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T imag() const noexcept
AMREX_GPU_DEVICE T * dataPtr() noexcept