Commit 537d66cc authored by Loic Hausammann's avatar Loic Hausammann
Browse files

h_max: use existing recursion

parent 89480c73
......@@ -4999,45 +4999,3 @@ int cell_can_use_pair_mm_rebuild(const struct cell *ci, const struct cell *cj,
return gravity_M2L_accept(multi_i->r_max_rebuild, multi_j->r_max_rebuild,
theta_crit2, r2);
}
/**
* @brief Updates the hydro h_max in all the cell above.
*
* This function is used when h_max is updated in the ghost.
*
* @param c The #cell to update.
* @param h_max The new h_max.
*/
void cell_update_hydro_h_max(struct cell *c, double h_max) {
/* Check if new h_max is larger */
if (h_max > c->hydro.h_max) {
c->hydro.h_max = h_max;
/* Update parents */
if (c->parent != NULL)
cell_update_hydro_h_max(c->parent, h_max);
}
}
/**
* @brief Updates the stars h_max in all the cell above.
*
* This function is used when h_max is updated in the ghost.
*
* @param c The #cell to update.
* @param h_max The new h_max.
*/
void cell_update_stars_h_max(struct cell *c, double h_max) {
/* Check if new h_max is larger */
if (h_max > c->stars.h_max) {
c->stars.h_max = h_max;
/* Update parents */
if (c->parent != NULL)
cell_update_stars_h_max(c->parent, h_max);
}
}
......@@ -799,8 +799,6 @@ int cell_can_use_pair_mm(const struct cell *ci, const struct cell *cj,
const struct engine *e, const struct space *s);
int cell_can_use_pair_mm_rebuild(const struct cell *ci, const struct cell *cj,
const struct engine *e, const struct space *s);
void cell_update_hydro_h_max(struct cell *c, double h_max);
void cell_update_stars_h_max(struct cell *c, double h_max);
/**
* @brief Compute the square of the minimal distance between any two points in
......
......@@ -154,7 +154,13 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) {
/* Recurse? */
if (c->split) {
for (int k = 0; k < 8; k++)
if (c->progeny[k] != NULL) runner_do_stars_ghost(r, c->progeny[k], 0);
if (c->progeny[k] != NULL) {
runner_do_stars_ghost(r, c->progeny[k], 0);
/* update h_max */
if (c->progeny[k]->stars.h_max > c->stars.h_max)
c->stars.h_max = c->progeny[k]->stars.h_max;
}
} else {
/* Init the list of active particles that have to be updated. */
......@@ -418,7 +424,9 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) {
free(h_0);
}
cell_update_stars_h_max(c, h_max);
/* update h_max */
if (h_max > c->stars.h_max)
c->stars.h_max = h_max;
if (timer) TIMER_TOC(timer_dostars_ghost);
}
......@@ -1365,7 +1373,12 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) {
/* Recurse? */
if (c->split) {
for (int k = 0; k < 8; k++)
if (c->progeny[k] != NULL) runner_do_ghost(r, c->progeny[k], 0);
if (c->progeny[k] != NULL) {
runner_do_ghost(r, c->progeny[k], 0);
/* update h_max */
if (c->progeny[k]->hydro.h_max > c->hydro.h_max)
c->hydro.h_max = c->progeny[k]->hydro.h_max;
}
} else {
/* Init the list of active particles that have to be updated and their
......@@ -1726,7 +1739,9 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) {
free(h_0);
}
cell_update_hydro_h_max(c, h_max);
/* Update h_max */
if (h_max > c->hydro.h_max)
c->hydro.h_max = h_max;
if (timer) TIMER_TOC(timer_do_ghost);
}
......
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