From 9ff194f4bf4f968a35e7dae6cb8cc934a33d9a82 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Sun, 11 Mar 2018 17:43:26 +0900
Subject: [PATCH] When converting internal energy to entropy at startup, apply
 the correct cosmology factor.

---
 src/cell.c  | 17 -----------------
 src/cell.h  |  1 -
 src/space.c |  3 ++-
 3 files changed, 2 insertions(+), 19 deletions(-)

diff --git a/src/cell.c b/src/cell.c
index b415cc077b..ea036c9708 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -1081,23 +1081,6 @@ void cell_sanitize(struct cell *c, int treated) {
   c->h_max = h_max;
 }
 
-/**
- * @brief Converts hydro quantities to a valid state after the initial density
- * calculation
- *
- * @param c Cell to act upon
- * @param data Unused parameter
- */
-void cell_convert_hydro(struct cell *c, void *data) {
-
-  struct part *p = c->parts;
-  struct xpart *xp = c->xparts;
-
-  for (int i = 0; i < c->count; ++i) {
-    hydro_convert_quantities(&p[i], &xp[i]);
-  }
-}
-
 /**
  * @brief Cleans the links in a given cell.
  *
diff --git a/src/cell.h b/src/cell.h
index 91663d45bf..87af742baf 100644
--- a/src/cell.h
+++ b/src/cell.h
@@ -492,7 +492,6 @@ int cell_getsize(struct cell *c);
 int cell_link_parts(struct cell *c, struct part *parts);
 int cell_link_gparts(struct cell *c, struct gpart *gparts);
 int cell_link_sparts(struct cell *c, struct spart *sparts);
-void cell_convert_hydro(struct cell *c, void *data);
 void cell_clean_links(struct cell *c, void *data);
 void cell_make_multipoles(struct cell *c, integertime_t ti_current);
 void cell_check_multipole(struct cell *c, void *data);
diff --git a/src/space.c b/src/space.c
index 5309486e26..e4055f4d10 100644
--- a/src/space.c
+++ b/src/space.c
@@ -2813,11 +2813,12 @@ void space_init_gparts(struct space *s, int verbose) {
 void space_convert_quantities_mapper(void *restrict map_data, int count,
                                      void *restrict extra_data) {
   struct space *s = (struct space *)extra_data;
+  const struct cosmology *cosmo = s->e->cosmology;
   struct part *restrict parts = (struct part *)map_data;
   const ptrdiff_t index = parts - s->parts;
   struct xpart *restrict xparts = s->xparts + index;
   for (int k = 0; k < count; k++)
-    hydro_convert_quantities(&parts[k], &xparts[k]);
+    hydro_convert_quantities(&parts[k], &xparts[k], cosmo);
 }
 
 /**
-- 
GitLab