Commit 89480c73 authored by Loic Hausammann's avatar Loic Hausammann
Browse files

Update h_max

parent b892e7f5
......@@ -4999,3 +4999,45 @@ 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,6 +799,8 @@ 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
......@@ -1059,4 +1061,5 @@ __attribute__((always_inline)) INLINE static void cell_ensure_tagged(
#endif // WITH_MPI
}
#endif /* SWIFT_CELL_H */
......@@ -144,6 +144,8 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) {
const int max_smoothing_iter = e->stars_properties->max_smoothing_iterations;
int redo = 0, scount = 0;
double h_max = c->stars.h_max;
TIMER_TIC;
/* Anything to do here? */
......@@ -338,7 +340,12 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) {
}
/* We now have a particle whose smoothing length has converged */
stars_reset_feedback(sp);
/* Check if h_max is increased */
if (h_max < sp->h)
h_max = sp->h;
stars_reset_feedback(sp);
/* Compute the stellar evolution */
stars_evolve_spart(sp, e->stars_properties, cosmo);
......@@ -411,6 +418,8 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) {
free(h_0);
}
cell_update_stars_h_max(c, h_max);
if (timer) TIMER_TOC(timer_dostars_ghost);
}
......@@ -1346,6 +1355,8 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) {
const int max_smoothing_iter = e->hydro_properties->max_smoothing_iterations;
int redo = 0, count = 0;
double h_max = c->hydro.h_max;
TIMER_TIC;
/* Anything to do here? */
......@@ -1598,6 +1609,11 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) {
/* We now have a particle whose smoothing length has converged */
/* Check if h_max is increased */
if (h_max < p->h) {
h_max = p->h;
}
#ifdef EXTRA_HYDRO_LOOP
/* As of here, particle gradient variables will be set. */
......@@ -1710,6 +1726,8 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) {
free(h_0);
}
cell_update_hydro_h_max(c, 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