Skip to content
Snippets Groups Projects
Commit 3acb789f authored by James Willis's avatar James Willis
Browse files

Shuffle particles randomly after forming a cell.

parent 1828f66f
No related branches found
No related tags found
1 merge request!154Shuffle array
...@@ -31,14 +31,6 @@ enum velocity_types { ...@@ -31,14 +31,6 @@ enum velocity_types {
velocity_rotating 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 * @brief Constructs a cell and all of its particle in a valid state prior to
* a DOPAIR or DOSELF calcuation. * a DOPAIR or DOSELF calcuation.
...@@ -127,6 +119,8 @@ struct cell *make_cell(size_t n, double *offset, double size, double h, ...@@ -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_min = 1;
cell->ti_end_max = 1; cell->ti_end_max = 1;
shuffle_particles(cell->parts,cell->count);
cell->sorted = 0; cell->sorted = 0;
cell->sort = NULL; cell->sort = NULL;
cell->sortsize = 0; cell->sortsize = 0;
......
...@@ -24,13 +24,6 @@ ...@@ -24,13 +24,6 @@
#include <unistd.h> #include <unistd.h>
#include "swift.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: /* n is both particles per axis and box size:
* particles are generated on a mesh with unit spacing * 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, ...@@ -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_min = 1;
cell->ti_end_max = 1; cell->ti_end_max = 1;
shuffle_particles(cell->parts,cell->count);
cell->sorted = 0; cell->sorted = 0;
cell->sort = NULL; cell->sort = NULL;
cell->sortsize = 0; cell->sortsize = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment