summaryrefslogtreecommitdiff
path: root/lib/break_edge.c
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2017-02-10 12:19:46 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2017-02-10 12:19:46 -0500
commit0ef0c0ce1d904be2b4e1f4da62dc029d8572c983 (patch)
tree12978013d870186240c08d1fdd6a7ce8781bca93 /lib/break_edge.c
parent9a93a3b88a604672f557950e6c7f3fe815bcf163 (diff)
parent901b9f16494f37890be17ef4bb66e6efc6873340 (diff)
downloadfuse_networks-0ef0c0ce1d904be2b4e1f4da62dc029d8572c983.tar.gz
fuse_networks-0ef0c0ce1d904be2b4e1f4da62dc029d8572c983.tar.bz2
fuse_networks-0ef0c0ce1d904be2b4e1f4da62dc029d8572c983.zip
Merge branch 'tmp'
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;
+}