From cb1b2e6822bdd1d1644ff2dad2d6157858e105b0 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Wed, 24 Apr 2019 23:31:40 -0400 Subject: many changes to introduce two-component, elastic-like fracture --- src/analysis_tools.cpp | 74 +++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'src/analysis_tools.cpp') diff --git a/src/analysis_tools.cpp b/src/analysis_tools.cpp index bc8095e..dea20f0 100644 --- a/src/analysis_tools.cpp +++ b/src/analysis_tools.cpp @@ -18,7 +18,7 @@ bool trivial(boost::detail::edge_desc_impl) return true; } -std::list find_minimal_crack(const Graph& G, const network& n) { +std::list, std::list>> find_minimal_crack(const Graph& G, const network& n) { Graph Gtmp(n.G.vertices.size()); std::list removed_edges; @@ -79,53 +79,53 @@ std::list find_minimal_crack(const Graph& G, const network& n) { } } - if (cycles.size() > 1) { - std::list> bool_cycles; - for (auto cycle : cycles) { - std::valarray bool_cycle(n.G.edges.size()); - for (auto v : cycle) { - bool_cycle[v] = 1; - } - bool_cycles.push_back(bool_cycle); + std::list> bool_cycles; + for (auto cycle : cycles) { + std::valarray bool_cycle(n.G.edges.size()); + for (auto v : cycle) { + bool_cycle[v] = 1; } + bool_cycles.push_back(bool_cycle); + } - // generate all possible cycles by taking xor of the edge sets of the known cycles - for (auto it1 = bool_cycles.begin(); it1 != std::prev(bool_cycles.end()); it1++) { - for (auto it2 = std::next(it1); it2 != bool_cycles.end(); it2++) { - std::valarray new_bool_cycle = (*it1) ^ (*it2); - std::list new_cycle; - unsigned pos = 0; - for (uint8_t included : new_bool_cycle) { - if (included) { - new_cycle.push_back(pos); - } - pos++; + // generate all possible cycles by taking xor of the edge sets of the known cycles + for (auto it1 = bool_cycles.begin(); it1 != std::prev(bool_cycles.end()); it1++) { + for (auto it2 = std::next(it1); it2 != bool_cycles.end(); it2++) { + std::valarray new_bool_cycle = (*it1) ^ (*it2); + std::list new_cycle; + unsigned pos = 0; + for (uint8_t included : new_bool_cycle) { + if (included) { + new_cycle.push_back(pos); } - cycles.push_back(new_cycle); + pos++; } + cycles.push_back(new_cycle); } + } - // find the cycle representing the crack by counting boundary crossings - for (auto cycle : cycles) { - std::array crossing_count{0,0}; + std::list, std::list>> output; - for (auto edge : cycle) { - if (n.G.dual_edges[edge].crossings[0]) { - crossing_count[0]++; - } - if (n.G.dual_edges[edge].crossings[1]) { - crossing_count[1]++; - } - } + // find the cycle representing the crack by counting boundary crossings + for (auto cycle : cycles) { + std::array crossing_count{0,0}; - if (crossing_count[0] % 2 == 1 && crossing_count[1] % 2 == 0) { - return cycle; + for (auto edge : cycle) { + if (n.G.dual_edges[edge].crossings[0]) { + crossing_count[0]++; + } + if (n.G.dual_edges[edge].crossings[1]) { + crossing_count[1]++; } } - } else { - return cycles.front(); + + if (crossing_count[0] % 2 == 1 && crossing_count[1] % 2 == 0) { + output.push_back({{1, 0}, cycle}); + } else if (crossing_count[0] % 2 == 0 && crossing_count[1] % 2 == 1) { + output.push_back({{0, 1}, cycle}); + } } - throw badcycleex; + return output; } -- cgit v1.2.3-54-g00ecf