diff --git a/src/cell.h b/src/cell.h index b83863df99d233d5ce00f5998e3ca361d69c0012..875951b99543dbb4f840ef0d6e45b6d0c9f75b2d 100644 --- a/src/cell.h +++ b/src/cell.h @@ -424,6 +424,14 @@ struct cell { /*! Minimum dimension, i.e. smallest edge of this cell (min(width)). */ float dmin; + /*! When walking the tree and running loops at different level, this is + * the minimal h that can be processed at this level */ + float h_min_allowed; + + /*! When walking the tree and running loops at different level, this is + * the maximal h that can be processed at this level */ + float h_max_allowed; + /*! ID of the previous owner, e.g. runner. */ int owner; diff --git a/src/runner_doiact_functions_hydro.h b/src/runner_doiact_functions_hydro.h index 099eec3a1f736cc7bee3f3eb88eeee4ba81dbee7..8559d80ee51b54633045a8593ba8144891f85293 100644 --- a/src/runner_doiact_functions_hydro.h +++ b/src/runner_doiact_functions_hydro.h @@ -68,8 +68,8 @@ void DOPAIR1_NAIVE(struct runner *r, const struct cell *restrict ci, #endif /* Get the limits in h (if any) */ - const float h_min = limit_min_h ? ci->dmin * 0.5 * (1. / kernel_gamma) : 0.; - const float h_max = limit_max_h ? ci->dmin * (1. / kernel_gamma) : FLT_MAX; + const float h_min = limit_min_h ? ci->h_min_allowed : 0.; + const float h_max = limit_max_h ? ci->h_max_allowed : FLT_MAX; /* Get the relative distance between the pairs, wrapping. */ double shift[3] = {0.0, 0.0, 0.0}; @@ -204,8 +204,8 @@ void DOPAIR2_NAIVE(struct runner *r, const struct cell *restrict ci, struct part *restrict parts_j = cj->hydro.parts; /* Get the limits in h (if any) */ - const float h_min = limit_min_h ? ci->dmin * 0.5 * (1. / kernel_gamma) : 0.; - const float h_max = limit_max_h ? ci->dmin * (1. / kernel_gamma) : FLT_MAX; + const float h_min = limit_min_h ? ci->h_min_allowed : 0.; + const float h_max = limit_max_h ? ci->h_max_allowed : FLT_MAX; /* Get the relative distance between the pairs, wrapping. */ double shift[3] = {0.0, 0.0, 0.0}; @@ -1077,8 +1077,8 @@ void DOPAIR1(struct runner *r, const struct cell *restrict ci, #endif /* SWIFT_DEBUG_CHECKS */ /* Get the limits in h (if any) */ - const float h_min = limit_min_h ? ci->dmin * 0.5 * (1. / kernel_gamma) : 0.; - const float h_max = limit_max_h ? ci->dmin * (1. / kernel_gamma) : FLT_MAX; + const float h_min = limit_min_h ? ci->h_min_allowed : 0.; + const float h_max = limit_max_h ? ci->h_max_allowed : FLT_MAX; /* Get some other useful values. */ const double hi_max = @@ -1406,8 +1406,8 @@ void DOPAIR2(struct runner *r, const struct cell *restrict ci, #endif /* SWIFT_DEBUG_CHECKS */ /* Get the limits in h (if any) */ - const float h_min = limit_min_h ? ci->dmin * 0.5 * (1. / kernel_gamma) : 0.; - const float h_max = limit_max_h ? ci->dmin * (1. / kernel_gamma) : FLT_MAX; + const float h_min = limit_min_h ? ci->h_min_allowed : 0.; + const float h_max = limit_max_h ? ci->h_max_allowed : FLT_MAX; /* Get some other useful values. */ const double hi_max = ci->hydro.h_max; diff --git a/src/runner_doiact_functions_rt.h b/src/runner_doiact_functions_rt.h index 85505a75e62f0e6d36a9927a25f0ee396216ed05..54d6e931d2ccbf1f09d0e2ba27a56ea4cf779157 100644 --- a/src/runner_doiact_functions_rt.h +++ b/src/runner_doiact_functions_rt.h @@ -184,8 +184,8 @@ void DOPAIR1_NONSYM_RT_NAIVE(struct runner *r, const struct cell *restrict ci, } /* Get the limits in h (if any) */ - const float h_min = limit_min_h ? ci->dmin * 0.5 * (1. / kernel_gamma) : 0.; - const float h_max = limit_max_h ? ci->dmin * (1. / kernel_gamma) : FLT_MAX; + const float h_min = limit_min_h ? ci->h_min_allowed : 0.; + const float h_max = limit_max_h ? ci->h_max_allowed : FLT_MAX; /* Loop over the sparts in ci. */ for (int sid = 0; sid < scount_i; sid++) { @@ -303,8 +303,8 @@ void DO_SYM_PAIR1_RT(struct runner *r, const struct cell *restrict ci, (cj->nodeID == e->nodeID) && rt_should_iact_cell_pair(cj, ci, e); /* Get the limits in h (if any) */ - const float h_min = limit_min_h ? ci->dmin * 0.5 * (1. / kernel_gamma) : 0.; - const float h_max = limit_max_h ? ci->dmin * (1. / kernel_gamma) : FLT_MAX; + const float h_min = limit_min_h ? ci->h_min_allowed : 0.; + const float h_max = limit_max_h ? ci->h_max_allowed : FLT_MAX; if (do_ci_stars) { diff --git a/src/runner_doiact_functions_stars.h b/src/runner_doiact_functions_stars.h index cb1ae8e6b666814d06a893e0c756dab62bff5d43..81f7a4723636f5a0e4c9dbd12448e3804b9ec863 100644 --- a/src/runner_doiact_functions_stars.h +++ b/src/runner_doiact_functions_stars.h @@ -212,8 +212,8 @@ void DO_NONSYM_PAIR1_STARS_NAIVE(struct runner *r, } /* Get the limits in h (if any) */ - const float h_min = limit_min_h ? ci->dmin * 0.5 * (1. / kernel_gamma) : 0.; - const float h_max = limit_max_h ? ci->dmin * (1. / kernel_gamma) : FLT_MAX; + const float h_min = limit_min_h ? ci->h_min_allowed : 0.; + const float h_max = limit_max_h ? ci->h_max_allowed : FLT_MAX; /* Loop over the sparts in ci. */ for (int sid = 0; sid < scount_i; sid++) { @@ -350,8 +350,8 @@ void DO_SYM_PAIR1_STARS(struct runner *r, const struct cell *restrict ci, #endif /* Get the limits in h (if any) */ - const float h_min = limit_min_h ? ci->dmin * 0.5 * (1. / kernel_gamma) : 0.; - const float h_max = limit_max_h ? ci->dmin * (1. / kernel_gamma) : FLT_MAX; + const float h_min = limit_min_h ? ci->h_min_allowed : 0.; + const float h_max = limit_max_h ? ci->h_max_allowed : FLT_MAX; if (do_ci_stars) { diff --git a/src/space_regrid.c b/src/space_regrid.c index 5a2abb4d9ea63823369291965b1971174b36c8e3..bc0844f0b94c6161a978277f7f70339fc37c615d 100644 --- a/src/space_regrid.c +++ b/src/space_regrid.c @@ -295,6 +295,8 @@ void space_regrid(struct space *s, int verbose) { c->width[1] = s->width[1]; c->width[2] = s->width[2]; c->dmin = dmin; + c->h_min_allowed = c->dmin * 0.5 * (1. / kernel_gamma); + c->h_max_allowed = c->dmin * (1. / kernel_gamma); c->depth = 0; c->split = 0; c->hydro.count = 0; diff --git a/src/space_split.c b/src/space_split.c index aefb7bebec3d74c086119fcca27c9d43a3fa68d2..e2edee5c3832e6fdd2674263c5cc39b59057fa9b 100644 --- a/src/space_split.c +++ b/src/space_split.c @@ -223,6 +223,8 @@ void space_split_recursive(struct space *s, struct cell *c, cp->width[1] = c->width[1] / 2; cp->width[2] = c->width[2] / 2; cp->dmin = c->dmin / 2; + cp->h_min_allowed = cp->dmin * 0.5 * (1. / kernel_gamma); + cp->h_max_allowed = cp->dmin * (1. / kernel_gamma); if (k & 4) cp->loc[0] += cp->width[0]; if (k & 2) cp->loc[1] += cp->width[1]; if (k & 1) cp->loc[2] += cp->width[2];