From e6fae8b2b338dd765eae60bdabb4233b709b7b13 Mon Sep 17 00:00:00 2001 From: Revathi Jambunathan <41089244+RevathiJambunathan@users.noreply.github.com> Date: Fri, 9 Dec 2022 14:43:50 -0800 Subject: Improve memory footprint for ParticleInitialize (#3392) --- Source/Particles/PhysicalParticleContainer.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 62d4df594..cbb0a6932 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -990,6 +990,27 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox) r = 1; } pcounts[index] = num_ppc*r; + // update pcount by checking if cell-corners or cell-center + // has non-zero density + const auto xlim = GpuArray{lo.x,(lo.x+hi.x)/2._rt,hi.x}; + const auto ylim = GpuArray{lo.y,(lo.y+hi.y)/2._rt,hi.y}; + const auto zlim = GpuArray{lo.z,(lo.z+hi.z)/2._rt,hi.z}; + + const auto checker = [&](){ + for (const auto& x : xlim) + for (const auto& y : ylim) + for (const auto& z : zlim) + if (inj_pos->insideBounds(x,y,z) and (inj_rho->getDensity(x,y,z) > 0) ) { + return 1; + } + return 0; + }; + const int flag_pcount = checker(); + if (flag_pcount == 1) { + pcounts[index] = num_ppc*r; + } else { + pcounts[index] = 0; + } } #if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) amrex::ignore_unused(k); -- cgit v1.2.3