From 61457add8acdf497a7e09e9cce91f93e1081f78f Mon Sep 17 00:00:00 2001 From: Pedro Gonnet <gonnet@google.com> Date: Tue, 18 Feb 2020 09:01:50 +0000 Subject: [PATCH] Store h_max values as floats in the `struct cell`, as the h values themselves are also just `float`s. --- src/cell.h | 30 +++++++++++++++--------------- src/runner_ghost.c | 6 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/cell.h b/src/cell.h index ebff1e5c20..b4242bf1f5 100644 --- a/src/cell.h +++ b/src/cell.h @@ -94,8 +94,11 @@ struct pcell { /*! Hydro variables */ struct { + /*! Number of #part in this cell. */ + int count; + /*! Maximal smoothing length. */ - double h_max; + float h_max; /*! Minimal integer end-of-timestep in this cell for hydro tasks */ integertime_t ti_end_min; @@ -109,9 +112,6 @@ struct pcell { /*! Integer time of the last drift of the #part in this cell */ integertime_t ti_old_part; - /*! Number of #part in this cell. */ - int count; - } hydro; /*! Gravity variables */ @@ -159,7 +159,7 @@ struct pcell { int count; /*! Maximal smoothing length. */ - double h_max; + float h_max; /*! Minimal integer end-of-timestep in this cell for stars tasks */ integertime_t ti_end_min; @@ -179,7 +179,7 @@ struct pcell { int count; /*! Maximal smoothing length. */ - double h_max; + float h_max; /*! Minimal integer end-of-timestep in this cell for black hole tasks */ integertime_t ti_end_min; @@ -386,9 +386,6 @@ struct cell { /*! Task for sorting the stars again after a SF event */ struct task *stars_resort; - /*! Max smoothing length in this cell. */ - double h_max; - /*! Last (integer) time the cell's part were drifted forward in time. */ integertime_t ti_old_part; @@ -405,6 +402,9 @@ struct cell { /*! Spin lock for various uses (#part case). */ swift_lock_type lock; + /*! Max smoothing length in this cell. */ + float h_max; + /*! Maximum part movement in this cell since last construction. */ float dx_max_part; @@ -569,9 +569,6 @@ struct cell { /*! Implicit tasks marking the exit of the stellar physics block of tasks */ struct task *stars_out; - /*! Max smoothing length in this cell. */ - double h_max; - /*! Last (integer) time the cell's spart were drifted forward in time. */ integertime_t ti_old_part; @@ -587,6 +584,9 @@ struct cell { /*! Nr of #spart this cell can hold after addition of new #spart. */ int count_total; + /*! Max smoothing length in this cell. */ + float h_max; + /*! Values of h_max before the drifts, used for sub-cell tasks. */ float h_max_old; @@ -678,9 +678,6 @@ struct cell { /*! Linked list of the tasks computing this cell's BH feedback. */ struct link *feedback; - /*! Max smoothing length in this cell. */ - double h_max; - /*! Last (integer) time the cell's bpart were drifted forward in time. */ integertime_t ti_old_part; @@ -693,6 +690,9 @@ struct cell { /*! Nr of #bpart this cell can hold after addition of new #bpart. */ int count_total; + /*! Max smoothing length in this cell. */ + float h_max; + /*! Values of h_max before the drifts, used for sub-cell tasks. */ float h_max_old; diff --git a/src/runner_ghost.c b/src/runner_ghost.c index e0e3f7239d..a1f38c9936 100644 --- a/src/runner_ghost.c +++ b/src/runner_ghost.c @@ -472,7 +472,7 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) { * Therefore we need to update h_max between the super- and top-levels */ if (c->stars.ghost) { for (struct cell *tmp = c->parent; tmp != NULL; tmp = tmp->parent) { - atomic_max_d(&tmp->stars.h_max, h_max); + atomic_max_f(&tmp->stars.h_max, h_max); } } @@ -783,7 +783,7 @@ void runner_do_black_holes_density_ghost(struct runner *r, struct cell *c, * Therefore we need to update h_max between the super- and top-levels */ if (c->black_holes.density_ghost) { for (struct cell *tmp = c->parent; tmp != NULL; tmp = tmp->parent) { - atomic_max_d(&tmp->black_holes.h_max, h_max); + atomic_max_f(&tmp->black_holes.h_max, h_max); } } @@ -1379,7 +1379,7 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) { * Therefore we need to update h_max between the super- and top-levels */ if (c->hydro.ghost) { for (struct cell *tmp = c->parent; tmp != NULL; tmp = tmp->parent) { - atomic_max_d(&tmp->hydro.h_max, h_max); + atomic_max_f(&tmp->hydro.h_max, h_max); } } -- GitLab