From a242c2cb5ae9bdd3a30ba66ba63d29f509d2b791 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Thu, 7 Nov 2019 23:37:15 +0100
Subject: [PATCH] Reset the reposition variables once the reposition is done.
 Avoids problems when there are multiple drifts.

---
 src/black_holes/EAGLE/black_holes.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/black_holes/EAGLE/black_holes.h b/src/black_holes/EAGLE/black_holes.h
index a1b41f0954..f600f6eeb8 100644
--- a/src/black_holes/EAGLE/black_holes.h
+++ b/src/black_holes/EAGLE/black_holes.h
@@ -125,6 +125,12 @@ __attribute__((always_inline)) INLINE static void black_holes_predict_extra(
     bp->gpart->x[0] = bp->reposition.x[0];
     bp->gpart->x[1] = bp->reposition.x[1];
     bp->gpart->x[2] = bp->reposition.x[2];
+
+    /* Reset the reposition variables */
+    bp->reposition.x[0] = -FLT_MAX;
+    bp->reposition.x[1] = -FLT_MAX;
+    bp->reposition.x[2] = -FLT_MAX;
+    bp->reposition.min_potential = FLT_MAX;
   }
 }
 
-- 
GitLab