From fd14c5e39d962be94a1f68b0d4cacb7a4aa9c3e7 Mon Sep 17 00:00:00 2001 From: pants Date: Fri, 2 Sep 2016 15:24:34 -0400 Subject: embedded systems with crack fully supported --- src/cracking_ini.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/cracking_ini.c') diff --git a/src/cracking_ini.c b/src/cracking_ini.c index 9ab4a9d..988af5b 100644 --- a/src/cracking_ini.c +++ b/src/cracking_ini.c @@ -31,6 +31,30 @@ double *gen_fuse_thres(unsigned int num_edges, double *edge_coords, double beta, return fuse_thres; } +void gen_voro_crack(finst *instance, double crack_len, cholmod_common *c) { + for (uint_t i = 0; i < instance->network->num_edges; i++) { + uint_t v1, v2; + double v1x, v1y, v2x, v2y, dx, dy; + + v1 = instance->network->edges_to_verts[2 * i]; + v2 = instance->network->edges_to_verts[2 * i + 1]; + + v1x = instance->network->vert_coords[2 * v1]; + v1y = instance->network->vert_coords[2 * v1 + 1]; + v2x = instance->network->vert_coords[2 * v2]; + v2y = instance->network->vert_coords[2 * v2 + 1]; + + dx = v1x - v2x; + dy = v1y - v2y; + + if (((v1y > 0.5 && v2y < 0.5) || (v1y < 0.5 && v2y > 0.5)) && fabs(dy) < 0.5) { + if (v1x + dx / dy * (v1y - 0.5) <= crack_len) { + break_edge(instance, i, c); + } + } + } +} + bool gen_crack(finst *instance, double crack_len, double crack_width, cholmod_common *c) { assert(instance != NULL); -- cgit v1.2.3-70-g09d2