diff options
| author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-12-05 19:16:28 -0500 | 
|---|---|---|
| committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-12-05 19:16:28 -0500 | 
| commit | 4f4cf365eae07e04298459bf8f9e27ad0cfcc834 (patch) | |
| tree | f9823c732c03d1ed0166c765a39c2a77d6f1afa9 /lib/src/graph.cpp | |
| parent | 66aad9c05bce441e3f74049b6c055312287e6a4a (diff) | |
| download | fuse_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/graph.cpp')
| -rw-r--r-- | lib/src/graph.cpp | 29 | 
1 files changed, 15 insertions, 14 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});      } | 
