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

Draft: Multiple types/packs for multiple types #742

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

brryan
Copy link
Collaborator

@brryan brryan commented Oct 5, 2022

PR Summary

We would like:

  • Packing for particle variables (which can be both Real and int types)
  • Support for arbitrary types for parthenon cell variables.

This PR attempts to implement this by

  • Templating SparsePacks on a datatype
  • Replacing varVector_ and varMap_ of CellVariable in Mesh*Data with a Params-like type-erased container that can return a vector of all CellVariables of a particular type
  • ~ ] Replace Add for CellVariables with a function templated on datatype (maybe defaulting to Real)
  • Modify SparsePack to also support packing ParticleVariables of a particular Swarm
  • Resolve buffer packing of different-sized types

Allowing arbitrary types in CellVariables has some potential complications that we may want to just deliberately avoid at least for now. For example how does one prolongate/restrict a cell-centered enum? If non-Real CellVariables are enrolled do we just require for now that they not have FillGhost? It might also be possible to allow/require developers to enroll their own prolongation/restriction operators for non-Real (or also Real?) types.

There also needs to be some rule for packing non-Real-sized data into buffers. The easiest thing (that particles already do in a similar context) is to assume other types are the same size as or smaller than Real and then just use casts going in and out of the buffer.

If the custom types framework were sufficiently flexible one could use vector types to have a fastest moving index other than i as @forrestglines pointed out the other day.

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
  • CI has been triggered on Darwin for performance regression tests.
  • (@lanl.gov employees) Update copyright on changed files

@brryan brryan requested a review from lroberts36 October 5, 2022 21:31
@@ -128,10 +128,10 @@ TEST_CASE("Test behavior of sparse packs", "[SparsePack]") {
"blocks") {
// Create a pack use type variables
auto sparse_pack =
parthenon::SparsePack<v5, v3>::Get(&mesh_data, {Metadata::WithFluxes});
parthenon::SparsePack<v5, v3>::Get<MeshData<Real>, Real>(&mesh_data, {Metadata::WithFluxes});
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It would be great to not have to be explicit about MeshData<Real> in the template parameter list here but I couldn't immediately figure out how to do it.

@brryan brryan changed the title Multiple types/packs for multiple types Draft: Multiple types/packs for multiple types Oct 7, 2022
@pdmullen pdmullen mentioned this pull request Mar 27, 2024
13 tasks
@pdmullen
Copy link
Collaborator

@brryan Can we close this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants