From 7c7ac4d8fef19c82564fafb01ffb5695b42ac1f8 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Tue, 28 Feb 2017 10:26:47 +0000
Subject: [PATCH] Added function to drift the multipole of a given cell without
 updating its progenies.

Added function to drift the multipole of a given cell without updating its progenies.
---
 src/cell.c   | 13 ++++++++++++-
 src/cell.h   |  1 +
 src/engine.c | 13 ++++---------
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/cell.c b/src/cell.c
index da55a01478..837a533476 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -1457,7 +1457,7 @@ void cell_drift_particles(struct cell *c, const struct engine *e) {
  * @param c The #cell.
  * @param e The #engine (to get ti_current).
  */
-void cell_drift_multipole(struct cell *c, const struct engine *e) {
+void cell_drift_all_multipoles(struct cell *c, const struct engine *e) {
 
   const double timeBase = e->timeBase;
   const integertime_t ti_old_multipole = c->ti_old_multipole;
@@ -1486,6 +1486,17 @@ void cell_drift_multipole(struct cell *c, const struct engine *e) {
   c->ti_old_multipole = ti_current;
 }
 
+/**
+ * @brief Drifts the multipole of a cell to the current time.
+ *
+ * Only drifts the multipole at this level. Multipoles deeper in the
+ * tree are not updated.
+ *
+ * @param c The #cell.
+ * @param e The #engine (to get ti_current).
+ */
+void cell_drift_multipole(struct cell *c, const struct engine *e);
+
 /**
  * @brief Recursively checks that all particles in a cell have a time-step
  */
diff --git a/src/cell.h b/src/cell.h
index 3edd238e21..2e3ce0e0e5 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -356,6 +356,7 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s);
 void cell_set_super(struct cell *c, struct cell *super);
 void cell_drift_particles(struct cell *c, const struct engine *e);
 void cell_drift_multipole(struct cell *c, const struct engine *e);
+void cell_drift_all_multipoles(struct cell *c, const struct engine *e);
 void cell_check_timesteps(struct cell *c);
 
 #endif /* SWIFT_CELL_H */
diff --git a/src/engine.c b/src/engine.c
index 5862181ec6..7213678294 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -3028,14 +3028,8 @@ void engine_step(struct engine *e) {
   if (e->step % 100 == 2) e->forcerepart = 1;
 #endif
 
-  /* Are we drifting everything ? */
-  if (e->policy & engine_policy_drift_all) {
-    engine_drift_all(e);
-
-#ifdef SWIFT_DEBUG_CHECKS
-    space_check_drift_point(e->s, e->ti_current);
-#endif
-  }
+  /* Are we drifting everything (a la Gadget/GIZMO) ? */
+  if (e->policy & engine_policy_drift_all) engine_drift_all(e);
 
   /* Print the number of active tasks ? */
   if (e->verbose) engine_print_task_counts(e);
@@ -3143,7 +3137,8 @@ void engine_do_drift_all_mapper(void *map_data, int num_elements,
       cell_drift_particles(c, e);
 
       /* Drift the multipole */
-      if (e->policy & engine_policy_self_gravity) cell_drift_multipole(c, e);
+      if (e->policy & engine_policy_self_gravity)
+        cell_drift_all_multipoles(c, e);
     }
   }
 }
-- 
GitLab