Skip to content

Commit

Permalink
Fix to use domain box
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgrote committed Feb 14, 2025
1 parent 085d335 commit a44ac51
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
14 changes: 7 additions & 7 deletions Source/Particles/Deposition/CurrentDeposition.H
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ void doVillasenorDepositionShapeNImplicit ([[maybe_unused]]const amrex::Particle
const amrex::Real dt,
const amrex::XDim3 & dinv,
const amrex::XDim3 & xyzmin,
const amrex::XDim3 & xyzmax,
const amrex::RealBox & prob_domain,
const amrex::GpuArray<amrex::GpuArray<bool,2>, AMREX_SPACEDIM> & is_absorbing,
const amrex::Dim3 lo,
const amrex::Real q,
Expand Down Expand Up @@ -1421,9 +1421,9 @@ void doVillasenorDepositionShapeNImplicit ([[maybe_unused]]const amrex::Particle
amrex::Real xp_np1_c = xp_np1;
amrex::Real yp_np1_c = yp_np1;
amrex::Real zp_np1_c = zp_np1;
ParticleUtils::crop_at_boundary(xp_n[ip], yp_n[ip], zp_n[ip], xp_np1_c, yp_np1_c, zp_np1_c, xyzmin.x, xyzmax.x, is_absorbing[0]);
ParticleUtils::crop_at_boundary(yp_n[ip], zp_n[ip], xp_n[ip], yp_np1_c, zp_np1_c, xp_np1_c, xyzmin.y, xyzmax.y, is_absorbing[1]);
ParticleUtils::crop_at_boundary(zp_n[ip], xp_n[ip], yp_n[ip], zp_np1_c, xp_np1_c, yp_np1_c, xyzmin.z, xyzmax.z, is_absorbing[2]);
ParticleUtils::crop_at_boundary(xp_n[ip], yp_n[ip], zp_n[ip], xp_np1_c, yp_np1_c, zp_np1_c, prob_domain.lo(0), prob_domain.hi(0), is_absorbing[0]);
ParticleUtils::crop_at_boundary(yp_n[ip], zp_n[ip], xp_n[ip], yp_np1_c, zp_np1_c, xp_np1_c, prob_domain.lo(1), prob_domain.hi(1), is_absorbing[1]);
ParticleUtils::crop_at_boundary(zp_n[ip], xp_n[ip], yp_n[ip], zp_np1_c, xp_np1_c, yp_np1_c, prob_domain.lo(2), prob_domain.hi(2), is_absorbing[2]);

// Keep these double to avoid bug in single precision
double const x_new = (xp_np1_c - xyzmin.x)*dinv.x;
Expand Down Expand Up @@ -1666,8 +1666,8 @@ void doVillasenorDepositionShapeNImplicit ([[maybe_unused]]const amrex::Particle
amrex::Real const vz = (zp_np1 - zp_n[ip])/dt;

amrex::Real zp_np1_c = zp_np1;
ParticleUtils::crop_at_boundary(xp_n_c, zp_n[ip], xp_np1_c, zp_np1_c, xyzmin.x, xyzmax.x, is_absorbing[0]);
ParticleUtils::crop_at_boundary(zp_n[ip], xp_n_c, zp_np1_c, xp_np1_c, xyzmin.z, xyzmax.z, is_absorbing[1]);
ParticleUtils::crop_at_boundary(xp_n_c, zp_n[ip], xp_np1_c, zp_np1_c, prob_domain.lo(0), prob_domain.hi(0), is_absorbing[0]);
ParticleUtils::crop_at_boundary(zp_n[ip], xp_n_c, zp_np1_c, xp_np1_c, prob_domain.lo(1), prob_domain.hi(1), is_absorbing[1]);

// Keep these double to avoid bug in single precision
double const x_new = (xp_np1_c - xyzmin.x)*dinv.x;
Expand Down Expand Up @@ -1855,7 +1855,7 @@ void doVillasenorDepositionShapeNImplicit ([[maybe_unused]]const amrex::Particle
#elif defined(WARPX_DIM_1D_Z)

amrex::Real zp_np1_c = zp_np1;
ParticleUtils::crop_at_boundary(zp_np1_c, xyzmin.z, xyzmax.z, is_absorbing[0]);
ParticleUtils::crop_at_boundary(zp_np1_c, prob_domain.lo(0), prob_domain.hi(0), is_absorbing[0]);

// Keep these double to avoid bug in single precision
double const z_new = (zp_np1_c - xyzmin.z)*dinv.z;
Expand Down
24 changes: 12 additions & 12 deletions Source/Particles/Gather/FieldGather.H
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ void doGatherPicnicShapeN (
[[maybe_unused]] const amrex::IndexType Bz_type,
const amrex::XDim3 & dinv,
const amrex::XDim3 & xyzmin,
const amrex::XDim3 & xyzmax,
const amrex::RealBox & prob_domain,
const amrex::GpuArray<amrex::GpuArray<bool,2>, AMREX_SPACEDIM> & is_absorbing,
const amrex::Dim3& lo,
const int n_rz_azimuthal_modes)
Expand Down Expand Up @@ -927,9 +927,9 @@ void doGatherPicnicShapeN (
amrex::Real xp_np1_c = xp_np1;
amrex::Real yp_np1_c = yp_np1;
amrex::Real zp_np1_c = zp_np1;
ParticleUtils::crop_at_boundary(xp_n, yp_n, zp_n, xp_np1_c, yp_np1_c, zp_np1_c, xyzmin.x, xyzmax.x, is_absorbing[0]);
ParticleUtils::crop_at_boundary(yp_n, zp_n, xp_n, yp_np1_c, zp_np1_c, xp_np1_c, xyzmin.y, xyzmax.y, is_absorbing[1]);
ParticleUtils::crop_at_boundary(zp_n, xp_n, yp_n, zp_np1_c, xp_np1_c, yp_np1_c, xyzmin.z, xyzmax.z, is_absorbing[2]);
ParticleUtils::crop_at_boundary(xp_n, yp_n, zp_n, xp_np1_c, yp_np1_c, zp_np1_c, prob_domain.lo(0), prob_domain.hi(0), is_absorbing[0]);
ParticleUtils::crop_at_boundary(yp_n, zp_n, xp_n, yp_np1_c, zp_np1_c, xp_np1_c, prob_domain.lo(1), prob_domain.hi(1), is_absorbing[1]);
ParticleUtils::crop_at_boundary(zp_n, xp_n, yp_n, zp_np1_c, xp_np1_c, yp_np1_c, prob_domain.lo(2), prob_domain.hi(2), is_absorbing[2]);

// Keep these double to avoid bug in single precision
double const x_new = (xp_np1_c - xyzmin.x)*dinv.x;
Expand Down Expand Up @@ -1193,8 +1193,8 @@ void doGatherPicnicShapeN (
#endif

amrex::Real zp_np1_c = zp_np1;
ParticleUtils::crop_at_boundary(xp_n_c, zp_n, xp_np1_c, zp_np1_c, xyzmin.x, xyzmax.x, is_absorbing[0]);
ParticleUtils::crop_at_boundary(zp_n, xp_n_c, zp_np1_c, xp_np1_c, xyzmin.z, xyzmax.z, is_absorbing[1]);
ParticleUtils::crop_at_boundary(xp_n_c, zp_n, xp_np1_c, zp_np1_c, prob_domain.lo(0), prob_domain.hi(0), is_absorbing[0]);
ParticleUtils::crop_at_boundary(zp_n, xp_n_c, zp_np1_c, xp_np1_c, prob_domain.lo(1), prob_domain.hi(1), is_absorbing[1]);

// Keep these double to avoid bug in single precision
double const x_new = (xp_np1_c - xyzmin.x)*dinv.x;
Expand Down Expand Up @@ -1426,7 +1426,7 @@ void doGatherPicnicShapeN (
#elif defined(WARPX_DIM_1D_Z)

amrex::Real zp_np1_c = zp_np1;
ParticleUtils::crop_at_boundary(zp_np1_c, xyzmin.z, xyzmax.z, is_absorbing[0]);
ParticleUtils::crop_at_boundary(zp_np1_c, prob_domain.lo(0), prob_domain.hi(0), is_absorbing[0]);

// Keep these double to avoid bug in single precision
double const z_new = (zp_np1_c - xyzmin.z)*dinv.z;
Expand Down Expand Up @@ -1744,7 +1744,7 @@ void doGatherShapeNImplicit (
const amrex::IndexType bz_type,
const amrex::XDim3 & dinv,
const amrex::XDim3 & xyzmin,
const amrex::XDim3 & xyzmax,
const amrex::RealBox & prob_domain,
const amrex::GpuArray<amrex::GpuArray<bool,2>, AMREX_SPACEDIM> & is_absorbing,
const amrex::Dim3& lo,
const int n_rz_azimuthal_modes,
Expand Down Expand Up @@ -1784,25 +1784,25 @@ void doGatherShapeNImplicit (
Exp, Eyp, Ezp, Bxp, Byp, Bzp,
ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
dinv, xyzmin, xyzmax, is_absorbing, lo, n_rz_azimuthal_modes);
dinv, xyzmin, prob_domain, is_absorbing, lo, n_rz_azimuthal_modes);
} else if (nox == 2) {
doGatherPicnicShapeN<2>(xp_n, yp_n, zp_n, xp_nph, yp_nph, zp_nph,
Exp, Eyp, Ezp, Bxp, Byp, Bzp,
ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
dinv, xyzmin, xyzmax, is_absorbing, lo, n_rz_azimuthal_modes);
dinv, xyzmin, prob_domain, is_absorbing, lo, n_rz_azimuthal_modes);
} else if (nox == 3) {
doGatherPicnicShapeN<3>(xp_n, yp_n, zp_n, xp_nph, yp_nph, zp_nph,
Exp, Eyp, Ezp, Bxp, Byp, Bzp,
ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
dinv, xyzmin, xyzmax, is_absorbing, lo, n_rz_azimuthal_modes);
dinv, xyzmin, prob_domain, is_absorbing, lo, n_rz_azimuthal_modes);
} else if (nox == 4) {
doGatherPicnicShapeN<4>(xp_n, yp_n, zp_n, xp_nph, yp_nph, zp_nph,
Exp, Eyp, Ezp, Bxp, Byp, Bzp,
ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
dinv, xyzmin, xyzmax, is_absorbing, lo, n_rz_azimuthal_modes);
dinv, xyzmin, prob_domain, is_absorbing, lo, n_rz_azimuthal_modes);
}
}
else if (depos_type == CurrentDepositionAlgo::Direct) {
Expand Down
4 changes: 2 additions & 2 deletions Source/Particles/PhysicalParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2832,9 +2832,9 @@ PhysicalParticleContainer::ImplicitPushXP (WarpXParIter& pti,

// Lower corner of tile box physical domain (take into account Galilean shift)
const amrex::XDim3 xyzmin = WarpX::LowerCorner(box, gather_lev, 0._rt);
const amrex::XDim3 xyzmax = WarpX::UpperCorner(box, gather_lev, 0._rt);

const WarpX& warpx = WarpX::GetInstance();
amrex::RealBox const prob_domain = warpx.Geom(0).ProbDomain();
amrex::Box const& domain_box = warpx.Geom(0).Domain();
auto const & field_boundary_lo = warpx.GetFieldBoundaryLo();
auto const & field_boundary_hi = warpx.GetFieldBoundaryHi();
Expand Down Expand Up @@ -3002,7 +3002,7 @@ PhysicalParticleContainer::ImplicitPushXP (WarpXParIter& pti,
doGatherShapeNImplicit(xp_n, yp_n, zp_n, xp, yp, zp, Exp, Eyp, Ezp, Bxp, Byp, Bzp,
ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
ex_type, ey_type, ez_type, bx_type, by_type, bz_type,
dinv, xyzmin, xyzmax, is_absorbing, lo, n_rz_azimuthal_modes, nox,
dinv, xyzmin, prob_domain, is_absorbing, lo, n_rz_azimuthal_modes, nox,
depos_type );
}

Expand Down
11 changes: 6 additions & 5 deletions Source/Particles/WarpXParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,8 @@ WarpXParticleContainer::DepositCurrent (WarpXParIter& pti,
const Dim3 lo = lbound(tilebox);
// Take into account Galilean shift
const amrex::XDim3 xyzmin = WarpX::LowerCorner(tilebox, depos_lev, 0.5_rt*dt);
const amrex::XDim3 xyzmax = WarpX::UpperCorner(tilebox, depos_lev, 0.5_rt*dt);

amrex::RealBox const prob_domain = warpx.Geom(0).ProbDomain();
amrex::Box const& domain_box = warpx.Geom(0).Domain();

auto const & field_boundary_lo = warpx.GetFieldBoundaryLo();
Expand Down Expand Up @@ -717,31 +718,31 @@ WarpXParticleContainer::DepositCurrent (WarpXParIter& pti,
GetPosition, wp.dataPtr() + offset,
uxp_n.dataPtr() + offset, uyp_n.dataPtr() + offset, uzp_n.dataPtr() + offset,
uxp.dataPtr() + offset, uyp.dataPtr() + offset, uzp.dataPtr() + offset, ion_lev,
jx_arr, jy_arr, jz_arr, np_to_deposit, dt, dinv, xyzmin, xyzmax, is_absorbing, lo, q,
jx_arr, jy_arr, jz_arr, np_to_deposit, dt, dinv, xyzmin, prob_domain, is_absorbing, lo, q,
WarpX::n_rz_azimuthal_modes);
} else if (WarpX::nox == 2){
doVillasenorDepositionShapeNImplicit<2>(
xp_n_data, yp_n_data, zp_n_data,
GetPosition, wp.dataPtr() + offset,
uxp_n.dataPtr() + offset, uyp_n.dataPtr() + offset, uzp_n.dataPtr() + offset,
uxp.dataPtr() + offset, uyp.dataPtr() + offset, uzp.dataPtr() + offset, ion_lev,
jx_arr, jy_arr, jz_arr, np_to_deposit, dt, dinv, xyzmin, xyzmax, is_absorbing, lo, q,
jx_arr, jy_arr, jz_arr, np_to_deposit, dt, dinv, xyzmin, prob_domain, is_absorbing, lo, q,
WarpX::n_rz_azimuthal_modes);
} else if (WarpX::nox == 3){
doVillasenorDepositionShapeNImplicit<3>(
xp_n_data, yp_n_data, zp_n_data,
GetPosition, wp.dataPtr() + offset,
uxp_n.dataPtr() + offset, uyp_n.dataPtr() + offset, uzp_n.dataPtr() + offset,
uxp.dataPtr() + offset, uyp.dataPtr() + offset, uzp.dataPtr() + offset, ion_lev,
jx_arr, jy_arr, jz_arr, np_to_deposit, dt, dinv, xyzmin, xyzmax, is_absorbing, lo, q,
jx_arr, jy_arr, jz_arr, np_to_deposit, dt, dinv, xyzmin, prob_domain, is_absorbing, lo, q,
WarpX::n_rz_azimuthal_modes);
} else if (WarpX::nox == 4){
doVillasenorDepositionShapeNImplicit<4>(
xp_n_data, yp_n_data, zp_n_data,
GetPosition, wp.dataPtr() + offset,
uxp_n.dataPtr() + offset, uyp_n.dataPtr() + offset, uzp_n.dataPtr() + offset,
uxp.dataPtr() + offset, uyp.dataPtr() + offset, uzp.dataPtr() + offset, ion_lev,
jx_arr, jy_arr, jz_arr, np_to_deposit, dt, dinv, xyzmin, xyzmax, is_absorbing, lo, q,
jx_arr, jy_arr, jz_arr, np_to_deposit, dt, dinv, xyzmin, prob_domain, is_absorbing, lo, q,
WarpX::n_rz_azimuthal_modes);
}
}
Expand Down

0 comments on commit a44ac51

Please sign in to comment.