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 GetPackDimension to StateDescriptor #1148

Merged
merged 9 commits into from
Aug 14, 2024
Merged

Conversation

bprather
Copy link
Collaborator

@bprather bprather commented Jul 31, 2024

Sometimes when initializing a package, you want to know how many variables another package has declared (e.g., a Flux package might need the total number of WithFluxes variables declared so far). The Mesh doesn't exist yet, so you have to ask the other packages directly, and have them tally up variable lists. Thus, GetPackDimension.

This is the last of the patches I've been carrying in KHARMA's version of Parthenon vs. develop. It works for my purposes downstream, but I'm pretty sure it would fail for Overridable variables and maybe other corner cases. Happy to try to make it more robust if it seems useful, or keep it downstream if no one else needs this kind of info at package init time (or maybe there's some cleaner way to get it? Create a temporary resolved_state or something?)

I've checked and these functions work fine for the StateDescriptor returned by CreateResolvedStateDescriptor, which I think already resolves any Overridable variables down to a single entry each. So, if anyone else needs this sort of crazy thing, the code in here at least has a decent chance of being robust for whatever use case they're throwing at it. Since I think the overall function has a chance of being broadly useful, I'm going to remove WIP, add a changelog entry, and ask for reviews/opinions.

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

Sometimes when initializing a package, you want to know how many
variables another package has declared (e.g., a `Flux` package
might need the total number of `WithFluxes` variables declared
so far).
The `Mesh` doesn't exist yet, so you have to ask the other packages
directly what they've declared.  Thus, `GetPackDimension`.
@bprather bprather changed the title WIP: Add GetPackDimension to StateDescriptor Add GetPackDimension to StateDescriptor Aug 5, 2024
src/interface/state_descriptor.cpp Outdated Show resolved Hide resolved
src/interface/state_descriptor.cpp Outdated Show resolved Hide resolved
@bprather bprather requested a review from Yurlungur August 8, 2024 20:26
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.

Minor comments below.

src/interface/state_descriptor.cpp Outdated Show resolved Hide resolved
src/interface/state_descriptor.cpp Outdated Show resolved Hide resolved
@pgrete pgrete enabled auto-merge (squash) August 14, 2024 13:07
@pgrete pgrete merged commit 9e2c7ea into develop Aug 14, 2024
53 checks passed
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.

3 participants