From 6e30d5196f6d820a237dbd2f33a3040f25b2db63 Mon Sep 17 00:00:00 2001
From: "Peter W. Draper" <p.w.draper@durham.ac.uk>
Date: Fri, 7 Oct 2016 16:04:51 +0100
Subject: [PATCH] Fix the updated particles count

Strange but drift doesn't seem to visit all cells to reset this count
---
 src/engine.c | 8 ++++++++
 src/runner.c | 4 ----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/engine.c b/src/engine.c
index e90bc321e9..fadaffd32c 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -2359,6 +2359,10 @@ void engine_collect_kick(struct cell *c) {
         ti_end_min = min(ti_end_min, cp->ti_end_min);
         updated += cp->updated;
         g_updated += cp->g_updated;
+
+        /* Collected, so clear for next time. */
+        cp->updated = 0;
+        cp->g_updated = 0;
       }
     }
   }
@@ -2394,6 +2398,10 @@ void engine_collect_timestep(struct engine *e) {
       ti_end_min = min(ti_end_min, c->ti_end_min);
       updates += c->updated;
       g_updates += c->g_updated;
+
+      /* Collected, so clear for next time. */
+      c->updated = 0;
+      c->g_updated = 0;
     }
 
 /* Aggregate the data from the different nodes. */
diff --git a/src/runner.c b/src/runner.c
index cfc9250314..bef07aadcb 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -756,10 +756,6 @@ static void runner_do_drift(struct cell *c, struct engine *e, int drift) {
 
   const int ti_current = e->ti_current;
 
-  /* Clear the active particle counters. */
-  c->updated = 0;
-  c->g_updated = 0;
-
   /* Unskip any active tasks. */
   if (c->ti_end_min == e->ti_current) {
     const int forcerebuild = cell_unskip_tasks(c);
-- 
GitLab