From dcaace6cfc7fd0896b6bc85cac6d0c6691fd3ae0 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Wed, 1 Feb 2017 14:13:34 +0000
Subject: [PATCH] Same rule for the other hydro schemes.

---
 src/hydro/Minimal/hydro.h         | 2 +-
 src/hydro/PressureEntropy/hydro.h | 2 +-
 src/runner_doiact.h               | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/hydro/Minimal/hydro.h b/src/hydro/Minimal/hydro.h
index a434372c4f..20856b7e03 100644
--- a/src/hydro/Minimal/hydro.h
+++ b/src/hydro/Minimal/hydro.h
@@ -360,7 +360,7 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra(
     struct part *restrict p, struct xpart *restrict xp, float dt) {
 
   /* Do not decrease the energy by more than a factor of 2*/
-  if (p->u_dt < -0.5f * xp->u_full / dt) {
+  if (dt > 0. && p->u_dt * dt < -0.5f * xp->u_full) {
     p->u_dt = -0.5f * xp->u_full / dt;
   }
   xp->u_full += p->u_dt * dt;
diff --git a/src/hydro/PressureEntropy/hydro.h b/src/hydro/PressureEntropy/hydro.h
index 3e6c19abde..f22bb8a13a 100644
--- a/src/hydro/PressureEntropy/hydro.h
+++ b/src/hydro/PressureEntropy/hydro.h
@@ -394,7 +394,7 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra(
     struct part *restrict p, struct xpart *restrict xp, float dt) {
 
   /* Do not decrease the entropy (temperature) by more than a factor of 2*/
-  if (p->entropy_dt < -0.5f * xp->entropy_full / dt) {
+  if (dt > 0. && p->entropy_dt * dt < -0.5f * xp->entropy_full) {
     p->entropy_dt = -0.5f * xp->entropy_full / dt;
   }
   xp->entropy_full += p->entropy_dt * dt;
diff --git a/src/runner_doiact.h b/src/runner_doiact.h
index b27c8bc241..7b40343954 100644
--- a/src/runner_doiact.h
+++ b/src/runner_doiact.h
@@ -2080,7 +2080,8 @@ void DOSUB_SELF1(struct runner *r, struct cell *ci, int gettimer) {
 
   /* Otherwise, compute self-interaction. */
   else {
-#if (DOSELF1 == runner_doself1_density) && defined(WITH_VECTORIZATION) && defined(GADGET2_SPH)
+#if (DOSELF1 == runner_doself1_density) && defined(WITH_VECTORIZATION) && \
+    defined(GADGET2_SPH)
     runner_doself1_density_vec(r, ci);
 #else
     DOSELF1(r, ci);
-- 
GitLab