Skip to content

Commit

Permalink
Revert "also use atomics in the particle_dx != dx case (AMReX-Codes#1356
Browse files Browse the repository at this point in the history
)"

This reverts commit 81e030b.
  • Loading branch information
kweide authored Sep 28, 2020
1 parent 3481118 commit 73867ce
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Src/Particle/AMReX_Particle_mod_K.H
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void amrex_deposit_particle_dx_cic (P const& p, int nc, amrex::Array4<amrex::Rea
if (i < rho.begin.x || i >= rho.end.x) continue;
amrex::Real wx = amrex::min(hx - i, amrex::Real(1.0)) - amrex::max(lx - i, amrex::Real(0.0));
amrex::Real weight = wx*factor;
amrex::Gpu::Atomic::Add(&rho(i, 0, 0, 0), static_cast<Real>(weight*p.rdata(0)));
rho(i, 0, 0, 0) += weight*p.rdata(0);
}

for (int comp = 1; comp < nc; ++comp)
Expand All @@ -134,7 +134,7 @@ void amrex_deposit_particle_dx_cic (P const& p, int nc, amrex::Array4<amrex::Rea
if (i < rho.begin.x || i >= rho.end.x) continue;
amrex::Real wx = amrex::min(hx - i, amrex::Real(1.0)) - amrex::max(lx - i, amrex::Real(0.0));
amrex::Real weight = wx*factor;
amrex::Gpu::Atomic::Add(&rho(i, 0, 0, comp), static_cast<Real>(weight*p.rdata(0)*p.rdata(comp)));
rho(i, 0, 0, comp) += weight*p.rdata(0)*p.rdata(comp);
}
}

Expand All @@ -159,8 +159,10 @@ void amrex_deposit_particle_dx_cic (P const& p, int nc, amrex::Array4<amrex::Rea
for (int i = lo_x; i <= hi_x; ++i) {
if (i < rho.begin.x || i >= rho.end.x) continue;
amrex::Real wx = amrex::min(hx - i, amrex::Real(1.0)) - amrex::max(lx - i, amrex::Real(0.0));

amrex::Real weight = wx*wy*factor;
amrex::Gpu::Atomic::Add(&rho(i, j, 0, 0), static_cast<Real>(weight*p.rdata(0)));

rho(i, j, 0, 0) += weight*p.rdata(0);
}
}

Expand All @@ -172,7 +174,7 @@ void amrex_deposit_particle_dx_cic (P const& p, int nc, amrex::Array4<amrex::Rea
if (i < rho.begin.x || i >= rho.end.x) continue;
amrex::Real wx = amrex::min(hx - i, amrex::Real(1.0)) - amrex::max(lx - i, amrex::Real(0.0));
amrex::Real weight = wx*wy*factor;
amrex::Gpu::Atomic::Add(&rho(i, j, 0, comp), static_cast<Real>(weight*p.rdata(0)*p.rdata(comp)));
rho(i, j, 0, comp) += weight*p.rdata(0)*p.rdata(comp);
}
}
}
Expand Down Expand Up @@ -205,8 +207,10 @@ void amrex_deposit_particle_dx_cic (P const& p, int nc, amrex::Array4<amrex::Rea
for (int i = lo_x; i <= hi_x; ++i) {
if (i < rho.begin.x || i >= rho.end.x) continue;
amrex::Real wx = amrex::min(hx - i, amrex::Real(1.0)) - amrex::max(lx - i, amrex::Real(0.0));

amrex::Real weight = wx*wy*wz*factor;
amrex::Gpu::Atomic::Add(&rho(i, j, k, 0), static_cast<Real>(weight*p.rdata(0)));

rho(i, j, k, 0) += weight*p.rdata(0);
}
}
}
Expand All @@ -222,7 +226,7 @@ void amrex_deposit_particle_dx_cic (P const& p, int nc, amrex::Array4<amrex::Rea
if (i < rho.begin.x || i >= rho.end.x) continue;
amrex::Real wx = amrex::min(hx - i, amrex::Real(1.0)) - amrex::max(lx - i, amrex::Real(0.0));
amrex::Real weight = wx*wy*wz*factor;
amrex::Gpu::Atomic::Add(&rho(i, j, k, comp), static_cast<Real>(weight*p.rdata(0)*p.rdata(comp)));
rho(i, j, k, comp) += weight*p.rdata(0)*p.rdata(comp);
}
}
}
Expand Down

0 comments on commit 73867ce

Please sign in to comment.