From f931752189ddf4f03cb0eabfd6fb25277a80e271 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Sat, 13 May 2017 13:34:44 +0100
Subject: [PATCH] No limit on h in test125cells. Add more digits to the output.
 Perturbed version of the test125cells now works.

---
 .gitignore                                    |  2 ++
 tests/test125cells.c                          | 19 ++++++++++---------
 tests/test125cells.sh.in                      |  2 +-
 tests/testKernel.c                            |  6 +++---
 ...rance_125.dat => tolerance_125_normal.dat} |  0
 tests/tolerance_125_perturbed.dat             |  3 +++
 6 files changed, 19 insertions(+), 13 deletions(-)
 rename tests/{tolerance_125.dat => tolerance_125_normal.dat} (100%)
 create mode 100644 tests/tolerance_125_perturbed.dat

diff --git a/.gitignore b/.gitignore
index a9138619c1..28a830818a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,6 +47,8 @@ tests/brute_force_27_perturbed.dat
 tests/swift_dopair_27_perturbed.dat
 tests/brute_force_125_standard.dat
 tests/swift_dopair_125_standard.dat
+tests/brute_force_125_perturbed.dat
+tests/swift_dopair_125_perturbed.dat
 tests/testGreetings
 tests/testReading
 tests/input.hdf5
diff --git a/tests/test125cells.c b/tests/test125cells.c
index bd7409333b..963b89b45e 100644
--- a/tests/test125cells.c
+++ b/tests/test125cells.c
@@ -374,7 +374,7 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
   /* Write header */
   fprintf(file,
           "# %4s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %13s %13s "
-          "%13s %8s %8s %8s %8s\n",
+          "%13s %13s %13s %8s %8s\n",
           "ID", "pos_x", "pos_y", "pos_z", "v_x", "v_y", "v_z", "h", "rho",
           "div_v", "S", "u", "P", "c", "a_x", "a_y", "a_z", "h_dt", "v_sig",
           "dS/dt", "du/dt");
