From 4fea70ea44d66f11bd372e10b8677fc1526da280 Mon Sep 17 00:00:00 2001 From: loikki <loic.hausammann@protonmail.ch> Date: Thu, 9 Apr 2020 09:49:17 +0200 Subject: [PATCH] GEAR: add error for hydro scheme not supported --- src/pressure_floor/GEAR/pressure_floor.h | 9 +++++++-- src/star_formation/GEAR/star_formation.h | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/pressure_floor/GEAR/pressure_floor.h b/src/pressure_floor/GEAR/pressure_floor.h index 00a026b4f3..642b36725a 100644 --- a/src/pressure_floor/GEAR/pressure_floor.h +++ b/src/pressure_floor/GEAR/pressure_floor.h @@ -70,7 +70,7 @@ __attribute__((always_inline)) static INLINE float pressure_floor_get_physical_pressure(const struct part* p, const float pressure_physical, const struct cosmology* cosmo) { - error("Not implemented"); + error("Not used."); return 0; } @@ -96,7 +96,12 @@ pressure_floor_get_comoving_pressure(const struct part* p, /* Compute the pressure floor */ float floor = kernel_gamma * kernel_gamma * p->h * p->h * rho * pressure_floor_props.constants * cosmo->a_inv; - floor -= p->pressure_floor_data.sigma2 * cosmo->a2_inv; + + /* Add the velocity dispersion */ + const float sigma2 = p->pressure_floor_data.sigma2 * cosmo->a2_inv; + if (sigma2 < floor) { + floor -= sigma2; + } floor *= a_coef * rho * hydro_one_over_gamma; return fmaxf(pressure_comoving, floor); diff --git a/src/star_formation/GEAR/star_formation.h b/src/star_formation/GEAR/star_formation.h index c9ab7432bc..83be20c50b 100644 --- a/src/star_formation/GEAR/star_formation.h +++ b/src/star_formation/GEAR/star_formation.h @@ -303,9 +303,14 @@ __attribute__((always_inline)) INLINE static void star_formation_end_density( #ifdef SPHENIX_SPH /* Copy the velocity divergence */ xp->sf_data.div_v = p->viscosity.div_v; -#else + /* SPHENIX is already including the Hubble flow */ +#elif GADGET_SPH /* Copy the velocity divergence */ xp->sf_data.div_v = p->density.div_v; + xp->sf_data.div_v += hydro_dimension * cosmo->H; +#else +#error This scheme is not implemented. Different scheme apply the Hubble flow \ + at different place. Be careful about it. #endif } -- GitLab