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

WIP: Store pmb->gid in VariableState #1010

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

Conversation

pdmullen
Copy link
Collaborator

@pdmullen pdmullen commented Feb 29, 2024

PR Summary

In addition to sparse_id, it would be also nice to be able to access the current block gid in a SparsePack via

pack(b, var()).gid

This utility is added in this MR, by adding gid to VariableState.

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

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.

This is a nice solution... Better than putting it directly into the pack. 👍

@pdmullen
Copy link
Collaborator Author

This is a nice solution... Better than putting it directly into the pack. 👍

Credit to @lroberts36

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.

See my comment below.

Comment on lines +42 to +43
pmb_gid_ = wpmb.lock().get()->gid;

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is possible that after a re-mesh when amr is turned on a block can have its gid changed. I don't think there is any mechanism to propagate this through to the variables, so I think that the VariableState could end up with a stale gid in this case.

The two possible solutions I think of. First, maybe adding a method to MeshBlock called UpdateGid(int gid) which updates the block gid and the VariableState of all variables (but I guess this depends on iterating through all of the containers). This method would need to be called in amr_loadbalance.cpp instead of just setting the block gids by hand. The other possibility is to just make sure that the values are updated during sparse packing, which is a little less clean I think but probably easier to implement.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just double checking: are our gids always guaranteed to be contiguous (starting from 0)?
We have some code paths that implicitly assume that there's always a block with gid 0.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, gids are defined to always start at zero and be contiguous (i.e. they are just the indices of all the blocks in a std::vector that has been sorted by the Morton number of the blocks' logical locations). The issue is that after remeshing, the Morton number of a block that hasn't been refined or derefined doesn't change but it's gid can change since blocks with lower Morton numbers may have been added/removed from the grid.

@pdmullen pdmullen changed the title Store pmb->gid in VariableState WIP: Store pmb->gid in VariableState Mar 14, 2024
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

4 participants