Skip to content
Snippets Groups Projects

Only drift the particles that need drifting

Merged Matthieu Schaller requested to merge kill_drift into master

Here is an algorithmic speed-up. The plan is to drift only the cells that contain an active particles and the cells that have at least one neighbour with an active particle.

  • If this condition is not met then runner_do_drift() just returns without performing any operation.

  • If the condition is met, runner_do_drift() moves all particles (as before) from the last point in time where a drift was performed.

We record for each cell the last time a drift was done such that we now by how much to drift things when needed.

Two exceptions to this rule: before reconstructing and before duping a snapshot, we drift all particles as we need correct position information at these two stages.

Note that I have made this an engine policy to ease the testing. Drifting all particles can be restored by setting the right flag.

@nnrw56 could you check that the function cell_is_drift_needed() makes sense and fully does what it says it does ? Also could you let me know whether you also agree with the whole logic and implementation.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • 643 643 const double timeBase = e->timeBase;
    644 const double dt = (e->ti_current - e->ti_old) * timeBase;
    645 const int ti_old = e->ti_old;
    644 const int ti_old = c->ti_old;
    646 645 const int ti_current = e->ti_current;
    647
    648 646 struct part *const parts = c->parts;
    649 647 struct xpart *const xparts = c->xparts;
    650 648 struct gpart *const gparts = c->gparts;
    651 float dx_max = 0.f, dx2_max = 0.f, h_max = 0.f;
    652 649
    650 /* Do we need to drift ? */
    651 if (!e->drift_all && !cell_is_drift_needed(c, ti_current)) return;
    652
    653 /* Drift from the last time the cell was drifted to the current time */
    654 const double dt = (ti_current - ti_old) * timeBase;
  • Apart from the two comments, this looks good! Also, many thanks for cleaning this up, that's awesome citizenship :)

  • Reassigned to @pdraper

  • 643 643 const double timeBase = e->timeBase;
    644 const double dt = (e->ti_current - e->ti_old) * timeBase;
    645 const int ti_old = e->ti_old;
    644 const int ti_old = c->ti_old;
    646 645 const int ti_current = e->ti_current;
    647
    648 646 struct part *const parts = c->parts;
    649 647 struct xpart *const xparts = c->xparts;
    650 648 struct gpart *const gparts = c->gparts;
    651 float dx_max = 0.f, dx2_max = 0.f, h_max = 0.f;
    652 649
    650 /* Do we need to drift ? */
    651 if (!e->drift_all && !cell_is_drift_needed(c, ti_current)) return;
    652
    653 /* Drift from the last time the cell was drifted to the current time */
    654 const double dt = (ti_current - ti_old) * timeBase;
  • 643 643 const double timeBase = e->timeBase;
    644 const double dt = (e->ti_current - e->ti_old) * timeBase;
    645 const int ti_old = e->ti_old;
    644 const int ti_old = c->ti_old;
    646 645 const int ti_current = e->ti_current;
    647
    648 646 struct part *const parts = c->parts;
    649 647 struct xpart *const xparts = c->xparts;
    650 648 struct gpart *const gparts = c->gparts;
    651 float dx_max = 0.f, dx2_max = 0.f, h_max = 0.f;
    652 649
    650 /* Do we need to drift ? */
    651 if (!e->drift_all && !cell_is_drift_needed(c, ti_current)) return;
    652
    653 /* Drift from the last time the cell was drifted to the current time */
    654 const double dt = (ti_current - ti_old) * timeBase;
  • Added 1 commit:

    • dcb0fd7a - Style change in cell_is_drift_needed() and early abort in the drift when dt==0
  • I have just applied these suggested changes. Let's wait for @pdraper to return next week to make sure I did not miss something here.

  • Added 1 commit:

  • mentioned in commit 49e93734

  • Matthieu Schaller Status changed to merged

    Status changed to merged

  • Please register or sign in to reply
    Loading