diff --git a/src/cell.c b/src/cell.c index e6fa623e0ab57a1d15d639b51791420393000080..f9b6fbedc2b1f464e2e40f0f875db318c087c2d0 100644 --- a/src/cell.c +++ b/src/cell.c @@ -984,6 +984,12 @@ void cell_set_super(struct cell *c, struct cell *super) { if (c->progeny[k] != NULL) cell_set_super(c->progeny[k], super); } +/** + * @brief Recursively drifts all particles and g-particles in a cell hierarchy. + * + * @param c The #cell. + * @param e The #engine (to get ti_current). + */ void cell_drift(struct cell *c, const struct engine *e) { const double timeBase = e->timeBase; diff --git a/src/engine.c b/src/engine.c index 1215e789c236b056605240c9f8f4c3f80b001225..a7f4d7d600f3a269fbe3f37112d474dfb6706931 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2616,9 +2616,8 @@ void engine_step(struct engine *e) { if (e->nodeID == 0) { /* Print some information to the screen */ - printf(" %6d %14e %d %14e %10zu %10zu %21.3f\n", e->step, e->time, - e->ti_current, e->timeStep, e->updates, e->g_updates, - e->wallclock_time); + printf(" %6d %14e %14e %10zu %10zu %21.3f\n", e->step, e->time, + e->timeStep, e->updates, e->g_updates, e->wallclock_time); fflush(stdout); fprintf(e->file_timesteps, " %6d %14e %14e %10zu %10zu %21.3f\n", e->step, diff --git a/src/hydro/Gadget2/hydro.h b/src/hydro/Gadget2/hydro.h index c681db18a7b2d4fdafe7e46c784450b5ce256eca..157893bc9e27806d2b97ac5f5a81d0f6fbb1c589 100644 --- a/src/hydro/Gadget2/hydro.h +++ b/src/hydro/Gadget2/hydro.h @@ -212,7 +212,6 @@ __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 61158a71d518d7843dd6ea04e21385b1f3d2dc29..4bbbf0aede12b692b15442b71a03ffbbcf2f8378 100644 --- a/src/hydro/Gadget2/hydro_part.h +++ b/src/hydro/Gadget2/hydro_part.h @@ -50,12 +50,6 @@ struct xpart { /* Data of a single particle. */ struct part { - /* Particle ID. */ - long long id; - - /* Pointer to corresponding gravity part. */ - struct gpart* gpart; - /* Particle position. */ double x[3]; @@ -77,8 +71,6 @@ struct part { /* Particle time of end of time-step. */ int ti_end; - // int ti_old; - /* Particle density. */ float rho; @@ -132,6 +124,12 @@ struct part { } force; }; + /* Particle ID. */ + long long id; + + /* Pointer to corresponding gravity part. */ + struct gpart* gpart; + } SWIFT_STRUCT_ALIGN; #endif /* SWIFT_GADGET2_HYDRO_PART_H */ diff --git a/src/runner.c b/src/runner.c index 3865b1b2ae3035b3aceb51df0eb54a70678a77b0..11e66b0e6bfb14b07a8247cfec07e5ed4783a5e4 100644 --- a/src/runner.c +++ b/src/runner.c @@ -744,15 +744,12 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) { } /** - * @brief Drift particles and g-particles in a cell forward in time, - * unskipping any tasks associated with active cells. + * @brief Unskip any tasks associated with active cells. * * @param c The cell. * @param e The engine. - * @param drift whether to actually drift the particles, will not be - * necessary for non-local cells. */ -static void runner_do_unskip(struct cell *c, struct engine *e, int drift) { +static void runner_do_unskip(struct cell *c, struct engine *e) { /* Unskip any active tasks. */ if (cell_is_active(c, e)) { @@ -765,14 +762,14 @@ static void runner_do_unskip(struct cell *c, struct engine *e, int drift) { for (int k = 0; k < 8; k++) { if (c->progeny[k] != NULL) { struct cell *cp = c->progeny[k]; - runner_do_unskip(cp, e, 0); + runner_do_unskip(cp, e); } } } } /** - * @brief Mapper function to drift particles and g-particles forward in time. + * @brief Mapper function to unskip active tasks. * * @param map_data An array of #cell%s. * @param num_elements Chunk size. @@ -787,18 +784,35 @@ void runner_do_unskip_mapper(void *map_data, int num_elements, for (int ind = 0; ind < num_elements; ind++) { struct cell *c = &cells[ind]; #ifdef WITH_MPI - if (c != NULL) runner_do_unskip(c, e, (c->nodeID == e->nodeID)); + if (c != NULL) runner_do_unskip(c, e); #else - if (c != NULL) runner_do_unskip(c, e, 0); + if (c != NULL) runner_do_unskip(c, e); #endif } } - +/** + * @brief Drift particles in real space. + * + * @param r The runner thread. + * @param c The cell. + * @param timer Are we timing this ? + */ void runner_do_drift(struct runner *r, struct cell *c, int timer) { + TIMER_TIC; + cell_drift(c, r->e); + + if (timer) TIMER_TOC(timer_drift); } +/** + * @brief Mapper function to drift ALL particle and g-particles forward in time. + * + * @param map_data An array of #cell%s. + * @param num_elements Chunk size. + * @param extra_data Pointer to an #engine. + */ void runner_do_drift_mapper(void *map_data, int num_elements, void *extra_data) { @@ -812,8 +826,7 @@ void runner_do_drift_mapper(void *map_data, int num_elements, } /** - * @brief Kick particles in momentum space and collect statistics (floating - * time-step case) + * @brief Kick particles in momentum space and collect statistics. * * @param r The runner thread. * @param c The cell. @@ -1043,8 +1056,7 @@ void *runner_main(void *data) { /* Check that we haven't scheduled an inactive task */ #ifdef SWIFT_DEBUG_CHECKS if (cj == NULL) { /* self */ - if (!cell_is_active(ci, e) && t->type != task_type_sort && - t->type != task_type_drift) + if (!cell_is_active(ci, e) && t->type != task_type_sort) error( "Task (type='%s/%s') should have been skipped ti_current=%d " "c->ti_end_min=%d", @@ -1060,11 +1072,6 @@ void *runner_main(void *data) { taskID_names[t->type], subtaskID_names[t->subtype], e->ti_current, ci->ti_end_min, t->flags); - /* Special treatement for drifts */ - if (!cell_is_active(ci, e) && t->type == task_type_drift) { - ; - } - } else { /* pair */ if (!cell_is_active(ci, e) && !cell_is_active(cj, e)) error( diff --git a/src/scheduler.c b/src/scheduler.c index 82ea453b6369259b077eddd31db1d00acf7da37f..df50f8525529d734abde5128ef75bef955d73f55 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -584,7 +584,6 @@ static void scheduler_splittask(struct task *t, struct scheduler *s) { } /* Otherwise, break it up if it is too large? */ - } else if (scheduler_doforcesplit && ci->split && cj->split && (ci->count > space_maxsize / cj->count)) { @@ -605,8 +604,7 @@ static void scheduler_splittask(struct task *t, struct scheduler *s) { tl->flags = space_getsid(s->space, &t->ci, &t->cj, shift); } - /* Otherwise, if not spilt, stitch-up the sorting and drift. */ - + /* Otherwise, if not spilt, stitch-up the sorting. */ } else { /* Create the sort for ci. */ @@ -617,7 +615,6 @@ static void scheduler_splittask(struct task *t, struct scheduler *s) { else ci->sorts->flags |= (1 << sid); lock_unlock_blind(&ci->lock); - scheduler_addunlock(s, ci->sorts, t); /* Create the sort for cj. */ @@ -628,7 +625,6 @@ static void scheduler_splittask(struct task *t, struct scheduler *s) { else cj->sorts->flags |= (1 << sid); lock_unlock_blind(&cj->lock); - scheduler_addunlock(s, cj->sorts, t); } @@ -1073,7 +1069,7 @@ void scheduler_start(struct scheduler *s) { if (cj == NULL) { /* self */ if (ci->ti_end_min == ti_current && t->skip && - t->type != task_type_sort && t->type != task_type_drift) + t->type != task_type_sort && t->type) error( "Task (type='%s/%s') should not have been skipped ti_current=%d " "c->ti_end_min=%d", @@ -1089,12 +1085,6 @@ void scheduler_start(struct scheduler *s) { taskID_names[t->type], subtaskID_names[t->subtype], ti_current, ci->ti_end_min, t->flags); - /* Special treatement for drifts */ - if (ci->ti_end_min == ti_current && t->skip && - t->type == task_type_drift) { - ; - } - } else { /* pair */ if ((ci->ti_end_min == ti_current || cj->ti_end_min == ti_current) &&