diff --git a/src/cell.c b/src/cell.c index 1d580b929b6c42b1d8bc4e264d48941ce83f9ea1..eb46f880459d1a1e08b6401708af2c4ba2d012a2 100644 --- a/src/cell.c +++ b/src/cell.c @@ -715,7 +715,7 @@ void cell_clean_links(struct cell *c, void *data) { */ void cell_check_drift_point(struct cell *c, void *data) { - integertime_t ti_current = *(int *)data; + integertime_t ti_current = *(integertime_t *)data; if (c->ti_old != ti_current && c->nodeID == engine_rank) error("Cell in an incorrect time-zone! c->ti_old=%lld ti_current=%lld", diff --git a/src/const.h b/src/const.h index c290a3e73a524e9003cadb63f8bd45e8b3c51dac..f0ee6318064403d742c1ec4f7cf6a770b567238a 100644 --- a/src/const.h +++ b/src/const.h @@ -59,4 +59,6 @@ #define SOURCETERMS_NONE //#define SOURCETERMS_SN_FEEDBACK +#define ICHECK 116650 + #endif /* SWIFT_CONST_H */ diff --git a/src/drift.h b/src/drift.h index bd1b35926740d49a67291ede4676f3387cd66748..478971e30a0cbdb633f5a2824820283d84f41824 100644 --- a/src/drift.h +++ b/src/drift.h @@ -39,8 +39,8 @@ * @param ti_current Integer end of time-step */ __attribute__((always_inline)) INLINE static void drift_gpart( - struct gpart *restrict gp, float dt, double timeBase, int ti_old, - int ti_current) { + struct gpart *restrict gp, float dt, double timeBase, integertime_t ti_old, + integertime_t ti_current) { /* Drift... */ gp->x[0] += gp->v_full[0] * dt; gp->x[1] += gp->v_full[1] * dt; @@ -64,7 +64,7 @@ __attribute__((always_inline)) INLINE static void drift_gpart( */ __attribute__((always_inline)) INLINE static void drift_part( struct part *restrict p, struct xpart *restrict xp, float dt, - double timeBase, int ti_old, int ti_current) { + double timeBase, integertime_t ti_old, integertime_t ti_current) { /* Drift... */ p->x[0] += xp->v_full[0] * dt; diff --git a/src/engine.c b/src/engine.c index fd641996fff30b0adc2392b8d45277ef340998e2..60630ec72bbff2057458014a726d3bcfbb115505 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2683,9 +2683,14 @@ void engine_step(struct engine *e) { engine_launch(e, e->nr_threads); TIMER_TOC(timer_runners); +#ifdef SWIFT_DEBUG_CHECKS for (size_t i = 0; i < e->s->nr_parts; ++i) { if (e->s->parts[i].time_bin == 0) error("Particle in bin 0"); } +#endif + + /* if(e->step > 2) */ + /* error("Done"); */ /* Save some statistics */ if (e->time - e->timeLastStatistics >= e->deltaTimeStatistics) { diff --git a/src/runner.c b/src/runner.c index 13705452de9fe8f74c71db9c4fb68d57a9374386..c457f495fe2480ecf0dcfbacf2dfaa4cd28a86cc 100644 --- a/src/runner.c +++ b/src/runner.c @@ -113,9 +113,6 @@ const char runner_flip[27] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, #include "runner_doiact_fft.h" #include "runner_doiact_grav.h" -#undef ICHECK -#define ICHECK 116650 - /** * @brief Perform source terms * @@ -972,8 +969,6 @@ void runner_do_kick(struct runner *r, struct cell *c, int timer) { if (timer) TIMER_TOC(timer_kick); } -#ifdef WITH_MPI - /** * @brief Construct the cell properties from the received particles * @@ -1036,8 +1031,6 @@ void runner_do_recv_cell(struct runner *r, struct cell *c, int timer) { if (timer) TIMER_TOC(timer_dorecv_cell); } -#endif /* WITH_MPI */ - /** * @brief The #runner main thread routine. * diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h index 59a5ae496680390c23458bde65b4bba321ffe7a1..9d2606ceb06fd6d32592010376e867a6ae582bf0 100644 --- a/src/runner_doiact_grav.h +++ b/src/runner_doiact_grav.h @@ -25,8 +25,6 @@ #include "gravity.h" #include "part.h" -#define ICHECK -1000 - /** * @brief Compute the recursive upward sweep, i.e. construct the * multipoles in a cell hierarchy. diff --git a/src/space.c b/src/space.c index 58c628c725652556660de1192a7b701044f3d795..86611d3816dc41f3129934c9ee92fc9889a3c5ac 100644 --- a/src/space.c +++ b/src/space.c @@ -1988,7 +1988,7 @@ void space_link_cleanup(struct space *s) { * @param s The #space to check. * @param ti_current The (integer) time. */ -void space_check_drift_point(struct space *s, int ti_current) { +void space_check_drift_point(struct space *s, integertime_t ti_current) { /* Recursively check all cells */ space_map_cells_pre(s, 1, cell_check_drift_point, &ti_current); diff --git a/src/space.h b/src/space.h index 4aea2a07560865c8d8a474f069b370748e12e65e..51a4f2a0d86a50c65a6cf8c211f35580561823e6 100644 --- a/src/space.h +++ b/src/space.h @@ -185,7 +185,7 @@ void space_do_gparts_sort(); void space_init_parts(struct space *s); void space_init_gparts(struct space *s); void space_link_cleanup(struct space *s); -void space_check_drift_point(struct space *s, int ti_current); +void space_check_drift_point(struct space *s, integertime_t ti_current); void space_clean(struct space *s); #endif /* SWIFT_SPACE_H */ diff --git a/src/timeline.h b/src/timeline.h index 3ee8a137908fbf23f480efeba1b42a3ad812489b..d9691ef846a70e7886c545055a790f8e3aa3c9d9 100644 --- a/src/timeline.h +++ b/src/timeline.h @@ -101,7 +101,7 @@ static INLINE integertime_t get_integer_time_end(integertime_t ti_current, if (dti == 0) return 0; else - return dti * ceil((double)ti_current / (double)dti); + return dti * ceill((double)ti_current / (double)dti); } /** diff --git a/src/timestep.h b/src/timestep.h index d9778439a978ff8b05477683c6139653184e540f..c7529bd042eaa20814c14c5f570532026ebdb27b 100644 --- a/src/timestep.h +++ b/src/timestep.h @@ -35,30 +35,40 @@ * @param ti_current The current time on the integer time-line. * @param timeBase_inv The inverse of the system's minimal time-step. */ -__attribute__((always_inline)) INLINE static int make_integer_timestep( - float new_dt, timebin_t old_bin, integertime_t ti_current, - double timeBase_inv) { +__attribute__((always_inline)) INLINE static integertime_t +make_integer_timestep(float new_dt, timebin_t old_bin, integertime_t ti_current, + double timeBase_inv, int verbose) { /* Convert to integer time */ integertime_t new_dti = (integertime_t)(new_dt * timeBase_inv); + if (verbose) message("new_dti=%lld", new_dti); + /* Current time-step */ integertime_t current_dti = get_integer_timestep(old_bin); integertime_t ti_end = get_integer_time_end(ti_current, old_bin); + if (verbose) + message("current_dti=%lld old_bin=%d ti_end=%lld", current_dti, old_bin, + ti_end); + /* Limit timestep increase */ if (old_bin > 0) new_dti = min(new_dti, 2 * current_dti); /* Put this timestep on the time line */ integertime_t dti_timeline = max_nr_timesteps; - while (new_dti < dti_timeline) dti_timeline /= 2; + while (new_dti < dti_timeline) dti_timeline /= 2LL; new_dti = dti_timeline; + if (verbose) message("new_dti=%lld", new_dti); + /* Make sure we are allowed to increase the timestep size */ if (new_dti > current_dti) { if ((max_nr_timesteps - ti_end) % new_dti > 0) new_dti = current_dti; } + if (verbose) message("new_dti=%lld", new_dti); + return new_dti; } @@ -68,7 +78,7 @@ __attribute__((always_inline)) INLINE static int make_integer_timestep( * @param gp The #gpart. * @param e The #engine (used to get some constants). */ -__attribute__((always_inline)) INLINE static int get_gpart_timestep( +__attribute__((always_inline)) INLINE static integertime_t get_gpart_timestep( const struct gpart *restrict gp, const struct engine *restrict e) { const float new_dt_external = external_gravity_timestep( @@ -86,7 +96,7 @@ __attribute__((always_inline)) INLINE static int get_gpart_timestep( /* Convert to integer time */ const integertime_t new_dti = make_integer_timestep( - new_dt, gp->time_bin, e->ti_current, e->timeBase_inv); + new_dt, gp->time_bin, e->ti_current, e->timeBase_inv, 0); return new_dti; } @@ -98,7 +108,7 @@ __attribute__((always_inline)) INLINE static int get_gpart_timestep( * @param xp The #xpart partner of p. * @param e The #engine (used to get some constants). */ -__attribute__((always_inline)) INLINE static int get_part_timestep( +__attribute__((always_inline)) INLINE static integertime_t get_part_timestep( const struct part *restrict p, const struct xpart *restrict xp, const struct engine *restrict e) { @@ -140,9 +150,13 @@ __attribute__((always_inline)) INLINE static int get_part_timestep( new_dt = min(new_dt, e->dt_max); new_dt = max(new_dt, e->dt_min); + if (p->id == ICHECK) message("new_dt=%e", new_dt); + /* Convert to integer time */ const integertime_t new_dti = make_integer_timestep( - new_dt, p->time_bin, e->ti_current, e->timeBase_inv); + new_dt, p->time_bin, e->ti_current, e->timeBase_inv, p->id == ICHECK); + + if (p->id == ICHECK) message("new_dti=%lld", new_dti); return new_dti; }