diff --git a/src/cell.c b/src/cell.c index ae79e14009773047e1107d3aa9cfb1b39f9bfd5c..0e5c6672ee06c2d8910b4021e7125de14989ee6c 100644 --- a/src/cell.c +++ b/src/cell.c @@ -906,6 +906,7 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { ; if (l == NULL) error("Missing link to send_xv task."); scheduler_activate(s, l->t); + if(l->t->cj->drift != NULL) scheduler_activate(s, l->t->cj->drift); for (l = cj->send_rho; l != NULL && l->t->cj->nodeID != ci->nodeID; l = l->next) @@ -932,6 +933,7 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { ; if (l == NULL) error("Missing link to send_xv task."); scheduler_activate(s, l->t); + if(l->t->ci->drift != NULL) scheduler_activate(s, l->t->ci->drift); for (l = ci->send_rho; l != NULL && l->t->cj->nodeID != cj->nodeID; l = l->next) @@ -1021,7 +1023,7 @@ void cell_drift(struct cell *c, const struct engine *e) { h_max = max(h_max, cp->h_max); } - } else if (ti_current >= ti_old) { + } else if (ti_current > ti_old) { /* Loop over all the g-particles in the cell */ const size_t nr_gparts = c->gcount; @@ -1051,6 +1053,8 @@ void cell_drift(struct cell *c, const struct engine *e) { /* Drift... */ drift_part(p, xp, dt, timeBase, ti_old, ti_current); + p->ti_old = ti_current; + /* Compute (square of) motion since last cell construction */ const float dx2 = xp->x_diff[0] * xp->x_diff[0] + xp->x_diff[1] * xp->x_diff[1] + diff --git a/src/engine.c b/src/engine.c index 4aa0ddb1b5c3b887cf23357f54c67005d0cadd21..e281d9122782533895706be2499641aca7656ccd 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2066,6 +2066,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, ; if (l == NULL) error("Missing link to send_xv task."); scheduler_activate(s, l->t); + if(l->t->cj->drift) scheduler_activate(s, l->t->cj->drift); for (l = cj->send_rho; l != NULL && l->t->cj->nodeID != ci->nodeID; l = l->next) @@ -2093,6 +2094,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, ; if (l == NULL) error("Missing link to send_xv task."); scheduler_activate(s, l->t); + if(l->t->ci->drift != NULL) scheduler_activate(s, l->t->ci->drift); for (l = ci->send_rho; l != NULL && l->t->cj->nodeID != cj->nodeID; l = l->next) diff --git a/src/hydro/Gadget2/hydro.h b/src/hydro/Gadget2/hydro.h index 157893bc9e27806d2b97ac5f5a81d0f6fbb1c589..66c6998057e0f3bfeab2c1babe53315b61707192 100644 --- a/src/hydro/Gadget2/hydro.h +++ b/src/hydro/Gadget2/hydro.h @@ -212,6 +212,7 @@ __attribute__((always_inline)) INLINE static float hydro_compute_timestep( __attribute__((always_inline)) INLINE static void hydro_first_init_part( struct part *restrict p, struct xpart *restrict xp) { + p->ti_old = 0; p->ti_begin = 0; p->ti_end = 0; xp->v_full[0] = p->v[0]; diff --git a/src/hydro/Gadget2/hydro_part.h b/src/hydro/Gadget2/hydro_part.h index 4bbbf0aede12b692b15442b71a03ffbbcf2f8378..15545f4800342997d77f4ed27b498fbf59364cb1 100644 --- a/src/hydro/Gadget2/hydro_part.h +++ b/src/hydro/Gadget2/hydro_part.h @@ -71,6 +71,8 @@ struct part { /* Particle time of end of time-step. */ int ti_end; + int ti_old; + /* Particle density. */ float rho; diff --git a/src/runner.c b/src/runner.c index 52f91d620ad483ddae366d36e1129efe1f91df9f..6bf9dc4e28a29d729b18147dd48193f0d7d3bba3 100644 --- a/src/runner.c +++ b/src/runner.c @@ -973,6 +973,8 @@ void runner_do_recv_cell(struct runner *r, struct cell *c, int timer) { for (size_t k = 0; k < nr_parts; k++) { const int ti_end = parts[k].ti_end; // if(ti_end < ti_current) error("Received invalid particle !"); + if(parts[k].ti_old != ti_current) error("Received undrifted particles p->ti_old=%d ti_current=%d c->nodeID=%d loc=(%f %f %f) c->drift=%p, c->drift->skip=%d", + parts[k].ti_old, ti_current, c->nodeID, c->loc[0], c->loc[1], c->loc[2], c->drift, c->drift ? c->drift->skip : -1); ti_end_min = min(ti_end_min, ti_end); ti_end_max = max(ti_end_max, ti_end); h_max = max(h_max, parts[k].h); @@ -1007,6 +1009,24 @@ void runner_do_recv_cell(struct runner *r, struct cell *c, int timer) { if (timer) TIMER_TOC(timer_dorecv_cell); } +void runner_check_drift(struct runner *r, struct cell *c) { + + + const struct part *restrict parts = c->parts; + const size_t nr_parts = c->count; + const int ti_current = r->e->ti_current; + + for (size_t k = 0; k < nr_parts; k++) { + + if(parts[k].ti_old != ti_current) { + message("Sending undrifted particles p->ti_old=%d ti_current=%d c->nodeID=%d loc=(%f %f %f) c->drift=%p, c->drift->skip=%d", + parts[k].ti_old, ti_current, c->nodeID, c->loc[0], c->loc[1], c->loc[2], + c->drift, c->drift ? c->drift->skip : -1); + break; + } + } +} + /** * @brief The #runner main thread routine. * @@ -1170,6 +1190,7 @@ void *runner_main(void *data) { break; #ifdef WITH_MPI case task_type_send: + runner_check_drift(r, ci); if (t->subtype == task_subtype_tend) { free(t->buff); }