#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; */ }