diff --git a/src/cell.c b/src/cell.c index 383f4ad5f0766d6e492abd5d0457f70510cf320d..476f84fb76713eab3d153b2e00cbb10277700a2f 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 0a9b1cd688a01be310ec394fdce9eef8fec7f7b5..d1b9b82be4e66d5847d775ee9684aaa793b53e64 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 14ccfdfde91bfb7f19e0add66aacba91f433c558..843452bca907edd1058b997930c7ebee62f26684 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. */