Skip to content
Snippets Groups Projects
Commit 5218a5a4 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Include self-gravity and external gravity in time-step calculation

parent 88308011
No related branches found
No related tags found
No related merge requests found
...@@ -70,14 +70,15 @@ make_integer_timestep(float new_dt, timebin_t old_bin, integertime_t ti_current, ...@@ -70,14 +70,15 @@ make_integer_timestep(float new_dt, timebin_t old_bin, integertime_t ti_current,
__attribute__((always_inline)) INLINE static integertime_t get_gpart_timestep( __attribute__((always_inline)) INLINE static integertime_t get_gpart_timestep(
const struct gpart *restrict gp, const struct engine *restrict e) { const struct gpart *restrict gp, const struct engine *restrict e) {
const float new_dt_external = external_gravity_timestep( float new_dt = FLT_MAX;
e->time, e->external_potential, e->physical_constants, gp);
/* const float new_dt_self = */ if (e->policy & engine_policy_external_gravity)
/* gravity_compute_timestep_self(e->physical_constants, gp); */ new_dt =
const float new_dt_self = FLT_MAX; // MATTHIEU min(new_dt, external_gravity_timestep(e->time, e->external_potential,
e->physical_constants, gp));
float new_dt = min(new_dt_external, new_dt_self); if (e->policy & engine_policy_self_gravity)
new_dt = min(new_dt, gravity_compute_timestep_self(gp));
/* Limit timestep within the allowed range */ /* Limit timestep within the allowed range */
new_dt = min(new_dt, e->dt_max); new_dt = min(new_dt, e->dt_max);
...@@ -114,14 +115,13 @@ __attribute__((always_inline)) INLINE static integertime_t get_part_timestep( ...@@ -114,14 +115,13 @@ __attribute__((always_inline)) INLINE static integertime_t get_part_timestep(
float new_dt_grav = FLT_MAX; float new_dt_grav = FLT_MAX;
if (p->gpart != NULL) { if (p->gpart != NULL) {
const float new_dt_external = external_gravity_timestep( if (e->policy & engine_policy_external_gravity)
e->time, e->external_potential, e->physical_constants, p->gpart); new_dt_grav = min(new_dt_grav, external_gravity_timestep(
e->time, e->external_potential,
e->physical_constants, p->gpart));
/* const float new_dt_self = */ if (e->policy & engine_policy_self_gravity)
/* gravity_compute_timestep_self(e->physical_constants, p->gpart); */ new_dt_grav = min(new_dt_grav, gravity_compute_timestep_self(p->gpart));
const float new_dt_self = FLT_MAX; // MATTHIEU
new_dt_grav = min(new_dt_external, new_dt_self);
} }
/* Final time-step is minimum of hydro and gravity */ /* Final time-step is minimum of hydro and gravity */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment