From cca41277f8e30ad8cea84c6cd2fd5cf8d14a8e6a Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Sat, 13 Oct 2018 19:25:21 +0200
Subject: [PATCH] Make the gpart friend of inhibted particles a stand-alone
 particle.

---
 src/cell.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/cell.c b/src/cell.c
index 9a3a71a5a2..defeb79f99 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -3238,7 +3238,13 @@ void cell_remove_part(const struct engine *e, struct cell *c, struct part *p,
 
   /* Mark the particle as inhibited */
   p->time_bin = time_bin_inhibited;
-  if (p->gpart) p->gpart->time_bin = time_bin_inhibited;
+
+  /* Mark the gpart as inhibited and stand-alone */
+  if (p->gpart) {
+    p->gpart->time_bin = time_bin_inhibited;
+    p->gpart->id_or_neg_offset = p->id;
+    p->gpart->type = swift_type_dark_matter;
+  }
 
   /* Un-link the part */
   p->gpart = NULL;
@@ -3283,9 +3289,13 @@ void cell_remove_spart(const struct engine *e, struct cell *c,
   if (c->nodeID != e->nodeID)
     error("Can't remove a particle in a foreign cell.");
 
-  /* Mark the particle as inhibited */
+  /* Mark the particle as inhibited and stand-alone */
   sp->time_bin = time_bin_inhibited;
-  if (sp->gpart) sp->gpart->time_bin = time_bin_inhibited;
+  if (sp->gpart) {
+    sp->gpart->time_bin = time_bin_inhibited;
+    sp->gpart->id_or_neg_offset = sp->id;
+    sp->gpart->type = swift_type_dark_matter;
+  }
 
   /* Un-link the spart */
   sp->gpart = NULL;
-- 
GitLab