diff options
author | 2022-12-09 14:43:50 -0800 | |
---|---|---|
committer | 2022-12-09 14:43:50 -0800 | |
commit | e6fae8b2b338dd765eae60bdabb4233b709b7b13 (patch) | |
tree | 3765c601fb988140948dc4b731bea7081f49378d /Source/Particles/PhysicalParticleContainer.cpp | |
parent | 7fbfd20121ea8726d0f6a91bcbd9b88dd1500f81 (diff) | |
download | WarpX-e6fae8b2b338dd765eae60bdabb4233b709b7b13.tar.gz WarpX-e6fae8b2b338dd765eae60bdabb4233b709b7b13.tar.zst WarpX-e6fae8b2b338dd765eae60bdabb4233b709b7b13.zip |
Improve memory footprint for ParticleInitialize (#3392)
Diffstat (limited to 'Source/Particles/PhysicalParticleContainer.cpp')
-rw-r--r-- | Source/Particles/PhysicalParticleContainer.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
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<Real, 3>{lo.x,(lo.x+hi.x)/2._rt,hi.x}; + const auto ylim = GpuArray<Real, 3>{lo.y,(lo.y+hi.y)/2._rt,hi.y}; + const auto zlim = GpuArray<Real, 3>{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); |