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

Add SwarmPacks #1037

Merged
merged 49 commits into from
May 10, 2024
Merged

Add SwarmPacks #1037

merged 49 commits into from
May 10, 2024

Conversation

pdmullen
Copy link
Collaborator

@pdmullen pdmullen commented Mar 27, 2024

This MR introduces the notion of a SwarmPack. It is a stripped down version of SparsePack, tuned towards particle swarms, to enable packing over MeshBlocks. I have preliminarily settled on a design wherein one can pack a SwarmPack via a std::vector<std::string> or the type-based variable prescription previously used in SparsePacks. SwarmPacks are unique from SparsePacks in that we must be able to handle both Real and integer types. In this MR, I do not allow SwarmPacks to contain mixed types, however, one can create a pack of Real swarm variables and a separate pack for int swarm variables. The design follows:

by std::vector<std::string> (where the template argument specifies that the data type):

std::vector<std::string> vars{swarm_position::x::name(),
                              swarm_position::y::name(),
                              swarm_position::z::name()};
static auto desc = MakeSwarmPackDescriptor<Real>(swarm_name, vars);
auto pack = desc.GetPack(md);

by type-based vars (where the data type is inferred from var-types):

static auto desc = MakeSwarmPackDescriptor<swarm_position::x,
                                           swarm_position::y,
                                           swarm_position::z>(swarm_name);
auto pack = desc.GetPack(md);

There are so many opportunities to further clean up things here... One could imagine (1) allowing mixed types in packs, (2) allowing for packing via Metadata or regex, or (4) combining SparsePacks and SwarmPacks, to name a few.

This MR adds the SwarmPack machinery to the particle_leapfrog test.

Finally, I'd note that this MR also transitions swarm_data to belong to meshblock_data rather than pmb. This likely has consequence when considering copies of mesh_data registers (e.g., in RK staging). Any undesired manifestations from this change should be uncovered as we continue to test downstream. For one, the current design requires that downstream users interface with particles via the base mesh_data register.

PR Checklist

  • Code passes cpplint
  • New features are documented.
  • Adds a test for any bugs fixed. Adds tests for new features.
  • Code is formatted
  • Changes are summarized in CHANGELOG.md
  • Change is breaking (API, behavior, ...)
    • Change is additionally added to CHANGELOG.md in the breaking section
    • PR is marked as breaking
    • Short summary API changes at the top of the PR (plus optionally with an automated update/fix script)
  • CI has been triggered on Darwin for performance regression tests.
  • Docs build
  • (@lanl.gov employees) Update copyright on changed files
  • Include caching for SwarmPacks (cache cleared whenever Swarm::setPoolMax is called)

@pdmullen pdmullen changed the title Add SwarmPacks WIP: Add SwarmPacks Mar 27, 2024
Copy link
Collaborator

@Yurlungur Yurlungur left a comment

Choose a reason for hiding this comment

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

I am super happy to see this be added! Worth noting it does break downstream because you moved where swarms live to be in meshblock data (which is where they belong). Comments below.

src/interface/make_swarm_pack_descriptor.hpp Show resolved Hide resolved
src/interface/mesh_data.hpp Show resolved Hide resolved
src/interface/meshblock_data.hpp Outdated Show resolved Hide resolved
src/interface/swarm_pack.hpp Outdated Show resolved Hide resolved
src/interface/swarm_pack_base.hpp Show resolved Hide resolved
src/interface/swarm_pack_base.hpp Outdated Show resolved Hide resolved
src/interface/swarm_pack_base.hpp Outdated Show resolved Hide resolved
src/interface/swarm_variable_types.hpp Outdated Show resolved Hide resolved
src/outputs/parthenon_xdmf.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@brryan brryan left a comment

Choose a reason for hiding this comment

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

After a brief first read, this looks great to me so far.

src/interface/meshblock_data.cpp Show resolved Hide resolved
src/interface/meshblock_data.hpp Outdated Show resolved Hide resolved
src/interface/swarm_pack.hpp Show resolved Hide resolved
src/outputs/output_utils.cpp Outdated Show resolved Hide resolved
@pdmullen pdmullen changed the title WIP: Add SwarmPacks Add SwarmPacks May 8, 2024
Copy link
Collaborator

@lroberts36 lroberts36 left a comment

Choose a reason for hiding this comment

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

Nice, this LGTM. Some small non-blocking questions/comments below.

src/interface/meshblock_data.cpp Show resolved Hide resolved
src/interface/pack_utils.hpp Show resolved Hide resolved
src/interface/swarm.cpp Outdated Show resolved Hide resolved
src/interface/swarm_pack.hpp Show resolved Hide resolved
src/interface/swarm_pack_base.hpp Outdated Show resolved Hide resolved
src/interface/swarm_pack_base.hpp Show resolved Hide resolved
Copy link
Collaborator

@Yurlungur Yurlungur left a comment

Choose a reason for hiding this comment

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

I still have some minor nitpicks but nothing I would call blocking. Thanks for this cleanup @pdmullen it's really great to have swarm packs.

src/interface/meshblock_data.hpp Outdated Show resolved Hide resolved
src/interface/meshblock_data.cpp Show resolved Hide resolved
src/interface/pack_utils.hpp Show resolved Hide resolved
src/interface/pack_utils.hpp Show resolved Hide resolved
src/interface/swarm_pack_base.hpp Show resolved Hide resolved
src/interface/swarm_pack_base.hpp Show resolved Hide resolved
src/interface/swarm_pack_base.hpp Outdated Show resolved Hide resolved
src/interface/swarm_pack_base.hpp Outdated Show resolved Hide resolved
src/kokkos_abstraction.hpp Show resolved Hide resolved
@pgrete
Copy link
Collaborator

pgrete commented May 9, 2024

FYI I'm happy with the discussion and don't plan a detailed review. So just go ahead an merge when everyone is happy.

@brryan brryan enabled auto-merge (squash) May 9, 2024 20:44
@pdmullen pdmullen disabled auto-merge May 10, 2024 00:37
@pdmullen pdmullen enabled auto-merge May 10, 2024 00:37
@pdmullen pdmullen merged commit b1b61cd into develop May 10, 2024
49 checks passed
@pdmullen pdmullen deleted the pdmullen/swarm-pack branch May 10, 2024 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants