From 3acb789f2aca0ae472e82e3d60ae482ca1fea13b Mon Sep 17 00:00:00 2001
From: James Willis <james.s.willis@durham.ac.uk>
Date: Mon, 25 Apr 2016 16:29:07 +0100
Subject: [PATCH] Shuffle particles randomly after forming a cell.

---
 tests/test27cells.c | 10 ++--------
 tests/testPair.c    |  9 ++-------
 2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/tests/test27cells.c b/tests/test27cells.c
index 7915511eed..2c7beb85c3 100644
--- a/tests/test27cells.c
+++ b/tests/test27cells.c
@@ -31,14 +31,6 @@ enum velocity_types {
   velocity_rotating
 };
 
-/**
- * @brief Returns a random number (uniformly distributed) in [a,b[
- */
-double random_uniform(double a, double b) {
-  return (rand() / (double)RAND_MAX) * (b - a) + a;
-}
-
-
 /**
  * @brief Constructs a cell and all of its particle in a valid state prior to
  * a DOPAIR or DOSELF calcuation.
@@ -127,6 +119,8 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
   cell->ti_end_min = 1;
   cell->ti_end_max = 1;
 
+  shuffle_particles(cell->parts,cell->count);
+
   cell->sorted = 0;
   cell->sort = NULL;
   cell->sortsize = 0;
diff --git a/tests/testPair.c b/tests/testPair.c
index 6e46b577ca..083ccf4971 100644
--- a/tests/testPair.c
+++ b/tests/testPair.c
@@ -24,13 +24,6 @@
 #include <unistd.h>
 #include "swift.h"
 
-/**
- * Returns a random number (uniformly distributed) in [a,b[
- */
-double random_uniform(double a, double b) {
-  return (rand() / (double)RAND_MAX) * (b - a) + a;
-}
-
 /* n is both particles per axis and box size:
  * particles are generated on a mesh with unit spacing
  */
@@ -93,6 +86,8 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
   cell->ti_end_min = 1;
   cell->ti_end_max = 1;
 
+  shuffle_particles(cell->parts,cell->count);
+
   cell->sorted = 0;
   cell->sort = NULL;
   cell->sortsize = 0;
-- 
GitLab