aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/PhysicalParticleContainer.cpp
diff options
context:
space:
mode:
authorGravatar Weiqun Zhang <WeiqunZhang@lbl.gov> 2022-04-16 08:20:40 -0700
committerGravatar GitHub <noreply@github.com> 2022-04-16 08:20:40 -0700
commit18a1df1943283a693daa153dc40f44be769b0850 (patch)
tree264b41bb7e47ad906a33870b3eb26e7877fdea7b /Source/Particles/PhysicalParticleContainer.cpp
parent48f10bedc1650c6ebc519115e9e1b45865db1e72 (diff)
downloadWarpX-18a1df1943283a693daa153dc40f44be769b0850.tar.gz
WarpX-18a1df1943283a693daa153dc40f44be769b0850.tar.zst
WarpX-18a1df1943283a693daa153dc40f44be769b0850.zip
Avoid unnecessary construction of CopyParticleAttribs (#3042)
If it's not used there is no reason to construct a CopyParticleAttribs object. In fact, it could result in a runtime `std::out_of_range` error in `std::map::at()` because `tmp_particle_data` is used in the CopyParticleAttribs constructor, but in `PhysicalParticleContainer::Evolve`, `tmp_particle_data` is properly prepared only when doing back transformed diagnostics.
Diffstat (limited to 'Source/Particles/PhysicalParticleContainer.cpp')
-rw-r--r--Source/Particles/PhysicalParticleContainer.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp
index 8845fb9e2..f8ec5044b 100644
--- a/Source/Particles/PhysicalParticleContainer.cpp
+++ b/Source/Particles/PhysicalParticleContainer.cpp
@@ -2594,11 +2594,14 @@ PhysicalParticleContainer::PushPX (WarpXParIter& pti,
ParticleReal* const AMREX_RESTRICT uy = attribs[PIdx::uy].dataPtr() + offset;
ParticleReal* const AMREX_RESTRICT uz = attribs[PIdx::uz].dataPtr() + offset;
- auto copyAttribs = CopyParticleAttribs(pti, tmp_particle_data, offset);
int do_copy = ( (WarpX::do_back_transformed_diagnostics
&& do_back_transformed_diagnostics
&& a_dt_type!=DtType::SecondHalf)
|| (m_do_back_transformed_particles && (a_dt_type!=DtType::SecondHalf)) );
+ CopyParticleAttribs copyAttribs;
+ if (do_copy) {
+ copyAttribs = CopyParticleAttribs(pti, tmp_particle_data, offset);
+ }
int* AMREX_RESTRICT ion_lev = nullptr;
if (do_field_ionization) {