From e817d415f02bae04881a5f0d3c1f1e313a892014 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Wed, 4 Sep 2019 13:43:57 -0400 Subject: reimplemented distance-from-pc measurements of the cluster size distributions --- src/perc_meas.cpp | 21 +++++++++++++++++++++ src/perc_meas.hpp | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/perc_meas.cpp b/src/perc_meas.cpp index 6ae637a..f0d7cbb 100644 --- a/src/perc_meas.cpp +++ b/src/perc_meas.cpp @@ -76,6 +76,7 @@ pm::pm(unsigned n, double a) : parent(2 * n), ds(&rank[0], &parent[0]), sn(3 * n), + sN(3 * n), ss(2 * n), sm(2 * n), sl(2 * n), @@ -86,6 +87,9 @@ pm::pm(unsigned n, double a) : for (std::vector &x : sn) { x.resize(2 * n); } + for (std::vector &x : sN) { + x.resize(2 * n); + } for (std::vector &x : sb) { x.resize(n); } @@ -97,6 +101,7 @@ pm::pm(unsigned Lx, unsigned Ly) : parent(Lx * Ly / 2), ds(&rank[0], &parent[0]), sn(Lx * Ly), + sN(Lx * Ly), ss(Lx * Ly / 2), sm(Lx * Ly / 2), sl(Lx * Ly / 2), @@ -107,6 +112,9 @@ pm::pm(unsigned Lx, unsigned Ly) : for (std::vector &x : sn) { x.resize(Lx * Ly / 2); } + for (std::vector &x : sN) { + x.resize(Lx * Ly / 2); + } for (std::vector &x : sb) { x.resize(Lx * Ly / 2); } @@ -114,6 +122,7 @@ pm::pm(unsigned Lx, unsigned Ly) : pm::~pm() { update_distribution_file("sn", sn, model_string); + update_distribution_file("sN", sN, model_string); update_distribution_file("ss", ss, model_string); update_distribution_file("sm", sm, model_string); update_distribution_file("sl", sl, model_string); @@ -126,6 +135,7 @@ void pm::pre_fracture(const network&) { initialize_incremental_components(G, ds); incremental_components(G, ds); r = 0; + sN_tmp.clear(); } void pm::bond_broken(const network& net, const current_info& cur, unsigned i) { @@ -135,6 +145,8 @@ void pm::bond_broken(const network& net, const current_info& cur, unsigned i) { boost::component_index components(parent.begin(), parent.end()); std::vector counts(components.size()); + sN_tmp.push_front({}); + BOOST_FOREACH(VertexIndex current_index, components) { unsigned comp_size = 0; BOOST_FOREACH(VertexIndex child_index, components[current_index]) { @@ -142,6 +154,7 @@ void pm::bond_broken(const network& net, const current_info& cur, unsigned i) { } sn[r][comp_size - 1]++; + sN_tmp.front().push_back(comp_size - 1); } std::vector vertex_in(net.G.vertices.size()); @@ -191,6 +204,14 @@ void pm::post_fracture(network &n) { } } + unsigned dr = 0; + for (std::list l : sN_tmp) { + for (unsigned size : l) { + sN[dr][size]++; + } + dr++; + } + sd[r - 1]++; } diff --git a/src/perc_meas.hpp b/src/perc_meas.hpp index e2357db..75ef61a 100644 --- a/src/perc_meas.hpp +++ b/src/perc_meas.hpp @@ -32,13 +32,14 @@ class pm : public hooks { // measurement storage std::vector> sn; // non-spanning cluster size distribution + std::vector> sN; // non-spanning cluster size distribution + std::list> sN_tmp; // non-spanning cluster size distribution std::vector ss; // minimal spanning cluster size distribution std::vector sm; // spanning cluster size distribution std::vector sl; // final avalanche size distribution std::vector> sb; // final avalanche size distribution std::vector sd; std::vector sr; - std::vector sb_tmp; public: std::string model_string; -- cgit v1.2.3-54-g00ecf