summaryrefslogtreecommitdiff
path: root/src/net_voltages.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/net_voltages.c')
-rw-r--r--src/net_voltages.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/net_voltages.c b/src/net_voltages.c
new file mode 100644
index 0000000..dedf5b2
--- /dev/null
+++ b/src/net_voltages.c
@@ -0,0 +1,22 @@
+
+#include "fracture.h"
+
+double *net_voltages(const net_t *net, cholmod_common *c) {
+ cholmod_dense *b = net->boundary_cond;
+ cholmod_factor *factor = net->factor;
+
+ cholmod_dense *x = CHOL_F(solve)(CHOLMOD_A, factor, b, c);
+
+ if (((double *)x->x)[0] != ((double *)x->x)[0]) {
+ printf("GET_VOLTAGE: value is NaN\n");
+ exit(EXIT_FAILURE);
+ }
+
+ double *voltages = (double *)x->x;
+ x->x = NULL;
+
+ CHOL_F(free_dense)(&x, c);
+
+ return voltages;
+}
+