From 7aec67f47f4c651680bf71d3d2f8e3b12ffe4518 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Sat, 25 Feb 2017 14:14:02 +0000 Subject: [PATCH] Moved the particle drifting mapper from the runner to the engine. --- src/engine.c | 28 +++++++++++++++++++++++++++- src/runner.c | 25 ------------------------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/engine.c b/src/engine.c index deae35f865..6e1bdfbed4 100644 --- a/src/engine.c +++ b/src/engine.c @@ -3136,6 +3136,32 @@ void engine_unskip(struct engine *e) { clocks_getunit()); } +/** + * @brief Mapper function to drift ALL particle types and multipoles forward in + * time. + * + * @param map_data An array of #cell%s. + * @param num_elements Chunk size. + * @param extra_data Pointer to an #engine. + */ +void engine_do_drift_all_mapper(void *map_data, int num_elements, + void *extra_data) { + + struct engine *e = (struct engine *)extra_data; + struct cell *cells = (struct cell *)map_data; + + for (int ind = 0; ind < num_elements; ind++) { + struct cell *c = &cells[ind]; + if (c != NULL && c->nodeID == e->nodeID) { + /* Drift all the particles */ + cell_drift_particles(c, e); + + /* Drift the multipole */ + if (e->policy & engine_policy_self_gravity) cell_drift_multipole(c, e); + } + } +} + /** * @brief Drift *all* particles forward to the current time. * @@ -3144,7 +3170,7 @@ void engine_unskip(struct engine *e) { void engine_drift_all(struct engine *e) { const ticks tic = getticks(); - threadpool_map(&e->threadpool, runner_do_drift_all_mapper, e->s->cells_top, + threadpool_map(&e->threadpool, engine_do_drift_all_mapper, e->s->cells_top, e->s->nr_cells, sizeof(struct cell), 1, e); #ifdef SWIFT_DEBUG_CHECKS diff --git a/src/runner.c b/src/runner.c index ff78e5d679..dec6c4e87a 100644 --- a/src/runner.c +++ b/src/runner.c @@ -819,31 +819,6 @@ void runner_do_drift_particles(struct runner *r, struct cell *c, int timer) { 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_all_mapper(void *map_data, int num_elements, - void *extra_data) { - - struct engine *e = (struct engine *)extra_data; - struct cell *cells = (struct cell *)map_data; - - for (int ind = 0; ind < num_elements; ind++) { - struct cell *c = &cells[ind]; - if (c != NULL && c->nodeID == e->nodeID) { - /* Drift all the particles */ - cell_drift_particles(c, e); - - /* Drift the multipole */ - if (e->policy & engine_policy_self_gravity) cell_drift_multipole(c, e); - } - } -} - /** * @brief Perform the first half-kick on all the active particles in a cell. * -- GitLab