From 2bb0740b68fdb62d45adc00204b3990ca42ade77 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 22 Aug 2016 10:11:14 -0400 Subject: started repo again without all the data files gunking the works --- src/toy_setup.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/toy_setup.c (limited to 'src/toy_setup.c') diff --git a/src/toy_setup.c b/src/toy_setup.c new file mode 100644 index 0000000..228acbc --- /dev/null +++ b/src/toy_setup.c @@ -0,0 +1,37 @@ + +#include "fracture.h" + +bool break_fuses(unsigned int width, double *fuse_thres, double *field, + bool *fuses) { + assert(fuse_thres != NULL); + assert(field != NULL); + assert(fuses != NULL); + unsigned int size = pow(width, 2); + + for (unsigned int i = 0; i < size; i++) { + if (fuses[i]) { + if (1 / fuse_thres[i] > field[i]) { + fuses[i] = 0; + } + } + } + + return true; +} + +bool gen_toy_field(unsigned int width, double strength, double *field) { + assert(field != NULL); + unsigned int size = pow(width, 2); + + for (unsigned intint i = 0; i < size; i++) { + int x = i / width + 1; + int y = i % width + 1; + if (y < (width + 1) / 2.) + field[i] = fabs((width) / 2. - x) / strength; + else + field[i] = + sqrt(pow((width) / 2. - x, 2) + pow((width) / 2. - y, 2)) / strength; + } + + return true; +} -- cgit v1.2.3-70-g09d2