Skip to content

Do not call BC on coarse buffer if there are no neighbors to fill it#1365

Merged
lroberts36 merged 14 commits intodevelopfrom
dempsey/bvals
Feb 25, 2026
Merged

Do not call BC on coarse buffer if there are no neighbors to fill it#1365
lroberts36 merged 14 commits intodevelopfrom
dempsey/bvals

Conversation

@adamdempsey90
Copy link
Collaborator

PR Summary

Ran into this issue in Artemis when calling one of our BCs with the coarse flag set to true in a situation where there was no neighbor at a coarser level. In that scenario, the coarse buffer was filled entirely with zeros since there was no one to fill it. Our EOS caught it since we were then passing in hard 0 density and energy values.

This adds a check for coarser neighbors before calling the BCs on the coarse buffer.

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
Copy link
Collaborator

Won't the coarse buffer always be filled with zeros in this case since kokkos views are zero-initialized? What should it be filled with? Or is the issue that your EOS calls happen inside the boundary call?

@adamdempsey90
Copy link
Collaborator Author

Won't the coarse buffer always be filled with zeros in this case since kokkos views are zero-initialized? What should it be filled with? Or is the issue that your EOS calls happen inside the boundary call?

Yeah, the coarse buffer will still be filled with zeros but we will not call the actual boundary kernel that uses it, so it doesn't matter. The BC in question was an extrapolation BC that needed to do an EOS call to set sie from the extrapolated rho and T.

@Yurlungur
Copy link
Collaborator

@lroberts36 to add additional review

@lroberts36 lroberts36 mentioned this pull request Feb 24, 2026
12 tasks
Comment on lines 44 to 57
// We only need to call the BC on the coarse buffer if one of the neighbors
// is at a coarser level than us.
if (coarse) {
bool has_coarser_neighbor = false;
const int mylevel = pmb->loc.level();
for (const auto &nb : pmb->neighbors) {
if (nb.origin_loc.level() < mylevel) {
has_coarser_neighbor = true;
break;
}
}
if (!has_coarser_neighbor) return TaskStatus::complete;
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

@adamdempsey90: This is definitely correct. Nevertheless, I would suggest we add this logic to MeshBlock rather than adding it here and just call pmb->HasCoarserNeighbor(); here. I put up another PR based on this one (#1367) that adds a function MeshBlock::HasCoarserNeighbor(), sets the return value of that once during neighbor finding, and calls that function here and another place we do a similar check. I also refactored how we access neighbors in MeshBlock there, it is really not directly related to this change but this was a good place to make the access patterns a little safer. Please take a look and let me know or just merge that PR into this one. I will approve this PR after that is in (or if we decide not to include it).

@lroberts36 lroberts36 self-requested a review February 24, 2026 22:42
@lroberts36 lroberts36 enabled auto-merge February 24, 2026 22:43
@lroberts36 lroberts36 disabled auto-merge February 25, 2026 21:19
@lroberts36 lroberts36 enabled auto-merge February 25, 2026 21:19
@lroberts36 lroberts36 merged commit c193aca into develop Feb 25, 2026
38 checks passed
@lroberts36 lroberts36 deleted the dempsey/bvals branch February 25, 2026 23:51
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