@@ -386,7 +386,7 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
     fprintf(file,
             "%6llu %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f "
             "%8.5f "
-            "%8.5f %8.5f %13e %13e %13e %8.5f %8.5f %8.5f %8.5f\n",
+            "%8.5f %8.5f %13e %13e %13e %13e %13e %8.5f %8.5f\n",
             main_cell->parts[pid].id, main_cell->parts[pid].x[0],
             main_cell->parts[pid].x[1], main_cell->parts[pid].x[2],
             main_cell->parts[pid].v[0], main_cell->parts[pid].v[1],
@@ -425,7 +425,7 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
       fprintf(file,
               "%6llu %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f "
               "%8.5f %8.5f "
-              "%8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f\n",
+              "%8.5f %8.5f %13f %13f %13f %13f %13f %8.5f %8.5f\n",
               solution[pid].id, solution[pid].x[0], solution[pid].x[1],
               solution[pid].x[2], solution[pid].v[0], solution[pid].v[1],
               solution[pid].v[2], solution[pid].h, solution[pid].rho,
@@ -559,7 +559,8 @@ int main(int argc, char *argv[]) {
 
   struct hydro_props hp;
   hp.target_neighbours = pow_dimension(h) * kernel_norm;
-  hp.delta_neighbours = 2.;
+  hp.delta_neighbours = 4.;
+  hp.h_max = FLT_MAX;
   hp.max_smoothing_iterations = 1;
   hp.CFL_condition = 0.1;
 
@@ -589,8 +590,8 @@ int main(int argc, char *argv[]) {
         const double offset[3] = {i * size, j * size, k * size};
 
         /* Construct it */
-        cells[i * 25 + j * 5 + k] =
-            make_cell(particles, offset, size, h, rho, &partId, perturbation, vel, press);
+        cells[i * 25 + j * 5 + k] = make_cell(
+            particles, offset, size, h, rho, &partId, perturbation, vel, press);
 
         /* Store the inner cells */
         if (i > 0 && i < 4 && j > 0 && j < 4 && k > 0 && k < 4) {
@@ -618,7 +619,7 @@ int main(int argc, char *argv[]) {
     /* Initialise the particles */
     for (int j = 0; j < 125; ++j)
       runner_do_drift_particles(&runner, cells[j], 0);
-    
+
     /* Reset particles. */
     for (int i = 0; i < 125; ++i) {
       for (int n = 0; n < cells[i]->count; ++n)
@@ -702,13 +703,13 @@ int main(int argc, char *argv[]) {
     }
   }
 
-  //for (size_t n = 0; n < 100*runs; ++n) {
+  // for (size_t n = 0; n < 100*runs; ++n) {
   //  ticks self_tic = getticks();
 
   //  DOSELF2(&runner, main_cell);
 
   //  self_force_time += getticks() - self_tic;
-  //  
+  //
   //}
 
   /* Output timing */
diff --git a/tests/test125cells.sh.in b/tests/test125cells.sh.in
index 1d3b0db75d..dbaf6ebd59 100755
--- a/tests/test125cells.sh.in
+++ b/tests/test125cells.sh.in
@@ -11,7 +11,7 @@ do
 
 	if [ -e brute_force_125_standard.dat ]
 	then
-	    python @srcdir@/difffloat.py brute_force_125_standard.dat swift_dopair_125_standard.dat @srcdir@/tolerance_125.dat 6
+	    python @srcdir@/difffloat.py brute_force_125_standard.dat swift_dopair_125_standard.dat @srcdir@/tolerance_125_normal.dat 6
 	else
 	    exit 1
         fi
diff --git a/tests/testKernel.c b/tests/testKernel.c
index 0f627675cb..a2744119a5 100644
--- a/tests/testKernel.c
+++ b/tests/testKernel.c
@@ -91,7 +91,7 @@ int main() {
 
   printf("\nVector Output for kernel_deval_2_vec\n");
   printf("-------------\n");
-  
+
   /* Test vectorised kernel that uses two vectors. */
   for (int i = 0; i < numPoints; i += VEC_SIZE) {
 
@@ -100,7 +100,7 @@ int main() {
 
     vector vx_2, vx_h_2;
     vector W_vec_2, dW_vec_2;
-    
+
     for (int j = 0; j < VEC_SIZE; j++) {
       vx.f[j] = (i + j) * 2.25f / numPoints;
       vx_2.f[j] = (i + j) * 2.25f / numPoints;
@@ -127,7 +127,7 @@ int main() {
         return 1;
       }
     }
-    
+
     /* Check second vector results. */
     for (int j = 0; j < VEC_SIZE; j++) {
       printf("%2d: h= %f H= %f x=%f W(x,h)=%f dW(x,h)=%f\n", i + j, h,
diff --git a/tests/tolerance_125.dat b/tests/tolerance_125_normal.dat
similarity index 100%
rename from tests/tolerance_125.dat
rename to tests/tolerance_125_normal.dat
diff --git a/tests/tolerance_125_perturbed.dat b/tests/tolerance_125_perturbed.dat
new file mode 100644
index 0000000000..c9ad23d447
--- /dev/null
+++ b/tests/tolerance_125_perturbed.dat
@@ -0,0 +1,3 @@
+#   ID    pos_x    pos_y    pos_z      v_x      v_y      v_z        h      rho    div_v        S        u        P        c      a_x      a_y      a_z     h_dt    v_sig    dS/dt    du/dt
+    0	  1e-4	   1e-4	    1e-4       1e-4	1e-4	 1e-4	    1e-4   1e-4	  1e-4	       1e-4	1e-4	 1e-4	  1e-4	 1e-4	  1e-4	   1e-4	   1e-4	   1e-4	    1e-4     1e-4
+    0	  1e-4	   1e-4	    1e-4       1e-4	1e-4	 1e-4	    1e-4   1e-4	  1e-4	       1e-4	1e-4	 1e-4	  1e-4	 1e-4	  1e-4	   1e-4	   1e-4	   1e-4	    1e-4     1e-4
-- 
GitLab