Commit a7485b7b authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

More cleaning-up, documentation and no unwanted changes.

parent b3dbade2
......@@ -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;
......
......@@ -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,
......
......@@ -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];
......
......@@ -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 */
......@@ -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(
......
......@@ -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) &&
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment