Commit 5f0e8673 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Better documentation of the particle re-organisation.

parent c86c5934
......@@ -5400,12 +5400,10 @@ void engine_check_for_dumps(struct engine *e) {
/* Do we want to perform structure finding? */
int run_stf = 0;
if (with_stf && stf_time_output) {
if (e->ti_end_min > e->ti_next_stf && e->ti_next_stf > 0)
run_stf = 1;
if (e->ti_end_min > e->ti_next_stf && e->ti_next_stf > 0) run_stf = 1;
}
if (with_stf && !stf_time_output) {
if(e->step % e->delta_step_stf == 0)
run_stf = 1;
if (e->step % e->delta_step_stf == 0) run_stf = 1;
}
/* Store information before attempting extra dump-related drifts */
......
......@@ -611,10 +611,16 @@ void space_rebuild(struct space *s, int verbose) {
/* Move non-local parts and inhibited parts to the end of the list. */
if (s->e->nr_nodes > 1 || count_inhibited_parts > 0) {
for (size_t k = 0; k < nr_parts; /* void */) {
/* Inhibited particle or foreign particle */
if (ind[k] == -1 || cells_top[ind[k]].nodeID != local_nodeID) {
/* One fewer particle */
nr_parts -= 1;
/* Swap the particle */
memswap(&s->parts[k], &s->parts[nr_parts], sizeof(struct part));
/* Swap the link with the gpart */
if (s->parts[k].gpart != NULL) {
s->parts[k].gpart->id_or_neg_offset = -k;
......@@ -622,10 +628,12 @@ void space_rebuild(struct space *s, int verbose) {
if (s->parts[nr_parts].gpart != NULL) {
s->parts[nr_parts].gpart->id_or_neg_offset = -nr_parts;
}
/* Swap the xpart */
memswap(&s->xparts[k], &s->xparts[nr_parts], sizeof(struct xpart));
/* Swap the index */
memswap(&ind[k], &ind[nr_parts], sizeof(int));
} else {
/* Increment when not exchanging otherwise we need to retest "k".*/
k++;
......@@ -654,10 +662,16 @@ void space_rebuild(struct space *s, int verbose) {
/* Move non-local sparts and inhibited sparts to the end of the list. */
if (s->e->nr_nodes > 1 || count_inhibited_sparts > 0) {
for (size_t k = 0; k < nr_sparts; /* void */) {
/* Inhibited particle or foreign particle */
if (sind[k] == -1 || cells_top[sind[k]].nodeID != local_nodeID) {
/* One fewer particle */
nr_sparts -= 1;
/* Swap the particle */
memswap(&s->sparts[k], &s->sparts[nr_sparts], sizeof(struct spart));
/* Swap the link with the gpart */
if (s->sparts[k].gpart != NULL) {
s->sparts[k].gpart->id_or_neg_offset = -k;
......@@ -665,8 +679,10 @@ void space_rebuild(struct space *s, int verbose) {
if (s->sparts[nr_sparts].gpart != NULL) {
s->sparts[nr_sparts].gpart->id_or_neg_offset = -nr_sparts;
}
/* Swap the index */
memswap(&sind[k], &sind[nr_sparts], sizeof(int));
} else {
/* Increment when not exchanging otherwise we need to retest "k".*/
k++;
......@@ -695,10 +711,16 @@ void space_rebuild(struct space *s, int verbose) {
/* Move non-local gparts and inhibited parts to the end of the list. */
if (s->e->nr_nodes > 1 || count_inhibited_gparts > 0) {
for (size_t k = 0; k < nr_gparts; /* void */) {
/* Inhibited particle or foreign particle */
if (gind[k] == -1 || cells_top[gind[k]].nodeID != local_nodeID) {
/* One fewer particle */
nr_gparts -= 1;
/* Swap the particle */
memswap(&s->gparts[k], &s->gparts[nr_gparts], sizeof(struct gpart));
/* Swap the link with part/spart */
if (s->gparts[k].type == swift_type_gas) {
s->parts[-s->gparts[k].id_or_neg_offset].gpart = &s->gparts[k];
......@@ -712,6 +734,7 @@ void space_rebuild(struct space *s, int verbose) {
s->sparts[-s->gparts[nr_gparts].id_or_neg_offset].gpart =
&s->gparts[nr_gparts];
}
/* Swap the index */
memswap(&gind[k], &gind[nr_gparts], sizeof(int));
} else {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment