Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
1 merge request!225Only drift the particles that need drifting
...@@ -829,12 +829,10 @@ int cell_is_drift_needed(struct cell *c, int ti_current) { ...@@ -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) if (l->t->type != task_type_pair && l->t->type != task_type_sub_pair)
continue; continue;
/* Left or right? */ /* Does the other cell in the pair have an active particle ? */
if (l->t->ci == c) { if ((l->t->ci == c) && (l->t->cj->ti_end_min == ti_current) ||
if (l->t->cj->ti_end_min == ti_current) return 1; (l->t->cj == c) && (l->t->ci->ti_end_min == ti_current))
} else if (l->t->cj == c) { return 1;
if (l->t->ci->ti_end_min == ti_current) return 1;
}
} }
/* No neighbouring cell has active particles. Drift not necessary */ /* No neighbouring cell has active particles. Drift not necessary */
......
...@@ -650,6 +650,9 @@ static void runner_do_drift(struct cell *c, struct engine *e) { ...@@ -650,6 +650,9 @@ static void runner_do_drift(struct cell *c, struct engine *e) {
/* Do we need to drift ? */ /* Do we need to drift ? */
if (!e->drift_all && !cell_is_drift_needed(c, ti_current)) return; 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 */ /* Drift from the last time the cell was drifted to the current time */
const double dt = (ti_current - ti_old) * timeBase; const double dt = (ti_current - ti_old) * timeBase;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment