Only drift the particles that need drifting
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
Activity
Added 7 commits:
-
de493833...c6a1f5a2 - 4 commits from branch
master
- 12e4a201 - Merge branch 'master' into kill_drift
- edaa3ba1 - Define a constant for the cell memory allocation alignment.
- a83354c4 - Merge branch 'master' into kill_drift
Toggle commit list-
de493833...c6a1f5a2 - 4 commits from branch
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; 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:
- 5c4963fc - Suppress a GCC warning
mentioned in commit 49e93734