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

correctly exclude flux vars from searches by default #1070

Merged
merged 6 commits into from
May 8, 2024

Conversation

Yurlungur
Copy link
Collaborator

@Yurlungur Yurlungur commented May 8, 2024

PR Summary

PR #1043 introduced an unexpected bug/interaction. When searching for vars by flag or by unique ID, it's possible to accidentally include fluxes, since they are now variables. To retain previous behavior, I introduce an enum FluxRequest, which can take on the values Any, NoFlux, or OnlyFlux. If Any is specified, the search does nothing special for fluxes. If NoFlux is specified, flux vars are explicitly excluded. If OnlyFlux is specified, behavior is a little special. Vars that have fluxes are searched for, and then the fluxes of those variables are returned.

I add a test to ensure the unexpected behavior is no longer present and confirmed in riot that the bug is now resolved.

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

@Yurlungur Yurlungur added the bug Something isn't working label May 8, 2024
@Yurlungur Yurlungur self-assigned this May 8, 2024
Comment on lines +162 to +165
[[noreturn]] inline void fail(std::string const &message, const char *const filename,
int const linenumber) {
fail(message.c_str(), filename, linenumber);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This overload was missing for whatever reason. Added it.

@Yurlungur Yurlungur enabled auto-merge May 8, 2024 19:21
Copy link
Collaborator

@bprather bprather left a comment

Choose a reason for hiding this comment

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

Fixes the problem, leaves the option, new tests + docs. LGTM.

@Yurlungur Yurlungur disabled auto-merge May 8, 2024 19:47
@Yurlungur Yurlungur enabled auto-merge May 8, 2024 19:47
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 catch! LGTM

src/interface/meshblock_data.cpp Outdated Show resolved Hide resolved
src/interface/meshblock_data.cpp Outdated Show resolved Hide resolved
src/interface/meshblock_data.cpp Show resolved Hide resolved
src/interface/metadata.hpp Show resolved Hide resolved
@Yurlungur Yurlungur disabled auto-merge May 8, 2024 20:05
@Yurlungur Yurlungur enabled auto-merge May 8, 2024 20:05
-----------------------------------------------------

As discussed above, fluxes are themselves ``Metadata::OneCopy``
variables. A flux variable will have ``Metadata::Flux`` flag
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
variables. A flux variable will have ``Metadata::Flux`` flag
variables. A flux variable will have a ``Metadata::Flux`` flag

the flux variable **associated** with the variable
requested. ``FluxRequest::Any`` does not modify search parameters. You
will get flux or non-flux variables, and variable associations will be
ignored.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we mention how PDOPt::WithFluxes is related here? Typically, if I want the variable and the flux, I would create a SparsePack with PDOPt::WithFluxes. I am sure you have ensured backwards compatibility here, but this documentation led to this confusion for me...

@Yurlungur Yurlungur merged commit c1b4f19 into develop May 8, 2024
49 checks passed
@Yurlungur Yurlungur deleted the jmm/GetVariablesByFlag-flxu-enum branch May 8, 2024 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants