diff --git a/src/engine.c b/src/engine.c index 67e6e45537b990bfd076c1b4d33700aa64180941..2c5700b4c04d9bb37bb5bcc649a94dc9801b70a6 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2186,8 +2186,6 @@ void engine_init_particles(struct engine *e) { if (e->nodeID == 0) message("Initialising particles"); - engine_prepare(e); - /* Make sure all particles are ready to go */ /* i.e. clean-up any stupid state in the ICs */ if (e->policy & engine_policy_hydro) { @@ -2198,6 +2196,8 @@ void engine_init_particles(struct engine *e) { space_map_cells_pre(s, 0, cell_init_gparts, NULL); } + engine_prepare(e); + engine_marktasks(e); /* Build the masks corresponding to the policy */ diff --git a/src/runner.c b/src/runner.c index e88f4ec1e3e4cc08f79cc0e53efd13d91aea8c1b..772e0478cc2c720fbe86948a43312c45cdc29d3c 100644 --- a/src/runner.c +++ b/src/runner.c @@ -57,46 +57,20 @@ #include "timestep.h" /* Orientation of the cell pairs */ -const float runner_shift[13 * 3] = { - 5.773502691896258e-01, - 5.773502691896258e-01, - 5.773502691896258e-01, - 7.071067811865475e-01, - 7.071067811865475e-01, - 0.0, - 5.773502691896258e-01, - 5.773502691896258e-01, - -5.773502691896258e-01, - 7.071067811865475e-01, - 0.0, - 7.071067811865475e-01, - 1.0, - 0.0, - 0.0, - 7.071067811865475e-01, - 0.0, - -7.071067811865475e-01, - 5.773502691896258e-01, - -5.773502691896258e-01, - 5.773502691896258e-01, - 7.071067811865475e-01, - -7.071067811865475e-01, - 0.0, - 5.773502691896258e-01, - -5.773502691896258e-01, - -5.773502691896258e-01, - 0.0, - 7.071067811865475e-01, - 7.071067811865475e-01, - 0.0, - 1.0, - 0.0, - 0.0, - 7.071067811865475e-01, - -7.071067811865475e-01, - 0.0, - 0.0, - 1.0, +const double runner_shift[13][3] = { + {5.773502691896258e-01, 5.773502691896258e-01, 5.773502691896258e-01}, + {7.071067811865475e-01, 7.071067811865475e-01, 0.0}, + {5.773502691896258e-01, 5.773502691896258e-01, -5.773502691896258e-01}, + {7.071067811865475e-01, 0.0, 7.071067811865475e-01}, + {1.0, 0.0, 0.0}, + {7.071067811865475e-01, 0.0, -7.071067811865475e-01}, + {5.773502691896258e-01, -5.773502691896258e-01, 5.773502691896258e-01}, + {7.071067811865475e-01, -7.071067811865475e-01, 0.0}, + {5.773502691896258e-01, -5.773502691896258e-01, -5.773502691896258e-01}, + {0.0, 7.071067811865475e-01, 7.071067811865475e-01}, + {0.0, 1.0, 0.0}, + {0.0, 7.071067811865475e-01, -7.071067811865475e-01}, + {0.0, 0.0, 1.0}, }; /* Does the axis need flipping ? */ @@ -256,8 +230,8 @@ void runner_do_sort(struct runner *r, struct cell *c, int flags, int clock) { struct entry *sort; int j, k, count = c->count; int i, ind, off[8], inds[8], temp_i, missing; - // float shift[3]; - float buff[8], px[3]; + float buff[8]; + double px[3]; TIMER_TIC @@ -361,9 +335,9 @@ void runner_do_sort(struct runner *r, struct cell *c, int flags, int clock) { for (j = 0; j < 13; j++) if (flags & (1 << j)) { sort[j * (count + 1) + k].i = k; - sort[j * (count + 1) + k].d = px[0] * runner_shift[3 * j + 0] + - px[1] * runner_shift[3 * j + 1] + - px[2] * runner_shift[3 * j + 2]; + sort[j * (count + 1) + k].d = px[0] * runner_shift[j][0] + + px[1] * runner_shift[j][1] + + px[2] * runner_shift[j][2]; } } diff --git a/src/runner.h b/src/runner.h index 35e5f56a7b94145eec656b02a1c5568ec39352b6..758b6cf57dbc1a46b6fc068a23615f3b28c8707e 100644 --- a/src/runner.h +++ b/src/runner.h @@ -27,7 +27,7 @@ #include "cell.h" #include "inline.h" -extern const float runner_shift[13 * 3]; +extern const double runner_shift[13][3]; extern const char runner_flip[27]; /* A struct representing a runner's thread and its data. */ diff --git a/src/runner_doiact.h b/src/runner_doiact.h index 97e22138b6c09750c1737741f58e61744a891c98..e0c13e4e0adb101d9a8975651f24225551277f43 100644 --- a/src/runner_doiact.h +++ b/src/runner_doiact.h @@ -376,9 +376,8 @@ void DOPAIR_SUBSET(struct runner *r, struct cell *restrict ci, for (k = 0; k < 3; k++) pix[k] = pi->x[k] - shift[k]; hi = pi->h; hig2 = hi * hi * kernel_gamma2; - di = hi * kernel_gamma + dxj + pix[0] * runner_shift[3 * sid + 0] + - pix[1] * runner_shift[3 * sid + 1] + - pix[2] * runner_shift[3 * sid + 2]; + di = hi * kernel_gamma + dxj + pix[0] * runner_shift[sid][0] + + pix[1] * runner_shift[sid][1] + pix[2] * runner_shift[sid][2]; /* Loop over the parts in cj. */ for (pjd = 0; pjd < count_j && sort_j[pjd].d < di; pjd++) { @@ -439,9 +438,8 @@ void DOPAIR_SUBSET(struct runner *r, struct cell *restrict ci, for (k = 0; k < 3; k++) pix[k] = pi->x[k] - shift[k]; hi = pi->h; hig2 = hi * hi * kernel_gamma2; - di = -hi * kernel_gamma - dxj + pix[0] * runner_shift[3 * sid + 0] + - pix[1] * runner_shift[3 * sid + 1] + - pix[2] * runner_shift[3 * sid + 2]; + di = -hi * kernel_gamma - dxj + pix[0] * runner_shift[sid][0] + + pix[1] * runner_shift[sid][1] + pix[2] * runner_shift[sid][2]; /* Loop over the parts in cj. */ for (pjd = count_j - 1; pjd >= 0 && di < sort_j[pjd].d; pjd--) { @@ -758,7 +756,7 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj) { /* Get the cutoff shift. */ for (rshift = 0.0, k = 0; k < 3; k++) - rshift += shift[k] * runner_shift[3 * sid + k]; + rshift += shift[k] * runner_shift[sid][k]; /* Pick-out the sorted lists. */ sort_i = &ci->sort[sid * (ci->count + 1)]; @@ -952,7 +950,7 @@ void DOPAIR2(struct runner *r, struct cell *ci, struct cell *cj) { /* Get the cutoff shift. */ for (rshift = 0.0, k = 0; k < 3; k++) - rshift += shift[k] * runner_shift[3 * sid + k]; + rshift += shift[k] * runner_shift[sid][k]; /* Pick-out the sorted lists. */ sort_i = &ci->sort[sid * (ci->count + 1)]; diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h index 81529eea39b3ee976a9e9a28fe077358993bd3c0..2dcb62cbaaffde834f0e1240c8cc28b727ea56bf 100644 --- a/src/runner_doiact_grav.h +++ b/src/runner_doiact_grav.h @@ -51,10 +51,9 @@ void runner_do_grav_up(struct runner *r, struct cell *c) { } else { /* Leaf node. */ - /* Just construct the multipole from the gparts. */ - multipole_init(&c->multipole, c->gparts, c->gcount); - } -} + /* Make sure the cells are sorted. */ + runner_do_gsort(r, ci, (1 << sid), 0); + runner_do_gsort(r, cj, (1 << sid), 0); /** * @brief Checks whether the cells are direct neighbours ot not. Both cells have @@ -68,10 +67,9 @@ void runner_do_grav_up(struct runner *r, struct cell *c) { __attribute__((always_inline)) INLINE static int are_neighbours( const struct cell *restrict ci, const struct cell *restrict cj) { -#ifdef SANITY_CHECKS - if (ci->h[0] != cj->h[0]) - error(" Cells of different size in distance calculation."); -#endif + /* Get the cutoff shift. */ + for (rshift = 0.0, k = 0; k < 3; k++) + rshift += shift[k] * runner_shift[3 * sid + k]; /* Maximum allowed distance */ const double min_dist = 1.2 * ci->h[0]; /* 1.2 accounts for rounding errors */