Skip to content
Snippets Groups Projects
Commit a507a518 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

When moving foreign particles to the end of the list, make sure we don't swap...

When moving foreign particles to the end of the list, make sure we don't swap with one that is a foreign particle.
parent c3795f39
No related branches found
No related tags found
1 merge request!158Exchange all foreign particles
...@@ -433,7 +433,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { ...@@ -433,7 +433,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
#ifdef WITH_MPI #ifdef WITH_MPI
/* Move non-local parts to the end of the list. */ /* Move non-local parts to the end of the list. */
const int local_nodeID = s->e->nodeID; const int local_nodeID = s->e->nodeID;
for (size_t k = 0; k < nr_parts; k++) for (size_t k = 0; k < nr_parts;) {
if (cells[ind[k]].nodeID != local_nodeID) { if (cells[ind[k]].nodeID != local_nodeID) {
cells[ind[k]].count -= 1; cells[ind[k]].count -= 1;
nr_parts -= 1; nr_parts -= 1;
...@@ -453,9 +453,14 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { ...@@ -453,9 +453,14 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
ind[k] = ind[nr_parts]; ind[k] = ind[nr_parts];
ind[nr_parts] = t; ind[nr_parts] = t;
} }
else {
/* Increment when not exchanging otherwise we need to retest "k".*/
k++;
}
}
/* Move non-local gparts to the end of the list. */ /* Move non-local gparts to the end of the list. */
for (int k = 0; k < nr_gparts; k++) for (int k = 0; k < nr_gparts;) {
if (cells[gind[k]].nodeID != local_nodeID) { if (cells[gind[k]].nodeID != local_nodeID) {
cells[gind[k]].gcount -= 1; cells[gind[k]].gcount -= 1;
nr_gparts -= 1; nr_gparts -= 1;
...@@ -472,6 +477,11 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { ...@@ -472,6 +477,11 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
gind[k] = gind[nr_gparts]; gind[k] = gind[nr_gparts];
gind[nr_gparts] = t; gind[nr_gparts] = t;
} }
else {
/* Increment when not exchanging otherwise we need to retest "k".*/
k++;
}
}
/* Exchange the strays, note that this potentially re-allocates /* Exchange the strays, note that this potentially re-allocates
the parts arrays. */ the parts arrays. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment