From 09f6effd4e50a965c8402e5c5d5a1c4cf4058df0 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Mon, 25 Jul 2016 15:00:13 +0100 Subject: [PATCH] Don't move the entropy_dt variable into the force sub-structure --- src/hydro/Gadget2/hydro.h | 19 +++++++++---------- src/hydro/Gadget2/hydro_debug.h | 2 +- src/hydro/Gadget2/hydro_iact.h | 6 +++--- src/hydro/Gadget2/hydro_part.h | 8 ++++---- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/hydro/Gadget2/hydro.h b/src/hydro/Gadget2/hydro.h index c467970e34..e998fae3e6 100644 --- a/src/hydro/Gadget2/hydro.h +++ b/src/hydro/Gadget2/hydro.h @@ -139,9 +139,9 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force( const float abs_div_v = fabsf(p->density.div_v); /* Compute the pressure */ - const float dt = (ti_current - (p->ti_begin + p->ti_end) / 2) * timeBase; + const float half_dt = (ti_current - (p->ti_begin + p->ti_end) / 2) * timeBase; const float pressure = - (p->entropy + p->force.entropy_dt * dt) * pow_gamma(p->rho); + (p->entropy + p->entropy_dt * half_dt) * pow_gamma(p->rho); const float irho = 1.f / p->rho; @@ -178,7 +178,7 @@ __attribute__((always_inline)) INLINE static void hydro_reset_acceleration( p->a_hydro[2] = 0.0f; /* Reset the time derivatives. */ - p->force.entropy_dt = 0.0f; + p->entropy_dt = 0.0f; p->force.h_dt = 0.0f; /* Reset maximal signal velocity */ @@ -201,7 +201,7 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra( /* Drift the pressure */ const float dt_entr = (t1 - (p->ti_begin + p->ti_end) / 2) * timeBase; const float pressure = - (p->entropy + p->force.entropy_dt * dt_entr) * pow_gamma(p->rho); + (p->entropy + p->entropy_dt * dt_entr) * pow_gamma(p->rho); const float irho = 1.f / p->rho; @@ -228,8 +228,7 @@ __attribute__((always_inline)) INLINE static void hydro_end_force( p->force.h_dt *= p->h * 0.333333333f; - p->force.entropy_dt *= - hydro_gamma_minus_one * pow_minus_gamma_minus_one(p->rho); + p->entropy_dt *= hydro_gamma_minus_one * pow_minus_gamma_minus_one(p->rho); } /** @@ -245,15 +244,15 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra( float half_dt) { /* Do not decrease the entropy (temperature) by more than a factor of 2*/ - const float entropy_change = p->force.entropy_dt * dt; + const float entropy_change = p->entropy_dt * dt; if (entropy_change > -0.5f * p->entropy) p->entropy += entropy_change; else p->entropy *= 0.5f; /* Do not 'overcool' when timestep increases */ - if (p->entropy + 0.5f * p->force.entropy_dt * dt < 0.5f * p->entropy) - p->force.entropy_dt = -0.5f * p->entropy / dt; + if (p->entropy + 0.5f * p->entropy_dt * dt < 0.5f * p->entropy) + p->entropy_dt = -0.5f * p->entropy / dt; } /** @@ -279,7 +278,7 @@ __attribute__((always_inline)) INLINE static void hydro_convert_quantities( __attribute__((always_inline)) INLINE static float hydro_get_internal_energy( const struct part *restrict p, float dt) { - const float entropy = p->entropy + p->force.entropy_dt * dt; + const float entropy = p->entropy + p->entropy_dt * dt; return entropy * pow_gamma_minus_one(p->rho) * hydro_one_over_gamma_minus_one; } diff --git a/src/hydro/Gadget2/hydro_debug.h b/src/hydro/Gadget2/hydro_debug.h index ca36b5f105..5500fbff66 100644 --- a/src/hydro/Gadget2/hydro_debug.h +++ b/src/hydro/Gadget2/hydro_debug.h @@ -30,7 +30,7 @@ __attribute__((always_inline)) INLINE static void hydro_debug_particle( xp->v_full[1], xp->v_full[2], p->a_hydro[0], p->a_hydro[1], p->a_hydro[2], p->h, p->density.wcount, p->density.wcount_dh, p->mass, p->rho_dh, p->rho, p->force.P_over_rho2 * p->rho * p->rho / p->rho_dh, p->force.P_over_rho2, - p->entropy, p->force.entropy_dt, p->force.soundspeed, p->density.div_v, + p->entropy, p->entropy_dt, p->force.soundspeed, p->density.div_v, p->density.rot_v[0], p->density.rot_v[1], p->density.rot_v[2], p->force.balsara, p->force.v_sig, p->force.h_dt, p->ti_begin, p->ti_end); } diff --git a/src/hydro/Gadget2/hydro_iact.h b/src/hydro/Gadget2/hydro_iact.h index bcee12122d..2033e29604 100644 --- a/src/hydro/Gadget2/hydro_iact.h +++ b/src/hydro/Gadget2/hydro_iact.h @@ -469,8 +469,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_force( pj->force.v_sig = fmaxf(pj->force.v_sig, v_sig); /* Change in entropy */ - pi->force.entropy_dt += 0.5f * mj * visc_term * dvdr; - pj->force.entropy_dt -= 0.5f * mi * visc_term * dvdr; + pi->entropy_dt += 0.5f * mj * visc_term * dvdr; + pj->entropy_dt -= 0.5f * mi * visc_term * dvdr; } /** @@ -566,7 +566,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force( pi->force.v_sig = fmaxf(pi->force.v_sig, v_sig); /* Change in entropy */ - pi->force.entropy_dt += 0.5f * mj * visc_term * dvdr; + pi->entropy_dt += 0.5f * mj * visc_term * dvdr; } /** diff --git a/src/hydro/Gadget2/hydro_part.h b/src/hydro/Gadget2/hydro_part.h index 51f1625e0c..0cd830c51a 100644 --- a/src/hydro/Gadget2/hydro_part.h +++ b/src/hydro/Gadget2/hydro_part.h @@ -58,7 +58,10 @@ struct part { /* Particle entropy. */ float entropy; - /* Derivative of the density with respect to smoothing length. */ + /* Entropy time derivative */ + float entropy_dt; + + /* Derivative of the density with respect to smoothing length. */ float rho_dh; union { @@ -93,9 +96,6 @@ struct part { /* Signal velocity. */ float v_sig; - /* Entropy time derivative */ - float entropy_dt; - /* Time derivative of the smoothing length */ float h_dt; -- GitLab