diff --git a/src/cell.c b/src/cell.c index 094645ba50e35cd06e3a3f0c333741cb34d4858d..dfbfe5fc003ee6a6a55bb3ac5a57642841e388c6 100644 --- a/src/cell.c +++ b/src/cell.c @@ -829,12 +829,10 @@ int cell_is_drift_needed(struct cell *c, int ti_current) { if (l->t->type != task_type_pair && l->t->type != task_type_sub_pair) continue; - /* Left or right? */ - if (l->t->ci == c) { - if (l->t->cj->ti_end_min == ti_current) return 1; - } else if (l->t->cj == c) { - if (l->t->ci->ti_end_min == ti_current) return 1; - } + /* Does the other cell in the pair have an active particle ? */ + if ((l->t->ci == c) && (l->t->cj->ti_end_min == ti_current) || + (l->t->cj == c) && (l->t->ci->ti_end_min == ti_current)) + return 1; } /* No neighbouring cell has active particles. Drift not necessary */ diff --git a/src/runner.c b/src/runner.c index 57a6b9de7017ccb953eaaf05d9880cc440bdd974..87de99ba7255b89495149566069bcc0cb3c638b4 100644 --- a/src/runner.c +++ b/src/runner.c @@ -650,6 +650,9 @@ static void runner_do_drift(struct cell *c, struct engine *e) { /* Do we need to drift ? */ if (!e->drift_all && !cell_is_drift_needed(c, ti_current)) return; + /* Check that we are actually going to move forward. */ + if (ti_current == ti_old) return; + /* Drift from the last time the cell was drifted to the current time */ const double dt = (ti_current - ti_old) * timeBase;