Skip to content

Commit

Permalink
Remove macros from apply_boundaries
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgrote committed Jun 10, 2024
1 parent e80ca98 commit 74d23ad
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 31 deletions.
20 changes: 9 additions & 11 deletions Source/Particles/ParticleBoundaries_K.H
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,15 @@ namespace ApplyParticleBoundaries {
*/
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void
apply_boundaries (
#ifndef WARPX_DIM_1D_Z
amrex::ParticleReal& x, amrex::Real xmin, amrex::Real xmax,
#endif
#if (defined WARPX_DIM_3D) || (defined WARPX_DIM_RZ)
amrex::ParticleReal& y,
#endif
#if (defined WARPX_DIM_3D)
amrex::Real ymin, amrex::Real ymax,
#endif
amrex::ParticleReal& z, amrex::Real zmin, amrex::Real zmax,
apply_boundaries ([[maybe_unused]] amrex::ParticleReal& x,
[[maybe_unused]] amrex::Real xmin,
[[maybe_unused]] amrex::Real xmax,
[[maybe_unused]] amrex::ParticleReal& y,
[[maybe_unused]] amrex::Real ymin,
[[maybe_unused]] amrex::Real ymax,
[[maybe_unused]] amrex::ParticleReal& z,
[[maybe_unused]] amrex::Real zmin,
[[maybe_unused]] amrex::Real zmax,
amrex::ParticleReal& ux, amrex::ParticleReal& uy, amrex::ParticleReal& uz,
bool& particle_lost,
ParticleBoundaries::ParticleBoundariesData const& boundaries,
Expand Down
33 changes: 13 additions & 20 deletions Source/Particles/WarpXParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,17 @@ WarpXParticleContainer::ApplyBoundaryConditions (){

auto boundary_conditions = m_boundary_conditions.data;

amrex::Box const & domain = Geom(0).Domain();
std::array<amrex::Real,3> xyzmin = WarpX::LowerCorner(domain, 0, 0._rt);
std::array<amrex::Real,3> xyzmax = WarpX::UpperCorner(domain, 0, 0._rt);

const amrex::Real xmin = xyzmin[0];
const amrex::Real xmax = xyzmax[0];
const amrex::Real ymin = xyzmin[1];
const amrex::Real ymax = xyzmax[1];
const amrex::Real zmin = xyzmin[2];
const amrex::Real zmax = xyzmax[2];

for (int lev = 0; lev <= finestLevel(); ++lev)
{
#ifdef AMREX_USE_OMP
Expand All @@ -1572,16 +1583,6 @@ WarpXParticleContainer::ApplyBoundaryConditions (){
{
auto GetPosition = GetParticlePosition<PIdx>(pti);
auto SetPosition = SetParticlePosition<PIdx>(pti);
#ifndef WARPX_DIM_1D_Z
const Real xmin = Geom(lev).ProbLo(0);
const Real xmax = Geom(lev).ProbHi(0);
#endif
#ifdef WARPX_DIM_3D
const Real ymin = Geom(lev).ProbLo(1);
const Real ymax = Geom(lev).ProbHi(1);
#endif
const Real zmin = Geom(lev).ProbLo(WARPX_ZINDEX);
const Real zmax = Geom(lev).ProbHi(WARPX_ZINDEX);

ParticleTileType& ptile = ParticlesAt(lev, pti);

Expand All @@ -1604,16 +1605,8 @@ WarpXParticleContainer::ApplyBoundaryConditions (){
// Note that for RZ, (x, y, z) is actually (r, theta, z).

bool particle_lost = false;
ApplyParticleBoundaries::apply_boundaries(
#ifndef WARPX_DIM_1D_Z
x, xmin, xmax,
#endif
#if (defined WARPX_DIM_3D) || (defined WARPX_DIM_RZ)
y,
#endif
#if (defined WARPX_DIM_3D)
ymin, ymax,
#endif
ApplyParticleBoundaries::apply_boundaries(x, xmin, xmax,
y, ymin, ymax,
z, zmin, zmax,
ux[i], uy[i], uz[i], particle_lost,
boundary_conditions, engine);
Expand Down

0 comments on commit 74d23ad

Please sign in to comment.