summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fracture.c4
-rw-r--r--src/gen_laplacian.c37
2 files changed, 13 insertions, 28 deletions
diff --git a/src/fracture.c b/src/fracture.c
index af9cd0f..1ed594f 100644
--- a/src/fracture.c
+++ b/src/fracture.c
@@ -327,8 +327,8 @@ int main(int argc, char *argv[]) {
FILE *testout = fopen("test.txt", "w");
double *tmp_voltage = net_voltages(net, &c);
- for (uint_t j = 0; j < g->bound_inds[1]; j++) {
- fprintf(testout, "%g ", tmp_voltage[g->bound_verts[j]]-tmp_voltage[g->nv+j]);
+ for (uint_t j = 0; j < g->nv; j++) {
+ fprintf(testout, "%g ", tmp_voltage[j]);
}
fclose(testout);
free(tmp_voltage);
diff --git a/src/gen_laplacian.c b/src/gen_laplacian.c
index 04f1f9b..411734c 100644
--- a/src/gen_laplacian.c
+++ b/src/gen_laplacian.c
@@ -106,7 +106,7 @@ cholmod_sparse *gen_laplacian(const net_t *instance, cholmod_common *c,
} else {
num_gedges = network->bound_inds[num_bounds] + (num_bounds - 2) * 2;
}
- if (network->boundary == TORUS_BOUND) num_gedges = 3 * bound_inds[1];
+ if (network->boundary == TORUS_BOUND) num_gedges = bound_inds[1];
uint_t num_gverts = network->break_dim;
uint_t nnz = num_gverts + 2 * num_gedges;
@@ -147,45 +147,30 @@ cholmod_sparse *gen_laplacian(const net_t *instance, cholmod_common *c,
acoo[num_gverts + 2*i+1] = -1;
acoo[vv]++;
acoo[network->nv + i]++;
-
- rowind[num_gverts + 2 * network->bound_inds[1] + 2*i] = network->nv + i;
- colind[num_gverts + 2 * network->bound_inds[1] + 2*i] = network->nv + network->bound_inds[1];
- acoo[num_gverts + 2 * network->bound_inds[1] + 2*i] = -1;
- rowind[num_gverts + 2 * network->bound_inds[1] + 2*i+1] = network->nv + network->bound_inds[1];
- colind[num_gverts + 2 * network->bound_inds[1] + 2*i+1] = network->nv + i;
- acoo[num_gverts + 2 * network->bound_inds[1] + 2*i+1] = -1;
- acoo[network->nv + i]++;
- acoo[network->nv + network->bound_inds[1]]++;
-
- rowind[num_gverts + 4 * network->bound_inds[1] + 2*i] = vv;
- colind[num_gverts + 4 * network->bound_inds[1] + 2*i] = network->nv + network->bound_inds[1];
- acoo[num_gverts + 4 * network->bound_inds[1] + 2*i] = -1;
- rowind[num_gverts + 4 * network->bound_inds[1] + 2*i+1] = network->nv + network->bound_inds[1];
- colind[num_gverts + 4 * network->bound_inds[1] + 2*i+1] = vv;
- acoo[num_gverts + 4 * network->bound_inds[1] + 2*i+1] = -1;
- acoo[vv]++;
- acoo[network->nv + network->bound_inds[1]]++;
}
acoo[bound_verts[0]]++;
}
if (network->boundary != TORUS_BOUND) {
- if (network->boundary != EMBEDDED_BOUND) acoo[0]++;
-
if (voltage_bound) {
for (uint_t i = 0; i < num_bounds; i++) {
for (uint_t j = 0; j < bound_inds[i + 1] - bound_inds[i]; j++) {
acoo[bound_verts[bound_inds[i] + j]]++;
- rowind[num_gverts + 2 * (bound_inds[i] + j)] = network->nv;
- colind[num_gverts + 2 * (bound_inds[i] + j)] = bound_verts[bound_inds[i] + j];
- rowind[num_gverts + 2 * (bound_inds[i] + j) + 1] = bound_verts[bound_inds[i] + j];
- colind[num_gverts + 2 * (bound_inds[i] + j) + 1] = network->nv;
- acoo[network->nv]++;
+
+ rowind[nnz - 1 - 2 * (bound_inds[i] + j)] = bound_verts[bound_inds[i] + j];
+ colind[nnz - 1 - 2 * (bound_inds[i] + j)] = num_gverts - 1;
+ acoo[nnz - 1 - 2 * (bound_inds[i] + j)] = -1;
+ rowind[nnz - 1 - 2 * (bound_inds[i] + j) - 1] = num_gverts - 1;
+ colind[nnz - 1 - 2 * (bound_inds[i] + j) - 1] = bound_verts[bound_inds[i] + j];
+ acoo[nnz - 1 - 2 * (bound_inds[i] + j) - 1] = -1;
+ acoo[num_gverts - 1]++;
acoo[bound_verts[bound_inds[i] + j]]++;
}
}
} else {
for (uint_t i = 0; i < num_bounds; i++) {
+ if (network->boundary != EMBEDDED_BOUND) acoo[0]++;
+
rowind[num_verts + i] = num_verts + i;
colind[num_verts + i] = num_verts + i;
if (i < 2)