Skip to content

Commit

Permalink
Fix: bin_size
Browse files Browse the repository at this point in the history
Upper bound had an off-by-one error for binning.
  • Loading branch information
ax3l committed Aug 22, 2024
1 parent 78b13bf commit 15a5d77
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/particles/wakefields/ChargeBinning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ namespace impactx::particles::wakefields
for (int lev = 0; lev <= nlevs; ++lev)
{
// OpenMP parallelization if enabled
#ifdef AMREX_USE_OMP
#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
#endif
//ifdef AMREX_USE_OMP
//pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
//endif
{
// Loop over particles at the current grid level
for (impactx::ParIterSoA pti(myspc, lev); pti.isValid(); ++pti)
Expand Down Expand Up @@ -140,9 +140,9 @@ namespace impactx::particles::wakefields
int const nlevs = myspc.finestLevel();
for (int lev = 0; lev <= nlevs; ++lev)
{
#ifdef AMREX_USE_OMP
#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
#endif
//ifdef AMREX_USE_OMP
//pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
//endif
{
for (impactx::ParIterSoA pti(myspc, lev); pti.isValid(); ++pti)
{
Expand Down
2 changes: 1 addition & 1 deletion src/particles/wakefields/ExecuteWakefield.H
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace impactx::particles::wakefields
int const num_bins = csr_bins; // Set resolution
amrex::Real const bin_min = t_min;
amrex::Real const bin_max = t_max;
amrex::Real const bin_size = (bin_max - bin_min) / num_bins;
amrex::Real const bin_size = (bin_max - bin_min) / (num_bins - 1);

// Allocate memory for the charge profile
amrex::Gpu::DeviceVector<amrex::Real> charge_distribution(num_bins, 0.0);
Expand Down
2 changes: 1 addition & 1 deletion src/particles/wakefields/WakePush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace impactx::particles::wakefields

if (idx < 0 || idx >= cw_size)
{
std::cerr << "Warning: Index out of range for wakfield." << std::endl;
std::cerr << "Warning: Index out of range for wakefield: " << idx << std::endl;
}

amrex::ParticleReal const F_L = wakefield_ptr[idx];
Expand Down

0 comments on commit 15a5d77

Please sign in to comment.