From e611cd83092ce21e6eae5ff3635832c1f3dff56e Mon Sep 17 00:00:00 2001
From: Bert Vandenbroucke <bert.vandenbroucke@gmail.com>
Date: Fri, 10 Mar 2017 12:03:11 +0000
Subject: [PATCH] 3D SHADOWFAX_SPH compiles again (but does not really work).
 Re-introduced global variables to store the box size.

---
 examples/main.c               | 25 +++++++++++++++++++++++++
 tests/benchmarkInteractions.c |  4 ++++
 tests/test125cells.c          |  4 ++++
 tests/test27cells.c           |  6 +++++-
 tests/testPair.c              |  6 +++++-
 tests/testSymmetry.c          |  8 ++++----
 tests/testTimeIntegration.c   |  2 +-
 tests/testVoronoi3D.c         |  4 ++--
 8 files changed, 50 insertions(+), 9 deletions(-)

diff --git a/examples/main.c b/examples/main.c
index b687ab1826..39b2e3a757 100644
--- a/examples/main.c
+++ b/examples/main.c
@@ -101,6 +101,10 @@ void print_help_message() {
       "parameter file.\n");
 }
 
+#if defined(SHADOWFAX_SPH) && defined(HYDRO_DIMENSION_3D)
+VORONOI3D_DECLARE_GLOBAL_VARIABLES()
+#endif
+
 /**
  * @brief Main routine that loads a few particles and generates some output.
  *
@@ -435,6 +439,27 @@ int main(int argc, char *argv[]) {
     fflush(stdout);
   }
 
+#if defined(SHADOWFAX_SPH) && defined(HYDRO_DIMENSION_3D)
+  /* set the *global* box dimensions */
+  float box_anchor[3], box_side[3];
+  if (periodic) {
+    box_anchor[0] = -0.5f * dim[0];
+    box_anchor[1] = -0.5f * dim[1];
+    box_anchor[2] = -0.5f * dim[2];
+    box_side[0] = 2.0f * dim[0];
+    box_side[1] = 2.0f * dim[1];
+    box_side[2] = 2.0f * dim[2];
+  } else {
+    box_anchor[0] = 0.0f;
+    box_anchor[1] = 0.0f;
+    box_anchor[2] = 0.0f;
+    box_side[0] = dim[0];
+    box_side[1] = dim[1];
+    box_side[2] = dim[2];
+  }
+  voronoi_set_box(box_anchor, box_side);
+#endif
+
 #ifdef SWIFT_DEBUG_CHECKS
   /* Check once and for all that we don't have unwanted links */
   if (!with_stars) {
diff --git a/tests/benchmarkInteractions.c b/tests/benchmarkInteractions.c
index 0f5b3d2eb2..da22b37f1d 100644
--- a/tests/benchmarkInteractions.c
+++ b/tests/benchmarkInteractions.c
@@ -450,6 +450,10 @@ void test_interactions(struct part test_part, struct part *parts, size_t count,
 #endif
 }
 
+#if defined(SHADOWFAX_SPH) && defined(HYDRO_DIMENSION_3D)
+VORONOI3D_DECLARE_GLOBAL_VARIABLES()
+#endif
+
 /* And go... */
 int main(int argc, char *argv[]) {
   size_t runs = 10000;
diff --git a/tests/test125cells.c b/tests/test125cells.c
index 21fc3f5407..6e8a3fd206 100644
--- a/tests/test125cells.c
+++ b/tests/test125cells.c
@@ -422,6 +422,10 @@ void runner_doself1_density(struct runner *r, struct cell *ci);
 void runner_dopair2_force(struct runner *r, struct cell *ci, struct cell *cj);
 void runner_doself2_force(struct runner *r, struct cell *ci);
 
+#if defined(SHADOWFAX_SPH) && defined(HYDRO_DIMENSION_3D)
+VORONOI3D_DECLARE_GLOBAL_VARIABLES()
+#endif
+
 /* And go... */
 int main(int argc, char *argv[]) {
 
diff --git a/tests/test27cells.c b/tests/test27cells.c
index 5ef78c9509..5cf7d7cdc8 100644
--- a/tests/test27cells.c
+++ b/tests/test27cells.c
@@ -117,7 +117,7 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
         part->h = size * h / (float)n;
         part->id = ++(*partId);
 
-#ifdef GIZMO_SPH
+#if defined(GIZMO_SPH) || defined(SHADOWFAX_SPH)
         part->conserved.mass = density * volume / count;
         voronoi_cell_init(&part->cell, part->x);
 #else
@@ -299,6 +299,10 @@ void runner_dopair1_density(struct runner *r, struct cell *ci, struct cell *cj);
 void runner_doself1_density(struct runner *r, struct cell *ci);
 void runner_doself1_density_vec(struct runner *r, struct cell *ci);
 
+#if defined(SHADOWFAX_SPH) && defined(HYDRO_DIMENSION_3D)
+VORONOI3D_DECLARE_GLOBAL_VARIABLES()
+#endif
+
 /* And go... */
 int main(int argc, char *argv[]) {
 
diff --git a/tests/testPair.c b/tests/testPair.c
index 6f6e36f2d6..bbcc17e61f 100644
--- a/tests/testPair.c
+++ b/tests/testPair.c
@@ -63,7 +63,7 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
         part->v[2] = random_uniform(-0.05, 0.05);
         part->h = size * h / (float)n;
         part->id = ++(*partId);
-#ifdef GIZMO_SPH
+#if defined(GIZMO_SPH) || defined(SHADOWFAX_SPH)
         part->conserved.mass = density * volume / count;
 #else
         part->mass = density * volume / count;
@@ -187,6 +187,10 @@ void dump_particle_fields(char *fileName, struct cell *ci, struct cell *cj) {
 /* Just a forward declaration... */
 void runner_dopair1_density(struct runner *r, struct cell *ci, struct cell *cj);
 
+#if defined(SHADOWFAX_SPH) && defined(HYDRO_DIMENSION_3D)
+VORONOI3D_DECLARE_GLOBAL_VARIABLES()
+#endif
+
 int main(int argc, char *argv[]) {
   size_t particles = 0, runs = 0, volume, type = 0;
   double offset[3] = {0, 0, 0}, h = 1.1255, size = 1., rho = 1.;
diff --git a/tests/testSymmetry.c b/tests/testSymmetry.c
index 9a94b28a1f..850e5aee2b 100644
--- a/tests/testSymmetry.c
+++ b/tests/testSymmetry.c
@@ -26,7 +26,7 @@
 
 #include "swift.h"
 
-#if defined(SHADOWSWIFT) && defined(HYDRO_DIMENSION_3D)
+#if defined(SHADOWFAX_SPH) && defined(HYDRO_DIMENSION_3D)
 VORONOI3D_DECLARE_GLOBAL_VARIABLES()
 #endif
 
@@ -35,7 +35,7 @@ int main(int argc, char *argv[]) {
   /* Choke if need be */
   feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
 
-#if defined(SHADOWSWIFT) && defined(HYDRO_DIMENSION_3D)
+#if defined(SHADOWFAX_SPH) && defined(HYDRO_DIMENSION_3D)
   /* Initialize the Voronoi simulation box */
   float box_anchor[3] = {-2.0f, -2.0f, -2.0f};
   float box_side[3] = {6.0f, 6.0f, 6.0f};
@@ -57,7 +57,7 @@ int main(int argc, char *argv[]) {
   pi.id = 1;
   pj.id = 2;
 
-#if defined(GIZMO_SPH) || defined(SHADOWSWIFT)
+#if defined(GIZMO_SPH) || defined(SHADOWFAX_SPH)
   /* Give the primitive variables sensible values, since the Riemann solver does
      not like negative densities and pressures */
   pi.primitives.rho = random_uniform(0.1f, 1.0f);
@@ -105,7 +105,7 @@ int main(int argc, char *argv[]) {
   pi.force.dt = 0.001;
   pj.force.dt = 0.001;
 
-#ifdef SHADOWSWIFT
+#ifdef SHADOWFAX_SPH
   voronoi_cell_init(&pi.cell, pi.x);
   voronoi_cell_init(&pj.cell, pj.x);
 #endif
diff --git a/tests/testTimeIntegration.c b/tests/testTimeIntegration.c
index 9ef4c963b0..6ce59eccc6 100644
--- a/tests/testTimeIntegration.c
+++ b/tests/testTimeIntegration.c
@@ -22,7 +22,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#if defined(SHADOWSWIFT) && defined(HYDRO_DIMENSION_3D)
+#if defined(SHADOWFAX_SPH) && defined(HYDRO_DIMENSION_3D)
 VORONOI3D_DECLARE_GLOBAL_VARIABLES()
 #endif
 
diff --git a/tests/testVoronoi3D.c b/tests/testVoronoi3D.c
index fc66f66e67..a1ff127c6b 100644
--- a/tests/testVoronoi3D.c
+++ b/tests/testVoronoi3D.c
@@ -1113,7 +1113,7 @@ void test_paths() {
   }
 }
 
-#ifdef SHADOWSWIFT
+#ifdef SHADOWFAX_SPH
 void set_coordinates(struct part *p, double x, double y, double z,
                      unsigned int id) {
   p->x[0] = x;
@@ -1125,7 +1125,7 @@ void set_coordinates(struct part *p, double x, double y, double z,
 #endif
 
 void test_degeneracies() {
-#ifdef SHADOWSWIFT
+#ifdef SHADOWFAX_SPH
   int idx = 0;
   /* make a small cube */
   struct part particles[100];
-- 
GitLab