Skip to content

Commit

Permalink
Fix Lost Particle w/ Runtime Attr
Browse files Browse the repository at this point in the history
For some processes and/or diagnostics, we add extra runtime
attributes to our beam (particle container). The logic that
collected "lost" particles in the beamline, i.e., as marked as
lost in apertures, did not account for extra runtime attributes
and thus got lost in bookkeeping.

This fixes the collection logic to be more robust and also copy
any extra runtime attributes over to the "lost" particle recording.

This was first seen with an input that used the nonlinear lens (NLL),
NLL-invariant diagnostics and an aperture at the same time.
  • Loading branch information
ax3l committed Jan 10, 2025
1 parent 8ef479d commit 5e58cdb
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/particles/CollectLost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,26 @@ namespace impactx
BL_PROFILE("impactX::collect_lost_particles");

using SrcData = ImpactXParticleContainer::ParticleTileType::ConstParticleTileDataType;

ImpactXParticleContainer& dest = *source.GetLostParticleContainer();

// Check destination has the same attributes as source + "s_lost"
for (auto & name : source.GetRealSoANames())
{
if (!dest.HasRealComp(name)) {
dest.AddRealComp(name);
}
}
for (auto & name : source.GetIntSoANames())
{
if (!dest.HasIntComp(name)) {
dest.AddIntComp(name);
}
}
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(source.GetRealSoANames().size() + 1 == dest.GetRealSoANames().size(),
"Source and destination have different Real attributes!");
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(source.GetIntSoANames().size() == dest.GetIntSoANames().size(),
"Source and destination have different Int attributes!");

const int s_runtime_index = dest.GetRealCompIndex("s_lost") - dest.NArrayReal;

RefPart const ref_part = source.GetRefParticle();
Expand Down

0 comments on commit 5e58cdb

Please sign in to comment.