Skip to content

Commit

Permalink
also use atomics in the particle_dx != dx case (AMReX-Codes#1356)
Browse files Browse the repository at this point in the history
  • Loading branch information
atmyers authored and dwillcox committed Oct 3, 2020
1 parent 3098ea6 commit dee1030
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 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;
rho(i, 0, 0, 0) += weight*p.rdata(0);
amrex::Gpu::Atomic::Add(&rho(i, 0, 0, 0), static_cast<Real>(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;
rho(i, 0, 0, comp) += weight*p.rdata(0)*p.rdata(comp);
amrex::Gpu::Atomic::Add(&rho(i, 0, 0, comp), static_cast<Real>(weight*p.rdata(0)*p.rdata(comp)));
}
}

Expand All @@ -159,10 +159,8 @@ 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;

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

Expand All @@ -174,7 +172,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;
rho(i, j, 0, comp) += weight*p.rdata(0)*p.rdata(comp);
amrex::Gpu::Atomic::Add(&rho(i, j, 0, comp), static_cast<Real>(weight*p.rdata(0)*p.rdata(comp)));
}
}
}
Expand Down Expand Up @@ -207,10 +205,8 @@ 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;

rho(i, j, k, 0) += weight*p.rdata(0);
amrex::Gpu::Atomic::Add(&rho(i, j, k, 0), static_cast<Real>(weight*p.rdata(0)));
}
}
}
Expand All @@ -226,7 +222,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;
rho(i, j, k, comp) += weight*p.rdata(0)*p.rdata(comp);
amrex::Gpu::Atomic::Add(&rho(i, j, k, comp), static_cast<Real>(weight*p.rdata(0)*p.rdata(comp)));
}
}
}
Expand Down

0 comments on commit dee1030

Please sign in to comment.