From a9bfc4a6d5dcbc2f0f827ce7cc2d167a930cb0f4 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Sat, 27 Jul 2019 11:16:46 +0100 Subject: [PATCH] Applied the same checks for already removed particles to the other species. --- src/cell.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/cell.c b/src/cell.c index eecf824002..d4a31db62f 100644 --- a/src/cell.c +++ b/src/cell.c @@ -5323,6 +5323,9 @@ void cell_remove_part(const struct engine *e, struct cell *c, struct part *p, if (c->nodeID != e->nodeID) error("Can't remove a particle in a foreign cell."); + /* Don't remove a particle twice */ + if (p->time_bin == time_bin_inhibited) return; + /* Mark the particle as inhibited */ p->time_bin = time_bin_inhibited; @@ -5357,6 +5360,10 @@ void cell_remove_part(const struct engine *e, struct cell *c, struct part *p, void cell_remove_gpart(const struct engine *e, struct cell *c, struct gpart *gp) { + /* Quick cross-check */ + if (c->nodeID != e->nodeID) + error("Can't remove a particle in a foreign cell."); + /* Don't remove a particle twice */ if (gp->time_bin == time_bin_inhibited) return; @@ -5388,6 +5395,9 @@ 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."); + /* Don't remove a particle twice */ + if (sp->time_bin == time_bin_inhibited) return; + /* Mark the particle as inhibited and stand-alone */ sp->time_bin = time_bin_inhibited; if (sp->gpart) { @@ -5421,6 +5431,9 @@ void cell_remove_bpart(const struct engine *e, struct cell *c, if (c->nodeID != e->nodeID) error("Can't remove a particle in a foreign cell."); + /* Don't remove a particle twice */ + if (bp->time_bin == time_bin_inhibited) return; + /* Mark the particle as inhibited and stand-alone */ bp->time_bin = time_bin_inhibited; if (bp->gpart) { -- GitLab