From 7591ce2e1638d3947fd57de54310713e93e578e6 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Fri, 23 Nov 2018 12:10:23 +0100 Subject: [PATCH] Additional debugging checks when re-ordering sparts in top-level cells. --- src/cell.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cell.c b/src/cell.c index 76a189cc5f..a74d44a47c 100644 --- a/src/cell.c +++ b/src/cell.c @@ -3749,7 +3749,7 @@ struct spart *cell_add_spart(struct engine *e, struct cell *const c) { /* Are there any extra particles left? */ if (top->stars.count == top->stars.count_total) { - //message("We ran out of star particles!"); + // message("We ran out of star particles!"); atomic_inc(&e->forcerebuild); return NULL; } @@ -3761,7 +3761,8 @@ struct spart *cell_add_spart(struct engine *e, struct cell *const c) { // MATTHIEU: This can be improved. We don't need to copy everything, just // need to swap a few particles. - memmove(&c->stars.parts[1], &c->stars.parts[0], n_copy * sizeof(struct spart)); + memmove(&c->stars.parts[1], &c->stars.parts[0], + n_copy * sizeof(struct spart)); /* Update the gpart->spart links (shift by 1) */ for (size_t i = 0; i < n_copy; ++i) { @@ -4049,6 +4050,11 @@ void cell_reorder_extra_sparts(struct cell *c, const ptrdiff_t sparts_offset) { memswap(&sparts[i], &sparts[first_not_extra], sizeof(struct spart)); if (sparts[i].gpart) sparts[i].gpart->id_or_neg_offset = -(i + sparts_offset); + sparts[first_not_extra].gpart = NULL; +#ifdef SWIFT_DEBUG_CHECKS + if (sparts[first_not_extra].time_bin != time_bin_not_created) + error("Incorrect swap occured!"); +#endif } } } -- GitLab