Commit af2ad857 authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

fix the cell linking in cell_split.

parent 693b07d6
......@@ -339,9 +339,11 @@ void cell_gunlocktree(struct cell *c) {
* @brief Sort the parts into eight bins along the given pivots.
*
* @param c The #cell array to be sorted.
* @param parts_offset Offset of the cell parts array relative to the
* space's parts array, i.e. c->parts - s->parts.
*/
void cell_split(struct cell *c) {
void cell_split(struct cell *c, ptrdiff_t parts_offset) {
int i, j;
const int count = c->count, gcount = c->gcount;
......@@ -452,7 +454,7 @@ void cell_split(struct cell *c) {
/* Re-link the gparts. */
for (int k = 0; k < count; k++)
if (parts[k].gpart != NULL) {
parts[k].gpart->id_or_neg_offset = -k;
parts[k].gpart->id_or_neg_offset = -(k + parts_offset);
}
/* Verify that _all_ the parts have been assigned to a cell. */
......
......@@ -20,6 +20,9 @@
#define SWIFT_CELL_H
/* Includes. */
#include <stddef.h>
/* Local includes. */
#include "lock.h"
#include "multipole.h"
#include "part.h"
......@@ -167,7 +170,7 @@ struct cell {
((int)(k) + (cdim)[2] * ((int)(j) + (cdim)[1] * (int)(i)))
/* Function prototypes. */
void cell_split(struct cell *c);
void cell_split(struct cell *c, ptrdiff_t parts_offset);
int cell_locktree(struct cell *c);
void cell_unlocktree(struct cell *c);
int cell_glocktree(struct cell *c);
......
......@@ -1100,7 +1100,7 @@ void space_do_split(struct space *s, struct cell *c) {
}
/* Split the cell data. */
cell_split(c);
cell_split(c, c->parts - s->parts);
/* Remove any progeny with zero parts. */
for (int k = 0; k < 8; k++)
......
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