diff --git a/src/runner_doiact_stars.h b/src/runner_doiact_stars.h index 1ce0c370f31d860dd36e5af54020c8feb0da6c4f..e56d3b9460381e8408f370cae33e64fb93ecd541 100644 --- a/src/runner_doiact_stars.h +++ b/src/runner_doiact_stars.h @@ -300,7 +300,7 @@ void DO_SYM_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj, pid >= 0 && sort_i[pid].d + hi_max + dx_max > dj_min; pid--) { /* Get a hold of the ith part in ci. */ - struct spart *restrict spi = &sparts_i[pid]; + struct spart *restrict spi = &sparts_i[sort_i[pid].i]; const float hi = spi->h; /* Skip inactive particles */ @@ -416,7 +416,7 @@ void DO_SYM_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj, pjd++) { /* Get a hold of the jth part in cj. */ - struct spart *spj = &sparts_j[pjd]; + struct spart *spj = &sparts_j[sort_j[pjd].i]; const float hj = spj->h; /* Skip inactive particles */ diff --git a/src/stars/Default/stars.h b/src/stars/Default/stars.h index 586a87f75600a08acfd84b0f7ecc57fc4573281f..1ff4936284c4d8913417c502db69a372fc83bc06 100644 --- a/src/stars/Default/stars.h +++ b/src/stars/Default/stars.h @@ -72,18 +72,7 @@ __attribute__((always_inline)) INLINE static void stars_init_spart( * @param dt_drift The drift time-step for positions. */ __attribute__((always_inline)) INLINE static void stars_predict_extra( - struct spart* restrict sp, float dt_drift) { - - // MATTHIEU - /* const float h_inv = 1.f / sp->h; */ - - /* /\* Predict smoothing length *\/ */ - /* const float w1 = sp->feedback.h_dt * h_inv * dt_drift; */ - /* if (fabsf(w1) < 0.2f) */ - /* sp->h *= approx_expf(w1); /\* 4th order expansion of exp(w) *\/ */ - /* else */ - /* sp->h *= expf(w1); */ -} + struct spart* restrict sp, float dt_drift) {} /** * @brief Sets the values to be predicted in the drifts to their values at a diff --git a/src/tools.c b/src/tools.c index 43ac0177daef171850ea325f9fa23770fb82ae13..a29408449600ad4b46bd73ba17e20adefdbcb613 100644 --- a/src/tools.c +++ b/src/tools.c @@ -442,6 +442,9 @@ void pairs_all_stars_density(struct runner *r, struct cell *ci, struct part *pj = &cj->hydro.parts[j]; + /* Early abort? */ + if (part_is_inhibited(pj, e)) continue; + /* Pairwise distance */ r2 = 0.0f; for (int k = 0; k < 3; k++) { @@ -472,6 +475,9 @@ void pairs_all_stars_density(struct runner *r, struct cell *ci, struct part *pi = &ci->hydro.parts[i]; + /* Early abort? */ + if (part_is_inhibited(pi, e)) continue; + /* Pairwise distance */ r2 = 0.0f; for (int k = 0; k < 3; k++) { @@ -660,6 +666,9 @@ void self_all_stars_density(struct runner *r, struct cell *ci) { pj = &ci->hydro.parts[j]; hj = pj->h; + /* Early abort? */ + if (part_is_inhibited(pj, e)) continue; + /* Pairwise distance */ r2 = 0.0f; for (int k = 0; k < 3; k++) { @@ -668,7 +677,7 @@ void self_all_stars_density(struct runner *r, struct cell *ci) { } /* Hit or miss? */ - if (r2 > 0.f && r2 < hig2) { + if (r2 < hig2) { /* Interact */ runner_iact_nonsym_stars_density(r2, dxi, hi, hj, spi, pj, a, H); } diff --git a/tests/test27cellsStars.c b/tests/test27cellsStars.c index e7e1b64b1cc99d8a51cf380fde1560bdd634ae20..e97aee278e4b34d7cb1904826aba7a5ff3ed5d67 100644 --- a/tests/test27cellsStars.c +++ b/tests/test27cellsStars.c @@ -70,6 +70,7 @@ struct cell *make_cell(size_t n, size_t n_stars, double *offset, double size, const size_t count = n * n * n; const size_t scount = n_stars * n_stars * n_stars; float h_max = 0.f; + float stars_h_max = 0.f; struct cell *cell = (struct cell *)malloc(sizeof(struct cell)); bzero(cell, sizeof(struct cell)); @@ -143,7 +144,7 @@ struct cell *make_cell(size_t n, size_t n_stars, double *offset, double size, spart->h = size * h * random_uniform(1.f, h_pert) / (float)n_stars; else spart->h = size * h / (float)n_stars; - h_max = fmaxf(h_max, spart->h); + stars_h_max = fmaxf(stars_h_max, spart->h); spart->id = ++(*spartId); spart->time_bin = 1; @@ -161,6 +162,7 @@ struct cell *make_cell(size_t n, size_t n_stars, double *offset, double size, cell->split = 0; cell->hydro.h_max = h_max; cell->hydro.count = count; + cell->stars.h_max = stars_h_max; cell->stars.count = scount; cell->hydro.dx_max_part = 0.; cell->hydro.dx_max_sort = 0.;