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/voronoi_bound_ini.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/voronoi_bound_ini.c (limited to 'src/voronoi_bound_ini.c') diff --git a/src/voronoi_bound_ini.c b/src/voronoi_bound_ini.c new file mode 100644 index 0000000..38f41cc --- /dev/null +++ b/src/voronoi_bound_ini.c @@ -0,0 +1,79 @@ + +#include "fracture.h" + +void voronoi_bound_ini(finst *instance, double *square_bound, + unsigned int width) { + unsigned int square_num_verts = 2 * ((width + 1) / 2) * (width / 2 + 1); + double total1 = 0; + double total2 = 0; + double total3 = 0; + double total4 = 0; + for (unsigned int i = 0; i < instance->network->num_bounds; i++) { + for (unsigned int j = 0; j < instance->network->bound_inds[i + 1] - + instance->network->bound_inds[i]; + j++) { + double x = instance->network + ->vert_coords[2 * + instance->network->bound_verts + [instance->network->bound_inds[i] + j]]; + double y = + instance->network + ->vert_coords[2 * + instance->network->bound_verts + [instance->network->bound_inds[i] + j] + + 1]; + + unsigned int vw = (width + 1) / 2; + unsigned int xp = (unsigned int)(x * vw); + unsigned int yp = (unsigned int)(y * vw); + + if (i == 0) { + ((double *)instance->boundary_cond + ->x)[instance->network + ->bound_verts[instance->network->bound_inds[i] + j]] = + square_bound[xp]; + total1 += square_bound[xp]; + } + if (i == 1) { + ((double *)instance->boundary_cond + ->x)[instance->network + ->bound_verts[instance->network->bound_inds[i] + j]] = + square_bound[square_num_verts - vw - 1 + xp]; + total2 += square_bound[square_num_verts - vw - 1 + xp]; + } + if (i == 2) { + ((double *)instance->boundary_cond + ->x)[instance->network + ->bound_verts[instance->network->bound_inds[i] + j]] = + square_bound[(width + 1) / 2 + yp * (width + 1)]; + total3 += square_bound[(width + 1) / 2 + yp * (width + 1)]; + } + if (i == 3) { + ((double *)instance->boundary_cond + ->x)[instance->network + ->bound_verts[instance->network->bound_inds[i] + j]] = + square_bound[(width + 1) / 2 + yp * (width + 1) + width / 2]; + total4 += square_bound[(width + 1) / 2 + yp * (width + 1) + width / 2]; + } + } + } + + ((double *)instance->boundary_cond->x)[instance->network->num_verts] = + - total1 / 2 - total2 / 2; + ((double *)instance->boundary_cond->x)[instance->network->num_verts + 1] = + - total1 / 2 - total2 / 2; + ((double *)instance->boundary_cond->x)[instance->network->num_verts + 2] = + -total3; + ((double *)instance->boundary_cond->x)[instance->network->num_verts + 3] = + -total4; + /* + ((double *)instance->boundary_cond->x)[instance->network->num_verts] = + 0; + ((double *)instance->boundary_cond->x)[instance->network->num_verts + 1] = + 0; + ((double *)instance->boundary_cond->x)[instance->network->num_verts + 2] = + 0; + ((double *)instance->boundary_cond->x)[instance->network->num_verts + 3] = + 0; + */ +} -- cgit v1.2.3-70-g09d2