summaryrefslogtreecommitdiff
path: root/lib/break_edge.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/break_edge.c')
-rw-r--r--lib/break_edge.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/break_edge.c b/lib/break_edge.c
new file mode 100644
index 0000000..2f112c2
--- /dev/null
+++ b/lib/break_edge.c
@@ -0,0 +1,51 @@
+
+#include "fracture.h"
+
+
+bool break_edge(net_t *net, uint_t edge, cholmod_common *c) {
+ net->fuses[edge] = true;
+ net->num_broken++;
+
+ double *x = (double *)net->boundary_cond->x;
+ const graph_t *g = net->graph;
+
+ uint_t v1 = net->graph->ev[2 * edge];
+ uint_t v2 = net->graph->ev[2 * edge + 1];
+
+ uint_t s1 = v1 < v2 ? v1 : v2;
+ uint_t s2 = v1 < v2 ? v2 : v1;
+
+ if (net->graph->boundary == TORUS_BOUND) {
+ if (net->graph->bq[edge]) {
+ double v1y = g->vx[2 * v1 + 1];
+ double v2y = g->vx[2 * v2 + 1];
+ uint_t ind = v1y < v2y ? 0 : 1;
+ x[g->ev[2 * edge + ind]] -= 1;
+ x[g->ev[2 * edge + !ind]] += 1;
+ }
+ if (net->factor != NULL) {
+ factor_update(net->factor, s1, s2, c);
+ }
+ } else if (net->voltage_bound) {
+ if (g->bq[v1] || g->bq[v2]) {
+ uint_t vv = g->bq[v1] ? v2 : v1;
+ uint_t uu = v1 == vv ? v2 : v1;
+ if (is_in(g->bi[1], g->b, uu)) {
+ x[g->bni[vv]] -= 1;
+ }
+ if (net->factor != NULL) {
+ factor_update2(net->factor, g->bni[vv], c);
+ }
+ } else {
+ if (net->factor != NULL) {
+ factor_update(net->factor, g->bni[s1], g->bni[s2], c);
+ }
+ }
+ } else {
+ if (net->factor != NULL) {
+ factor_update(net->factor, s1, s2, c);
+ }
+ }
+
+ return true;
+}