Commit cbf521a5 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

In the feedback loops, skip the particles that are not doing feedback.

parent f9393ac0
......@@ -44,6 +44,27 @@ __attribute__((always_inline)) INLINE static int feedback_do_feedback(
return (sp->birth_time != -1.);
}
/**
* @brief Should this particle be doing any feedback-related operation?
*
* @param sp The #spart.
* @param time The current simulation time (Non-cosmological runs).
* @param cosmo The cosmological model (cosmological runs).
* @param with_cosmology Are we doing a cosmological run?
*/
__attribute__((always_inline)) INLINE static int feedback_is_active(
const struct spart* sp, const float time, const struct cosmology* cosmo,
const int with_cosmology) {
if (sp->birth_time == -1.) return 0;
if (with_cosmology) {
return ((float)cosmo->a) > sp->birth_scale_factor;
} else {
return time > sp->birth_time;
}
}
/**
* @brief Prepares a s-particle for its feedback interactions
*
......
......@@ -45,6 +45,21 @@ __attribute__((always_inline)) INLINE static int feedback_do_feedback(
return 0;
}
/**
* @brief Should this particle be doing any feedback-related operation?
*
* @param sp The #spart.
* @param time The current simulation time (Non-cosmological runs).
* @param cosmo The cosmological model (cosmological runs).
* @param with_cosmology Are we doing a cosmological run?
*/
__attribute__((always_inline)) INLINE static int feedback_is_active(
const struct spart* sp, const float time, const struct cosmology* cosmo,
const int with_cosmology) {
return 0;
}
/**
* @brief Prepares a star's feedback field before computing what
* needs to be distributed.
......
......@@ -185,7 +185,8 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) {
if ((right = (float *)malloc(sizeof(float) * c->stars.count)) == NULL)
error("Can't allocate memory for right.");
for (int k = 0; k < c->stars.count; k++)
if (spart_is_active(&sparts[k], e)) {
if (spart_is_active(&sparts[k], e) &&
feedback_is_active(&sparts[k], e->time, cosmo, with_cosmology)) {
sid[scount] = k;
h_0[scount] = sparts[k].h;
left[scount] = 0.f;
......@@ -1608,14 +1609,12 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) {
const float h_init = h_0[i];
const float h_old = p->h;
const float h_old_dim = pow_dimension(h_old);
// const float h_old_inv_dim = pow_dimension(1.f / h_old);
const float h_old_dim_minus_one = pow_dimension_minus_one(h_old);
float h_new;
int has_no_neighbours = 0;
if (p->density.wcount == 0.f) {
// 1e-5 * kernel_root * h_old_inv_dim) { /* No neighbours case */
if (p->density.wcount == 0.f) { /* No neighbours case */
/* Flag that there were no neighbours */
has_no_neighbours = 1;
......
......@@ -102,6 +102,7 @@ void DOSELF1_STARS(struct runner *r, struct cell *c, int timer) {
TIMER_TIC;
const struct engine *e = r->e;
const int with_cosmology = e->policy & engine_policy_cosmology;
const integertime_t ti_current = e->ti_current;
const struct cosmology *cosmo = e->cosmology;
......@@ -124,8 +125,13 @@ void DOSELF1_STARS(struct runner *r, struct cell *c, int timer) {
/* Get a hold of the ith spart in ci. */
struct spart *restrict si = &sparts[sid];
/* Skip inactive particles */
if (!spart_is_active(si, e)) continue;
/* Skip inactive particles */
if (!feedback_is_active(si, e->time, cosmo, with_cosmology)) continue;
const float hi = si->h;
const float hig2 = hi * hi * kernel_gamma2;
const float six[3] = {(float)(si->x[0] - c->loc[0]),
......@@ -191,6 +197,7 @@ void DO_NONSYM_PAIR1_STARS_NAIVE(struct runner *r, struct cell *restrict ci,
#endif
const struct engine *e = r->e;
const int with_cosmology = e->policy & engine_policy_cosmology;
const integertime_t ti_current = e->ti_current;
const struct cosmology *cosmo = e->cosmology;
......@@ -222,8 +229,13 @@ void DO_NONSYM_PAIR1_STARS_NAIVE(struct runner *r, struct cell *restrict ci,
/* Get a hold of the ith spart in ci. */
struct spart *restrict si = &sparts_i[sid];
/* Skip inactive particles */
if (!spart_is_active(si, e)) continue;
/* Skip inactive particles */
if (!feedback_is_active(si, e->time, cosmo, with_cosmology)) continue;
const float hi = si->h;
const float hig2 = hi * hi * kernel_gamma2;
const float six[3] = {(float)(si->x[0] - (cj->loc[0] + shift[0])),
......@@ -284,6 +296,7 @@ void DO_SYM_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj,
TIMER_TIC;
const struct engine *e = r->e;
const int with_cosmology = e->policy & engine_policy_cosmology;
const integertime_t ti_current = e->ti_current;
const struct cosmology *cosmo = e->cosmology;
......@@ -350,6 +363,9 @@ void DO_SYM_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj,
/* Skip inactive particles */
if (!spart_is_active(spi, e)) continue;
/* Skip inactive particles */
if (!feedback_is_active(spi, e->time, cosmo, with_cosmology)) continue;
/* Compute distance from the other cell. */
const double px[3] = {spi->x[0], spi->x[1], spi->x[2]};
float dist = px[0] * runner_shift[sid][0] + px[1] * runner_shift[sid][1] +
......@@ -475,6 +491,9 @@ void DO_SYM_PAIR1_STARS(struct runner *r, struct cell *ci, struct cell *cj,
/* Skip inactive particles */
if (!spart_is_active(spj, e)) continue;
/* Skip inactive particles */
if (!feedback_is_active(spj, e->time, cosmo, with_cosmology)) continue;
/* Compute distance from the other cell. */
const double px[3] = {spj->x[0], spj->x[1], spj->x[2]};
float dist = px[0] * runner_shift[sid][0] + px[1] * runner_shift[sid][1] +
......
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