From 492419f0ae1b32c1d4bc60997ca8eb7daba22182 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Sat, 29 Jun 2019 23:54:37 -0400 Subject: more fixes, and updating the interface --- lib/src/network.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'lib/src') diff --git a/lib/src/network.cpp b/lib/src/network.cpp index dcc5e0e..ed23d45 100644 --- a/lib/src/network.cpp +++ b/lib/src/network.cpp @@ -90,6 +90,9 @@ void network::fracture(hooks& m, bool one_axis) { } void network::update_backbone(const std::vector& c) { + + bool done_x = px.sol.conductivity[0] < 1.0 / G.edges.size(); + bool done_y = py.sol.conductivity[1] < 1.0 / G.edges.size(); class get_cycle_edges : public boost::default_dfs_visitor { public: std::set tE; @@ -191,7 +194,7 @@ void network::update_backbone(const std::vector& c) { other_cycles.push_back(tcycle); } - if (std::any_of(other_cycles.begin(), other_cycles.end(), [](std::array c){return c[0] % 2 == 0 && c[1] % 2 == 0;})) { + if (std::any_of(other_cycles.begin(), other_cycles.end(), [done_x, done_y](std::array c){return (c[0] % 2 == 0 && c[1] % 2 == 0) || ((c[0] % 2 == 0 && done_x) || (c[1] % 2 == 0 && done_y));})) { seen_pairs[{G.edges[i].v[0], G.edges[i].v[1]}] = true; backbone[i] = true; boost::remove_edge(G.edges[i].v[0], G.edges[i].v[1], bG); @@ -304,6 +307,8 @@ void network::update_backbone(const std::vector& c) { bool any_intervening_e_1 = false; bool any_intervening2 = false; bool any_intervening_e_2 = false; + unsigned ie1 = 0; + unsigned ie2 = 0; for (unsigned k = il + 1; k < ig; k++) { if (!boost::same_component(G.vertices[v].nd[i], G.vertices[v].nd[k], ds)) { @@ -320,33 +325,24 @@ void network::update_backbone(const std::vector& c) { if (any_intervening2 && !any_intervening1) { for (unsigned k = il + 1; k <= ig; k++) { if (!backbone[G.vertices[v].ne[k]]) { - any_intervening_e_1 = true; - break; + ie1++; } } } if (any_intervening1 && !any_intervening2) { for (unsigned k = ig + 1; k%G.vertices[v].nd.size() != il + 1; k++) { if (!backbone[G.vertices[v].ne[k%G.vertices[v].nd.size()]]) { - any_intervening_e_2 = true; - break; + ie2++; } } } - if ((any_intervening1 && any_intervening2) || (any_intervening1 && any_intervening_e_2) || (any_intervening2 && any_intervening_e_1)) { + if ((any_intervening1 && any_intervening2) || (any_intervening1 && ie2 > 1) || (any_intervening2 && ie1 > 1)) { found_pair = true; p1 = il; p2 = ig; d1 = G.vertices[v].nd[il]; d2 = G.vertices[v].nd[ig]; - break; - } - } - } - } - } - if (found_pair) { std::list cedges = {}; get_cycle_edges vis(cedges); std::vector cm1(G.dual_vertices.size()); @@ -390,7 +386,7 @@ void network::update_backbone(const std::vector& c) { other_cycles.push_back(tcycle); } - if (std::any_of(other_cycles.begin(), other_cycles.end(), [](std::array c){return c[0] % 2 == 0 && c[1] % 2 == 0;})) { + if (std::any_of(other_cycles.begin(), other_cycles.end(), [done_x, done_y](std::array c){return ((c[0] % 2 == 0 && c[1] % 2 == 0) || (c[0] % 2 == 0 && done_x)) || (c[1] % 2 == 0 && done_y);})) { seen_pairs[{d1, d2}] = true; std::set left_edges = {}; @@ -455,6 +451,10 @@ void network::update_backbone(const std::vector& c) { boost::add_edge(G.dual_edges[e].v[0], G.dual_edges[e].v[1], {e}, dG); } } + } + } + } + } } } -- cgit v1.2.3-70-g09d2