From ccdc8b06547d2e00a17737c00f73e6ec8cb87d25 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Wed, 7 Sep 2016 14:47:50 +0100
Subject: [PATCH] Pass a pointer to the xpart to the cool_part() function.

---
 src/const.h                        | 4 ++--
 src/cooling/const_du/cooling.h     | 2 +-
 src/cooling/const_lambda/cooling.h | 2 +-
 src/cooling/none/cooling.h         | 2 +-
 src/runner.c                       | 4 +++-
 5 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/const.h b/src/const.h
index 1082bccc0b..b8b8434cc5 100644
--- a/src/const.h
+++ b/src/const.h
@@ -95,8 +95,8 @@
 //#define EXTERNAL_POTENTIAL_DISK_PATCH
 
 /* Cooling properties */
-#define COOLING_NONE
-//#define COOLING_CONST_DU
+//#define COOLING_NONE
+#define COOLING_CONST_DU
 //#define COOLING_CONST_LAMBDA
 //#define COOLING_GRACKLE
 
diff --git a/src/cooling/const_du/cooling.h b/src/cooling/const_du/cooling.h
index 2d3ff5bcc6..f6fce4f1c1 100644
--- a/src/cooling/const_du/cooling.h
+++ b/src/cooling/const_du/cooling.h
@@ -59,7 +59,7 @@ __attribute__((always_inline)) INLINE static void cooling_cool_part(
     const struct phys_const* restrict phys_const,
     const struct UnitSystem* restrict us,
     const struct cooling_function_data* restrict cooling,
-    struct part* restrict p, float dt) {
+    struct part* restrict p, struct xpart* restrict xp, float dt) {
 
   /* Get current internal energy (dt=0) */
   const float u_old = hydro_get_internal_energy(p, 0.f);
diff --git a/src/cooling/const_lambda/cooling.h b/src/cooling/const_lambda/cooling.h
index 9f149915d0..19921537a7 100644
--- a/src/cooling/const_lambda/cooling.h
+++ b/src/cooling/const_lambda/cooling.h
@@ -86,7 +86,7 @@ __attribute__((always_inline)) INLINE static void cooling_cool_part(
     const struct phys_const* restrict phys_const,
     const struct UnitSystem* restrict us,
     const struct cooling_function_data* restrict cooling,
-    struct part* restrict p, float dt) {
+    struct part* restrict p, struct xpart* restrict xp, float dt) {
 
   /* Get current internal energy (dt=0) */
   const float u_old = hydro_get_internal_energy(p, 0.f);
diff --git a/src/cooling/none/cooling.h b/src/cooling/none/cooling.h
index 535fdd5b19..4fc9c6e1c5 100644
--- a/src/cooling/none/cooling.h
+++ b/src/cooling/none/cooling.h
@@ -51,7 +51,7 @@ __attribute__((always_inline)) INLINE static void cooling_cool_part(
     const struct phys_const* restrict phys_const,
     const struct UnitSystem* restrict us,
     const struct cooling_function_data* restrict cooling,
-    struct part* restrict p, float dt) {}
+    struct part* restrict p, struct xpart* restrict xp, float dt) {}
 
 /**
  * @brief Computes the cooling time-step.
diff --git a/src/runner.c b/src/runner.c
index 7712d0ca76..eb2605915c 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -170,6 +170,7 @@ void runner_do_grav_external(struct runner *r, struct cell *c, int timer) {
 void runner_do_cooling(struct runner *r, struct cell *c, int timer) {
 
   struct part *restrict parts = c->parts;
+  struct xpart *restrict xparts = c->xparts;
   const int count = c->count;
   const int ti_current = r->e->ti_current;
   const struct cooling_function_data *cooling_func = r->e->cooling_func;
@@ -195,13 +196,14 @@ void runner_do_cooling(struct runner *r, struct cell *c, int timer) {
 
     /* Get a direct pointer on the part. */
     struct part *restrict p = &parts[i];
+    struct xpart *restrict xp = &xparts[i];
 
     /* Kick has already updated ti_end, so need to check ti_begin */
     if (p->ti_begin == ti_current) {
 
       const double dt = (p->ti_end - p->ti_begin) * timeBase;
 
-      cooling_cool_part(constants, us, cooling_func, p, dt);
+      cooling_cool_part(constants, us, cooling_func, p, xp, dt);
     }
   }
 
-- 
GitLab