Skip to content
Snippets Groups Projects
Commit 4d965cd1 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Add engine_drift() function so that we can time drifts

parent cc6a8d95
Branches
Tags
1 merge request!241Drift all particles before repartitioning
......@@ -2282,8 +2282,7 @@ void engine_prepare(struct engine *e, int nodrift) {
/* Drift all particles to the current time if needed. */
if (!nodrift) {
e->drift_all = 1;
threadpool_map(&e->threadpool, runner_do_drift_mapper, e->s->cells_top,
e->s->nr_cells, sizeof(struct cell), 1, e);
engine_drift(e);
/* Restore the default drifting policy */
e->drift_all = (e->policy & engine_policy_drift_all);
......@@ -2670,8 +2669,7 @@ void engine_step(struct engine *e) {
/* Drift everybody to the snapshot position */
e->drift_all = 1;
threadpool_map(&e->threadpool, runner_do_drift_mapper, e->s->cells_top,
e->s->nr_cells, sizeof(struct cell), 1, e);
engine_drift(e);
/* Restore the default drifting policy */
e->drift_all = (e->policy & engine_policy_drift_all);
......@@ -2713,8 +2711,7 @@ void engine_step(struct engine *e) {
* if we are about to repartition. */
int repart = (e->forcerepart != REPART_NONE);
e->drift_all = repart || e->drift_all;
threadpool_map(&e->threadpool, runner_do_drift_mapper, e->s->cells_top,
e->s->nr_cells, sizeof(struct cell), 1, e);
engine_drift(e);
/* Re-distribute the particles amongst the nodes? */
if (repart) engine_repartition(e);
......@@ -2805,6 +2802,21 @@ int engine_is_done(struct engine *e) {
return !(e->ti_current < max_nr_timesteps);
}
/**
* @brief Drift particles using the current engine drift policy.
*
* @param e The #engine.
*/
void engine_drift(struct engine *e) {
ticks tic = getticks();
threadpool_map(&e->threadpool, runner_do_drift_mapper, e->s->cells_top,
e->s->nr_cells, sizeof(struct cell), 1, e);
if (e->verbose)
message("took %.3f %s.", clocks_from_ticks(getticks() - tic),
clocks_getunit());
}
/**
* @brief Create and fill the proxies.
*
......
......@@ -209,6 +209,7 @@ struct engine {
/* Function prototypes. */
void engine_barrier(struct engine *e, int tid);
void engine_compute_next_snapshot_time(struct engine *e);
void engine_drift(struct engine *e);
void engine_dump_snapshot(struct engine *e);
void engine_init(struct engine *e, struct space *s,
const struct swift_params *params, int nr_nodes, int nodeID,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment