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

Bugfix to particle defragmentation #1185

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

Conversation

brryan
Copy link
Collaborator

@brryan brryan commented Oct 5, 2024

PR Summary

There was a bug in the defragmentation routine acting on particle lists. The issue was that empty indices weren't being updated after defragmentation. This PR fixes that.

As an aside: this produced the surprising effect that simulation correctness depended on frequency of simulation output, even when no particle fields were being output. This is because particle defragmentation is called during every output cycle. Not saying we can't do this, just mentioning it because it was unexpected. Shouldn't be a correctness issue if defragmentation actually works :)

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

"Set empty indices prefix sum", 0, nmax_pool_ - num_active_ - 1,
KOKKOS_LAMBDA(const int nn, int &update, const bool &final) {
const int n = nn + num_active;
"Set empty indices prefix sum", num_active, nmax_pool_ - 1,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not a change to behavior, this is just clearer IMO

if (final) scan_scratch_toread(n) = update;
if (final) {
scan_scratch_toread(n) = update;
empty_indices(n - num_active) = n;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The bugfix

@@ -62,6 +62,11 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin) {
destroy_particles_frac >= 0. && destroy_particles_frac <= 1.,
"Fraction of particles to destroy each timestep must be between 0 and 1");

Real defrag_threshold = pin->GetOrAddReal("Particles", "defrag_threshold", 0.9);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Useful to be able to control this at runtime.

@brryan brryan requested review from pgrete, Yurlungur and pdmullen and removed request for pgrete October 5, 2024 20:04
Copy link
Collaborator

@pdmullen pdmullen left a comment

Choose a reason for hiding this comment

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

LGTM! The defrag in outputs happens even when particles aren't being dumped, which is also likely undesirable.

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.

2 participants