Improve EMParticleContainer::InitParticles#166
Merged
atmyers merged 3 commits intoAMReX-Codes:mainfrom Nov 6, 2025
Merged
Conversation
atmyers
reviewed
Nov 6, 2025
ExampleCodes/Particles/ElectromagneticPIC/Source/EMParticleContainerInit.cpp
Outdated
Show resolved
Hide resolved
atmyers
approved these changes
Nov 6, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The most significant change this PR makes is that it switches the order in which particles are initialized from
(uix * ny + uiy) * nz + uizto(uiz * ny + uiy) * nx + uix. The new way has uix as the fastest-moving dimension, which is significantly faster in particle-grid operations, especially if num_ppc is 1.The calculation of cellid is then further simplified by using Array4 and removing the index clamping, which is not necessary as the ParallelFor iterates over the same box.
Gpu::exclusive_scan is replaced by Scan::ExclusiveSum so that the return value can be used for num_to_add.
DefineAndReturnParticleTile is used to be more concise and make sure that the tile is defined.
ParticleTileData is used instead of realarray.