summaryrefslogtreecommitdiff
path: root/src/randfuncs.c
diff options
context:
space:
mode:
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) {