Skip to content
Snippets Groups Projects
Commit 36296f3a authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Added infrastructure to check that particles follow the Kick-Drift-Kick scheme correctly

parent 7fb5b96d
No related branches found
No related tags found
1 merge request!301New time line
......@@ -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;
......
......@@ -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 */
......@@ -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) {
......
......@@ -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);
......
......@@ -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
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment