Skip to content

Commit

Permalink
Update total particle derive to use ParallelFor
Browse files Browse the repository at this point in the history
  • Loading branch information
jmsexton03 committed Jul 27, 2023
1 parent 8613f29 commit d00eb7d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Source/DerivedQuantities/ParticleDerive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,20 @@ Nyx::particle_derive (const std::string& name, Real time, int ngrow)
{
const FArrayBox& ffab = temp_dat[mfi];
FArrayBox& cfab = ctemp_dat[mfi];
auto farr = temp_dat.array(mfi);
auto carr = ctemp_dat.array(mfi);
const Box& fbx = ffab.box();

BL_ASSERT(cfab.box() == amrex::coarsen(fbx, trr));

for (IntVect p = fbx.smallEnd(); p <= fbx.bigEnd(); fbx.next(p))
amrex::ParallelFor(fbx,
[=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
const Real val = ffab(p);
auto p = IntVect(AMREX_D_DECL(i,j,k));
const Real val = farr(i,j,k);
if (val > 0)
cfab(amrex::coarsen(p, trr)) += val;
}
carr(amrex::coarsen(p, trr)) += val;
});
}

temp_dat.clear();
Expand Down

0 comments on commit d00eb7d

Please sign in to comment.