From b7869d73e7bf43b3538079066fa82f93d26af68f Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Sun, 14 Feb 2016 12:57:44 +0000 Subject: [PATCH] New interface for kick_extra --- src/hydro/Default/hydro.h | 5 +++-- src/hydro/Gadget2/hydro.h | 7 ++++++- src/hydro/Minimal/hydro.h | 12 +++++++++++- src/runner.c | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/hydro/Default/hydro.h b/src/hydro/Default/hydro.h index aefd85cf6e..a7e7e18512 100644 --- a/src/hydro/Default/hydro.h +++ b/src/hydro/Default/hydro.h @@ -194,14 +194,15 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra( __attribute__((always_inline)) INLINE static void hydro_end_force(struct part* p) {} + + /** * @brief Kick the additional variables * * @param p The particle to act upon - * @param dt The time-step for this kick */ __attribute__((always_inline)) - INLINE static void hydro_kick_extra(struct part* p, float dt) {} + INLINE static void hydro_kick_extra(struct part* p, float dt) {} /** * @brief Converts hydro quantity of a particle diff --git a/src/hydro/Gadget2/hydro.h b/src/hydro/Gadget2/hydro.h index 7a8518a010..b1f83be3b3 100644 --- a/src/hydro/Gadget2/hydro.h +++ b/src/hydro/Gadget2/hydro.h @@ -190,13 +190,18 @@ __attribute__((always_inline)) (const_hydro_gamma - 1.f) * powf(p->rho, -(const_hydro_gamma - 1.f)); } + /** * @brief Kick the additional variables * * @param p The particle to act upon + * @param xp The particle extended data to act upon + * @param dt The time-step for this kick + * @param half_dt The half time-step for this kick */ __attribute__((always_inline)) - INLINE static void hydro_kick_extra(struct part* p, float dt) { + INLINE static void hydro_kick_extra(struct part* p, struct xpart* xp, + float dt, float half_dt) { /* Do not decrease the entropy (temperature) by more than a factor of 2*/ const float entropy_change = p->entropy_dt * dt; diff --git a/src/hydro/Minimal/hydro.h b/src/hydro/Minimal/hydro.h index 4543b18aab..464a03a7ed 100644 --- a/src/hydro/Minimal/hydro.h +++ b/src/hydro/Minimal/hydro.h @@ -156,10 +156,20 @@ __attribute__((always_inline)) * @brief Kick the additional variables * * @param p The particle to act upon + * @param xp The particle extended data to act upon * @param dt The time-step for this kick + * @param half_dt The half time-step for this kick */ __attribute__((always_inline)) - INLINE static void hydro_kick_extra(struct part* p, float dt) {} + INLINE static void hydro_kick_extra(struct part* p, struct xpart* xp, + float dt, float half_dt) { + + /* Kick in momentum space */ + xp->u_full += p->u_dt * dt; + + /* Get the predicted internal energy */ + p->u = xp->u_full - half_dt * p->u_dt; +} /** * @brief Converts hydro quantity of a particle diff --git a/src/runner.c b/src/runner.c index 84bb73debc..fc17e7d3d9 100644 --- a/src/runner.c +++ b/src/runner.c @@ -930,7 +930,7 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) { /* p->v[2]); */ /* Extra kick work */ - hydro_kick_extra(p, dt); + hydro_kick_extra(p, xp, dt, half_dt); } /* Now collect quantities for statistics */ -- GitLab