From 2faf0e4598c7c046d58107d23145f95db334200c Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 16 Mar 2020 18:19:09 -0400 Subject: Implemented new behavior when w=0 or w=1. --- src/analysis_tools.cpp | 20 ++++++++++++++++---- src/animate_fracture.cpp | 28 ++++++++++++++++++++++++++++ src/fracture.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/analysis_tools.cpp b/src/analysis_tools.cpp index 2965915..8ad8235 100644 --- a/src/analysis_tools.cpp +++ b/src/analysis_tools.cpp @@ -30,10 +30,22 @@ std::pair, std::set> find_minimal_crack(const } if (all_good) { - if (cycles[0].second.size() > cycles[1].second.size()) { - return cycles[1]; + if (n.two_sides) { + if (cycles[0].second.size() > cycles[1].second.size()) { + return cycles[1]; + } else { + return cycles[0]; + } } else { - return cycles[0]; + if (cycles[0].first[0] % 2 == 0) { + return cycles[0]; + } else { + return cycles[1]; + } + } + } else if (!n.two_sides) { + if (cycles[!not_good].first[0] % 2 == 0) { + return cycles[!not_good]; } } @@ -63,7 +75,7 @@ std::pair, std::set> find_minimal_crack(const pos++; } - if (cycles[!not_good].second.size() > new_cycle.size()) { + if (cycles[!not_good].second.size() > new_cycle.size() || !n.two_sides) { return {{sum_sig_0, sum_sig_1}, new_cycle}; } else { return cycles[!not_good]; diff --git a/src/animate_fracture.cpp b/src/animate_fracture.cpp index e8de8c1..fd1ffe2 100644 --- a/src/animate_fracture.cpp +++ b/src/animate_fracture.cpp @@ -69,6 +69,33 @@ int main(int argc, char* argv[]) { randutils::auto_seed_128 seeds; std::mt19937 rng{seeds}; + if (w == 0.0 || w == 1.0) { + if (use_aN) { + animate meas(sqrt(2*n *a), sqrt( 2*n / a), width, argc, argv); + + for (unsigned trial = 0; trial < N; trial++) { + graph G(n, a, rng); + fuse_network net(G, &c); + net.set_thresholds(beta, rng); + net.fracture(meas); + } + } else { + animate meas(Lx, Ly, width, argc, argv); + const graph G(Lx, Ly); + const fuse_network plain_net(G, &c); + + for (unsigned trial = 0; trial < N; trial++) { + fuse_network net = plain_net; + net.set_thresholds(beta, rng); + try { + net.fracture(meas); + } catch (std::exception &e) { + std::cout << e.what() << std::endl; + getchar(); + } + } + } + } else { if (use_aN) { animate meas(sqrt(2*n *a), sqrt( 2*n / a), width, argc, argv); @@ -89,6 +116,7 @@ int main(int argc, char* argv[]) { net.fracture(meas); } } + } CHOL_F(finish)(&c); diff --git a/src/fracture.cpp b/src/fracture.cpp index 96cdac3..22101c8 100644 --- a/src/fracture.cpp +++ b/src/fracture.cpp @@ -76,6 +76,49 @@ int main(int argc, char* argv[]) { randutils::auto_seed_128 seeds; std::mt19937 rng{seeds}; + if (w == 0 || w == 1) { + if (use_aN) { + ma meas(n, a, beta, w); + + for (unsigned trial = 0; trial < N; trial++) { + while (true) { + try { + graph G(n, a, rng); + fuse_network n(G, &c); + n.set_thresholds(beta, rng); + n.fracture(meas); + break; + } catch (std::exception &e) { + std::cout << e.what() << '\n'; + } + } + + if (quit.load()) + break; + } + } else { + ma meas(Lx, Ly, beta, w); + + const graph G(Lx, Ly); + const fuse_network n(G, &c); + + for (unsigned trial = 0; trial < N; trial++) { + while (true) { + try { + fuse_network net = n; + net.set_thresholds(beta, rng); + net.fracture(meas); + break; + } catch (std::exception &e) { + std::cout << e.what() << '\n'; + } + } + + if (quit.load()) + break; + } + } + } else { if (use_aN) { ma meas(n, a, beta, w); @@ -117,6 +160,7 @@ int main(int argc, char* argv[]) { break; } } + } CHOL_F(finish)(&c); -- cgit v1.2.3-54-g00ecf