summaryrefslogtreecommitdiff
path: root/lib/src
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-12-05 19:16:28 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-12-05 19:16:28 -0500
commit4f4cf365eae07e04298459bf8f9e27ad0cfcc834 (patch)
treef9823c732c03d1ed0166c765a39c2a77d6f1afa9 /lib/src
parent66aad9c05bce441e3f74049b6c055312287e6a4a (diff)
downloadfuse_networks-4f4cf365eae07e04298459bf8f9e27ad0cfcc834.tar.gz
fuse_networks-4f4cf365eae07e04298459bf8f9e27ad0cfcc834.tar.bz2
fuse_networks-4f4cf365eae07e04298459bf8f9e27ad0cfcc834.zip
now takes Lx and Ly for anisotropic fracture
Diffstat (limited to 'lib/src')
-rw-r--r--lib/src/graph.cpp29
-rw-r--r--lib/src/network.cpp6
2 files changed, 18 insertions, 17 deletions
diff --git a/lib/src/graph.cpp b/lib/src/graph.cpp
index e5f374e..f2e8065 100644
--- a/lib/src/graph.cpp
+++ b/lib/src/graph.cpp
@@ -1,10 +1,11 @@
#include "graph.hpp"
-graph::graph(unsigned int L) {
- double dx = 1.0 / L;
- unsigned int nv = 2 * pow(L / 2, 2);
- unsigned int ne = pow(L, 2);
+graph::graph(unsigned int Nx, unsigned int Ny) {
+ L = {(double)Nx, (double)Ny};
+
+ unsigned int ne = Nx * Ny;
+ unsigned int nv = ne / 2;
vertices.resize(nv);
edges.reserve(ne);
@@ -13,22 +14,22 @@ graph::graph(unsigned int L) {
dual_edges.reserve(ne);
for (unsigned int i = 0; i < nv; i++) {
- vertices[i].r.x = dx * ((1 + i / (L / 2)) % 2 + 2 * (i % (L / 2)));
- vertices[i].r.y = dx * (i / (L / 2));
+ vertices[i].r.x = (double)((1 + i / (Nx / 2)) % 2 + 2 * (i % (Nx / 2)));
+ vertices[i].r.y = (double)(i / (Nx / 2));
- dual_vertices[i].r.x = dx * ((i / (L / 2)) % 2 + 2 * (i % (L / 2)));
- dual_vertices[i].r.y = dx * (i / (L / 2));
+ dual_vertices[i].r.x = (double)((i / (Nx / 2)) % 2 + 2 * (i % (Nx / 2)));
+ dual_vertices[i].r.y = (double)(i / (Nx / 2));
}
- for (unsigned int x = 0; x < L; x++) {
- for (unsigned int y = 0; y < L; y++) {
- unsigned int v1 = (L * x) / 2 + ((y + x % 2) / 2) % (L / 2);
- unsigned int v2 = ((L * (x + 1)) / 2 + ((y + (x + 1) % 2) / 2) % (L / 2)) % nv;
+ for (unsigned int x = 0; x < Ny; x++) {
+ for (unsigned int y = 0; y < Nx; y++) {
+ unsigned int v1 = (Nx * x) / 2 + ((y + x % 2) / 2) % (Nx / 2);
+ unsigned int v2 = ((Nx * (x + 1)) / 2 + ((y + (x + 1) % 2) / 2) % (Nx / 2)) % nv;
edges.push_back({v1, v2});
- unsigned int dv1 = (L * x) / 2 + ((y + (x + 1) % 2) / 2) % (L / 2);
- unsigned int dv2 = ((L * (x + 1)) / 2 + ((y + x % 2) / 2) % (L / 2)) % nv;
+ unsigned int dv1 = (Nx * x) / 2 + ((y + (x + 1) % 2) / 2) % (Nx / 2);
+ unsigned int dv2 = ((Nx * (x + 1)) / 2 + ((y + x % 2) / 2) % (Nx / 2)) % nv;
dual_edges.push_back({dv1, dv2});
}
diff --git a/lib/src/network.cpp b/lib/src/network.cpp
index 9f6cb0d..bc7a0c6 100644
--- a/lib/src/network.cpp
+++ b/lib/src/network.cpp
@@ -7,7 +7,7 @@ network::network(const graph& G, cholmod_common *c) : c(c), G(G), fuses(G.edges.
double v0y = G.vertices[G.edges[i][0]].r.y;
double v1y = G.vertices[G.edges[i][1]].r.y;
- if (fabs(v0y - v1y) > 0.5) {
+ if (fabs(v0y - v1y) > G.L.y / 2) {
bool ind = v0y < v1y ? 0 : 1;
((double *)b->x)[G.edges[i][ind]] += 1.0;
@@ -138,7 +138,7 @@ void network::break_edge(unsigned int e, bool unbreak) {
double v0y = G.vertices[v0].r.y;
double v1y = G.vertices[v1].r.y;
- if (fabs(v0y - v1y) > 0.5) {
+ if (fabs(v0y - v1y) > G.L.y / 2) {
bool ind = v0y < v1y ? unbreak : !unbreak;
((double *)b->x)[G.edges[e][ind]] -= 1.0;
@@ -172,7 +172,7 @@ current_info network::get_current_info() {
double v0y = G.vertices[G.edges[i][0]].r.y;
double v1y = G.vertices[G.edges[i][1]].r.y;
- if (fabs(v0y - v1y) > 0.5) {
+ if (fabs(v0y - v1y) > G.L.y / 2) {
if (v0y > v1y) {
currents[i] += 1.0;
total_current += currents[i];