diff --git a/src/drift.h b/src/drift.h index 478971e30a0cbdb633f5a2824820283d84f41824..c01b1a5c6b26761e65d21e8b4f2598386759a02e 100644 --- a/src/drift.h +++ b/src/drift.h @@ -66,6 +66,16 @@ __attribute__((always_inline)) INLINE static void drift_part( struct part *restrict p, struct xpart *restrict xp, float dt, double timeBase, integertime_t ti_old, integertime_t ti_current) { +#ifdef SWIFT_DEBUG_CHECKS + if (p->ti_drift != ti_old) + error( + "Particle has not been drifted to the current time p->ti_drift=%lld, " + "c->ti_old=%lld, ti_current=%lld", + p->ti_drift, ti_old, ti_current); + + p->ti_drift = ti_current; +#endif + /* Drift... */ p->x[0] += xp->v_full[0] * dt; p->x[1] += xp->v_full[1] * dt; diff --git a/src/hydro/Gadget2/hydro_part.h b/src/hydro/Gadget2/hydro_part.h index 8fb4b1d7b7e60ee5fe80b41b150ff872ae433c60..69ae79666e1db4e4f405c653cfc533606989a73a 100644 --- a/src/hydro/Gadget2/hydro_part.h +++ b/src/hydro/Gadget2/hydro_part.h @@ -130,6 +130,16 @@ struct part { /* Time-step length */ timebin_t time_bin; +#ifdef SWIFT_DEBUG_CHECKS + + /* Time of the last drift */ + integertime_t ti_drift; + + /* Time of the last kick */ + integertime_t ti_kick; + +#endif + } SWIFT_STRUCT_ALIGN; #endif /* SWIFT_GADGET2_HYDRO_PART_H */ diff --git a/src/kick.h b/src/kick.h index d532b2a9abb0cc234cd7d55d6636e8dae1b059ab..a679da274186b3ac96fe7ae0e1687511f3f6ed4a 100644 --- a/src/kick.h +++ b/src/kick.h @@ -64,11 +64,21 @@ __attribute__((always_inline)) INLINE static void kick_gpart( */ __attribute__((always_inline)) INLINE static void kick_part( struct part *restrict p, struct xpart *restrict xp, integertime_t ti_start, - integertime_t ti_end, integertime_t ti_current, double timeBase) { + integertime_t ti_end, double timeBase) { /* Time interval for this half-kick */ const float dt = (ti_end - ti_start) * timeBase; +#ifdef SWIFT_DEBUG_CHECKS + if (p->ti_kick != ti_start) + error( + "Particle has not been kicked to the current time p->ti_kick=%lld, " + "ti_start=%lld, ti_end=%lld", + p->ti_kick, ti_start, ti_end); + + p->ti_kick = ti_end; +#endif + /* Get the acceleration */ float a_tot[3] = {p->a_hydro[0], p->a_hydro[1], p->a_hydro[2]}; if (p->gpart != NULL) { diff --git a/src/runner.c b/src/runner.c index 50e72606b4c52a4146f849981d17d7fe47072398..c224fd7cd20ef0a14e791e6b67de7ace82147a8d 100644 --- a/src/runner.c +++ b/src/runner.c @@ -867,8 +867,7 @@ void runner_do_kick1(struct runner *r, struct cell *c, int timer) { get_integer_time_begin(ti_current, p->time_bin); /* do the kick */ - kick_part(p, xp, ti_begin, ti_begin + ti_step / 2, ti_current, - timeBase); + kick_part(p, xp, ti_begin, ti_begin + ti_step / 2, timeBase); } } @@ -944,8 +943,7 @@ void runner_do_kick2(struct runner *r, struct cell *c, int timer) { get_integer_time_begin(ti_current, p->time_bin); /* Finish the time-step with a second half-kick */ - kick_part(p, xp, ti_begin + ti_step / 2, ti_begin + ti_step, ti_current, - timeBase); + kick_part(p, xp, ti_begin + ti_step / 2, ti_begin + ti_step, timeBase); /* Prepare the values to be drifted */ hydro_reset_predicted_values(p, xp); diff --git a/src/space.c b/src/space.c index a0a36da641cac511fe39b7a35af8eeb6b29fc4e7..bca8a1653386ed8c4a51c222d891446237c631c4 100644 --- a/src/space.c +++ b/src/space.c @@ -1770,6 +1770,11 @@ void space_init_parts(struct space *s) { #endif hydro_first_init_part(&p[i], &xp[i]); + +#ifdef SWIFT_DEBUG_CHECKS + p->ti_drift = 0; + p->ti_kick = 0; +#endif } }