Commit dcb0fd7a authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Style change in cell_is_drift_needed() and early abort in the drift when dt==0

parent a83354c4
......@@ -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 */
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment