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/animate.cpp | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/animate.cpp') diff --git a/src/animate.cpp b/src/animate.cpp index 5bae15e..be0beef 100644 --- a/src/animate.cpp +++ b/src/animate.cpp @@ -1,5 +1,6 @@ #include "animate.hpp" +#include animate::animate(double Lx, double Ly, unsigned window_size, int argc, char *argv[]) : G(2 * (unsigned)ceil(Lx * Ly / 2)) { glutInit(&argc, argv); @@ -85,20 +86,41 @@ void animate::bond_broken(const network& n, const current_info& cur, unsigned i) } void animate::post_fracture(network &n) { + + std::list crack; +// unsigned crack_component = component[n.G.dual_edges[crack.front()].v[0]]; + unsigned crack_component = 10000; + + std::default_random_engine gen; + std::uniform_real_distribution dis(0.0,1.0); + + bool cycle_present = true; + auto av_it = avalanches.rbegin(); + + while (cycle_present) { + for (unsigned e : *av_it) { + boost::remove_edge(n.G.dual_edges[e].v[0], n.G.dual_edges[e].v[1], G); + n.fuses[e] = false; + } + + auto cracks = find_minimal_crack(G, n); + std::cout << cracks.size() << "\n"; + if (cracks.size() == 0) { + cycle_present = false; + } + + av_it++; + } + std::vector component(boost::num_vertices(G)); unsigned num = boost::connected_components(G, &component[0]); - std::list crack = find_minimal_crack(G, n); - unsigned crack_component = component[n.G.dual_edges[crack.front()].v[0]]; - std::vector> components(num); for (unsigned i = 0; i < n.G.dual_vertices.size(); i++) { components[component[i]].push_back(i); } - std::default_random_engine gen; - std::uniform_real_distribution dis(0.0,1.0); char key; while ((key = getchar()) != 'n') { -- cgit v1.2.3-54-g00ecf