From 7d6c99a87cd7e629973c5a7e63c6dab687519a1a Mon Sep 17 00:00:00 2001 From: loikki <loic.hausammann@protonmail.ch> Date: Wed, 9 Jan 2019 16:23:01 +0100 Subject: [PATCH] improve logic for sorting stars --- src/cell.c | 27 ++++++++++++--------------- src/cell.h | 3 +-- src/runner.c | 3 +++ 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/cell.c b/src/cell.c index 383f4ad5f0..476f84fb76 100644 --- a/src/cell.c +++ b/src/cell.c @@ -2004,20 +2004,19 @@ void cell_activate_stars_sorts_up(struct cell *c, struct scheduler *s) { if (c == c->super) { #ifdef SWIFT_DEBUG_CHECKS - if (c->stars.sorts_local == NULL && c->stars.sorts_foreign == NULL) + if ((c->nodeID == engine_rank && c->stars.sorts_local == NULL) || + (c->nodeID != engine_rank && c->stars.sorts_foreign == NULL)) error("Trying to activate un-existing c->stars.sorts"); #endif - if (c->stars.sorts_local) { + if (c->nodeID == engine_rank) { scheduler_activate(s, c->stars.sorts_local); - } - if (c->stars.sorts_foreign) { - scheduler_activate(s, c->stars.sorts_foreign); - } - if (c->stars.sorts_local) { // MATTHIEU: to do: do we actually need both drifts here? cell_activate_drift_part(c, s); cell_activate_drift_spart(c, s); } + if (c->nodeID != engine_rank) { + scheduler_activate(s, c->stars.sorts_foreign); + } } else { for (struct cell *parent = c->parent; @@ -2026,20 +2025,18 @@ void cell_activate_stars_sorts_up(struct cell *c, struct scheduler *s) { parent->stars.do_sub_sort = 1; if (parent == c->super) { #ifdef SWIFT_DEBUG_CHECKS - if (parent->stars.sorts_local == NULL && - parent->stars.sorts_foreign == NULL) + if ((c->nodeID == engine_rank && parent->stars.sorts_local == NULL) || + (c->nodeID != engine_rank && parent->stars.sorts_foreign == NULL)) error("Trying to activate un-existing parents->stars.sorts"); #endif - if (parent->stars.sorts_local) { + if (c->nodeID == engine_rank) { scheduler_activate(s, parent->stars.sorts_local); - } - if (parent->stars.sorts_foreign) { - scheduler_activate(s, parent->stars.sorts_foreign); - } - if (parent->stars.sorts_local) { cell_activate_drift_part(parent, s); cell_activate_drift_spart(parent, s); } + if (c->nodeID != engine_rank) { + scheduler_activate(s, parent->stars.sorts_foreign); + } break; } } diff --git a/src/cell.h b/src/cell.h index 0a9b1cd688..d1b9b82be4 100644 --- a/src/cell.h +++ b/src/cell.h @@ -1008,8 +1008,7 @@ cell_need_rebuild_for_hydro_pair(const struct cell *ci, const struct cell *cj) { } /** * @brief Have star particles in a pair of cells moved too much and require a - * rebuild - * ? + * rebuild? * * @param ci The first #cell. * @param cj The second #cell. diff --git a/src/runner.c b/src/runner.c index 14ccfdfde9..843452bca9 100644 --- a/src/runner.c +++ b/src/runner.c @@ -1019,6 +1019,9 @@ void runner_do_stars_sort(struct runner *r, struct cell *c, int flags, /* Copy the minimum into the new sort array. */ finger[ind].d = buff[inds[0]]; + if (c->progeny[inds[0]] == NULL || + c->progeny[inds[0]]->stars.count == 0) + error("should not do it"); finger[ind].i = fingers[inds[0]]->i + off[inds[0]]; /* Update the buffer. */ -- GitLab