summaryrefslogtreecommitdiff
path: root/src/randfuncs.c
diff options
context:
space:
mode:
authorpants <jaron@kent-dobias.com>2016-08-31 11:57:40 -0400
committerpants <jaron@kent-dobias.com>2016-08-31 11:57:40 -0400
commit0f6782c9e5a9171d69d8e62dff33a558ba542d58 (patch)
tree79ebe235b2c9fb957946428e87d2629f07dfde10 /src/randfuncs.c
parentc2164e4a38b79c8a02bd7c0f4481f222c7b4dae6 (diff)
downloadfuse_networks-0f6782c9e5a9171d69d8e62dff33a558ba542d58.tar.gz
fuse_networks-0f6782c9e5a9171d69d8e62dff33a558ba542d58.tar.bz2
fuse_networks-0f6782c9e5a9171d69d8e62dff33a558ba542d58.zip
did some refactoring
Diffstat (limited to 'src/randfuncs.c')
-rw-r--r--src/randfuncs.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/randfuncs.c b/src/randfuncs.c
index 260c047..35b9f56 100644
--- a/src/randfuncs.c
+++ b/src/randfuncs.c
@@ -1,7 +1,7 @@
#include "fracture.h"
-double *genfunc_uniform(unsigned int L, gsl_rng *r, unsigned int *num) {
+double *genfunc_uniform(unsigned int L, bound_t boundary, gsl_rng *r, unsigned int *num) {
*num = pow(L / 2 + 1, 2) + pow((L + 1) / 2, 2);
double *lattice = (double *)malloc(2 * (*num) * sizeof(double));
@@ -13,7 +13,7 @@ double *genfunc_uniform(unsigned int L, gsl_rng *r, unsigned int *num) {
return lattice;
}
-double *genfunc_hyperuniform(unsigned int L, gsl_rng *r, unsigned int *num) {
+double *genfunc_hyperuniform(unsigned int L, bound_t boundary, gsl_rng *r, unsigned int *num) {
*num = pow(L / 2 + 1, 2) + pow((L + 1) / 2, 2);
// necessary to prevent crashing when underflow occurs
@@ -21,7 +21,27 @@ double *genfunc_hyperuniform(unsigned int L, gsl_rng *r, unsigned int *num) {
double *lattice = (double *)malloc(2 * (*num) * sizeof(double));
double rho = *num;
- for (unsigned int i = 0; i < (*num); i++) {
+ unsigned int to_gen = *num;
+
+ if (boundary == EMBEDDED_BOUND) {
+ for (unsigned int i = 0; i < L / 2; i++) {
+ lattice[2 * i] = 0;
+ lattice[2 * i + 1] = (2. * i + 1.) / L;
+
+ lattice[L / 2 + 2 * i] = 1;
+ lattice[L / 2 + 2 * i + 1] = (2. * i + 1.) / L;
+
+ lattice[L + 2 * i] = (2. * i + 1.) / L;
+ lattice[L + 2 * i + 1] = 0;
+
+ lattice[3 * L / 2 + 2 * i] = (2. * i + 1.) / L;
+ lattice[3 * L / 2 + 2 * i + 1] = 1;
+ }
+
+ to_gen -= 2 * L;
+ }
+
+ for (unsigned int i = 0; i < to_gen; i++) {
bool reject = true;
double x, y;
while(reject) {