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

Remove Temporary Particle Container tmp_pc #5056

Open
RemiLehe opened this issue Jul 17, 2024 · 3 comments · May be fixed by #5571
Open

Remove Temporary Particle Container tmp_pc #5056

RemiLehe opened this issue Jul 17, 2024 · 3 comments · May be fixed by #5571
Assignees
Labels
cleaning Clean code, improve readability

Comments

@RemiLehe
Copy link
Member

RemiLehe commented Jul 17, 2024

The WarpXParticleContainer class has a tmp_particle_data (tmp_pc) here: https://github.com/ECP-WarpX/WarpX/blob/development/Source/Particles/WarpXParticleContainer.H#L507, which is used exclusively to save the old positions and momenta used in the boosted-frame diagnostics:
https://github.com/ECP-WarpX/WarpX/blob/development/Source/Particles/PhysicalParticleContainer.cpp#L2813
https://github.com/ECP-WarpX/WarpX/blob/development/Source/Particles/PhysicalParticleContainer.cpp#L2813

This is a bit clunky, e.g. as tmp_particle_data needs to be resized here:
https://github.com/ECP-WarpX/WarpX/blob/development/Source/Particles/WarpXParticleContainer.cpp#L1523
Additionally, the name is not very descriptive, and might confuse new developers (it is not clear that this is related to BTD, unless one really search through the code for the places where tmp_particle_data is used.)

It might be cleaner to remove tmp_particle_data and instead use runtime components, as is done currently for the implicit PIC (which also needs to save the old positions and momenta, albeit at a different point in the PIC loop):
https://github.com/ECP-WarpX/WarpX/blob/development/Source/Initialization/WarpXInitData.cpp#L591
https://github.com/ECP-WarpX/WarpX/blob/development/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp#L113
https://github.com/ECP-WarpX/WarpX/blob/development/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp#L113

We could use similar runtime components for the BTD, but with a different name in order not to conflict with the implicit solver (e.g. uz_btd_old instead of uz_n). I also seem to remember that we can set a flag on some runtime component to avoid doing MPI exchanges (which would be useful for the runtime components that would replace tmp_particle_data).

@EZoni EZoni added the cleaning Clean code, improve readability label Jul 17, 2024
@EZoni EZoni changed the title Code clean-up: remove tmp_particle_data Code cleanup: remove tmp_particle_data Jul 23, 2024
@EZoni EZoni changed the title Code cleanup: remove tmp_particle_data Clean code: remove tmp_particle_data Jul 23, 2024
@ax3l ax3l changed the title Clean code: remove tmp_particle_data Remove Temporary Particle Container tmp_pc Jan 10, 2025
@atmyers
Copy link
Member

atmyers commented Jan 13, 2025

I think this plan looks good. We should merge #5489 beforehand, because we also don't want to read/write the BTD runtime components from/to the checkpoint files.

@atmyers
Copy link
Member

atmyers commented Jan 16, 2025

Hi @EZoni - here some detailed steps I think will work:

  1. Remove all references to tmp_particle_data from WarpX. In particular there are several places we are resizing tmp_particle_data that will not be needed any more.
  2. In both Warpx::InitFromScratch and Warpx::InitFromCheckpoint, add logic to add new particle real components if m_do_back_transformed_particles is true. You can look at how this is handled in the CreateParticleAttributes() method in this PR: Fix restart for implicit simulations #5489
  3. In BackTransformParticleFunctor.H/cpp, both SelectParticles and LorentzTransformParticles no longer need to take tmp_particle_data - they can get the proper components from a_pti instead.
  4. The same is true for the CopyParticleAttribs functor at Source/Particles/Pusher/CopyParticleAttribs.H
  5. Update all uses of CopyParticleAttribs in the code base - the ones I see are in Source/Particles/PhotonParticleContainer.cpp and Source/Particles/PhysicalParticleContainer.cpp.

There may some things I'm over looking but I think that's ~90% of the process.

@EZoni
Copy link
Member

EZoni commented Jan 16, 2025

@atmyers

Understood, thanks for the summary!

@EZoni EZoni linked a pull request Jan 17, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleaning Clean code, improve readability
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants