Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Lost Particle w/ Runtime Attr #795

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atmyers question for you: we use amrex::filterAndTransformParticles below.
I am a bit afraid that when the order of attributes added in dest is not 100% the same as in source that this gets confused.

In particular, the attributes in source are something like:

  • x,y,t,px,py,pt,I,H
    and in dest
  • x,y,t,px,py,pt,s,I,H

s, I and H are runtime components, all are Real.

Will that lead to broken/mismatched or partial copies from source to dest?

Copy link
Member Author

@ax3l ax3l Jan 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to add a few asserts, but maybe we need to generalize with new helper methods/functions for copies that help with the matching a bit, to simplify complex bookkeeping.

}
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
Loading