From e3b663588a30ec4f05afe50c260982bd44a1bb2b Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Thu, 24 Jan 2019 19:01:18 -0500 Subject: style changes --- src/analysis_tools.cpp | 24 +++++++------- src/analysis_tools.hpp | 4 +-- src/animate.cpp | 26 +++++++-------- src/animate.hpp | 6 ++-- src/animate_fracture.cpp | 6 ++-- src/animate_fracture_square.cpp | 6 ++-- src/fracture.cpp | 6 ++-- src/fracture_square.cpp | 6 ++-- src/measurements.cpp | 70 ++++++++++++++++++++--------------------- src/measurements.hpp | 12 +++---- 10 files changed, 83 insertions(+), 83 deletions(-) (limited to 'src') diff --git a/src/analysis_tools.cpp b/src/analysis_tools.cpp index 34e4ea0..778e713 100644 --- a/src/analysis_tools.cpp +++ b/src/analysis_tools.cpp @@ -10,16 +10,16 @@ bool trivial(boost::detail::edge_desc_impl) return true; } -std::list find_minimal_crack(const Graph& G, const network& n) { +std::list find_minimal_crack(const Graph& G, const network& n) { Graph Gtmp(n.G.vertices.size()); - std::list removed_edges; + std::list removed_edges; class add_tree_edges : public boost::default_dfs_visitor { public: Graph& G; - std::list& E; + std::list& E; - add_tree_edges(Graph& G, std::list& E) : G(G), E(E) {} + add_tree_edges(Graph& G, std::list& E) : G(G), E(E) {} void tree_edge(boost::graph_traits::edge_descriptor e, const Graph& g) { boost::add_edge(boost::source(e, g), boost::target(e, g), g[e], G); @@ -37,11 +37,11 @@ std::list find_minimal_crack(const Graph& G, const network& n) { class find_cycle : public boost::default_dfs_visitor { public: - std::list& E; - unsigned int end; + std::list& E; + unsigned end; struct done{}; - find_cycle(std::list& E, unsigned int end) : E(E), end(end) {} + find_cycle(std::list& E, unsigned end) : E(E), end(end) {} void discover_vertex(boost::graph_traits::vertex_descriptor v, const Graph& g) { if (v == end) { @@ -58,10 +58,10 @@ std::list find_minimal_crack(const Graph& G, const network& n) { } }; - std::list> cycles; + std::list> cycles; for (auto edge : removed_edges) { - std::list cycle = {edge}; + std::list cycle = {edge}; find_cycle vis(cycle, n.G.dual_edges[edge].v[1]); std::vector new_color_map(boost::num_vertices(Gtmp)); try { @@ -85,8 +85,8 @@ std::list find_minimal_crack(const Graph& G, const network& n) { 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 int pos = 0; + std::list new_cycle; + unsigned pos = 0; for (uint8_t included : new_bool_cycle) { if (included) { new_cycle.push_back(pos); @@ -99,7 +99,7 @@ std::list find_minimal_crack(const Graph& G, const network& n) { // find the cycle representing the crack by counting boundary crossings for (auto cycle : cycles) { - std::array crossing_count{0,0}; + std::array crossing_count{0,0}; for (auto edge : cycle) { if (n.G.dual_edges[edge].crossings[0]) { diff --git a/src/analysis_tools.hpp b/src/analysis_tools.hpp index 34ed967..4f3f285 100644 --- a/src/analysis_tools.hpp +++ b/src/analysis_tools.hpp @@ -14,7 +14,7 @@ #include struct EdgeProperties { - unsigned int index; + unsigned index; }; typedef boost::adjacency_list Graph; @@ -25,5 +25,5 @@ bool is_shorter(const std::list &, const std::list &); bool trivial(boost::detail::edge_desc_impl); -std::list find_minimal_crack(const Graph &, const network &); +std::list find_minimal_crack(const Graph &, const network &); diff --git a/src/animate.cpp b/src/animate.cpp index 4f10e0a..5bae15e 100644 --- a/src/animate.cpp +++ b/src/animate.cpp @@ -1,10 +1,10 @@ #include "animate.hpp" -animate::animate(double Lx, double Ly, unsigned int window_size, int argc, char *argv[]) : G(2 * (unsigned int)ceil(Lx * Ly / 2)) { +animate::animate(double Lx, double Ly, unsigned window_size, int argc, char *argv[]) : G(2 * (unsigned)ceil(Lx * Ly / 2)) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize((unsigned int)(Lx / Ly * window_size), window_size); + glutInitWindowSize((unsigned)(Lx / Ly * window_size), window_size); glutCreateWindow("wolff"); glClearColor(0.0,0.0,0.0,0.0); glMatrixMode(GL_PROJECTION); @@ -21,7 +21,7 @@ void animate::pre_fracture(const network &n) { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_LINES); glColor3f(0.0f, 0.0f, 0.0f); - for (unsigned int i = 0; i < n.G.edges.size(); i++) { + for (unsigned i = 0; i < n.G.edges.size(); i++) { graph::coordinate r1 = n.G.vertices[n.G.edges[i].v[0]].r; graph::coordinate r2 = n.G.vertices[n.G.edges[i].v[1]].r; @@ -47,7 +47,7 @@ void animate::pre_fracture(const network &n) { glFlush(); } -void animate::bond_broken(const network& n, const current_info& cur, unsigned int i) { +void animate::bond_broken(const network& n, const current_info& cur, unsigned i) { long double c = logl(cur.conductivity / fabs(cur.currents[i])) + n.thresholds[i]; if (c > lv && avalanches.back().size() > 0) { lv = c; @@ -85,15 +85,15 @@ void animate::bond_broken(const network& n, const current_info& cur, unsigned in } void animate::post_fracture(network &n) { - std::vector component(boost::num_vertices(G)); - unsigned int num = boost::connected_components(G, &component[0]); + std::vector component(boost::num_vertices(G)); + unsigned num = boost::connected_components(G, &component[0]); - std::list crack = find_minimal_crack(G, n); - unsigned int crack_component = component[n.G.dual_edges[crack.front()].v[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); + std::vector> components(num); - for (unsigned int i = 0; i < n.G.dual_vertices.size(); i++) { + for (unsigned i = 0; i < n.G.dual_vertices.size(); i++) { components[component[i]].push_back(i); } @@ -106,7 +106,7 @@ void animate::post_fracture(network &n) { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_LINES); glColor3f(0.0f, 0.0f, 0.0f); - for (unsigned int i = 0; i < n.G.edges.size(); i++) { + for (unsigned i = 0; i < n.G.edges.size(); i++) { if (!n.fuses[i]) { graph::coordinate r1 = n.G.vertices[n.G.edges[i].v[0]].r; graph::coordinate r2 = n.G.vertices[n.G.edges[i].v[1]].r; @@ -151,7 +151,7 @@ void animate::post_fracture(network &n) { break; case 'c' : - for (unsigned int i = 0; i < num; i++) { + for (unsigned i = 0; i < num; i++) { if (i == crack_component) { glColor3d(1.0, 0.0, 0.0); } else { @@ -170,7 +170,7 @@ void animate::post_fracture(network &n) { break; case 'C' : - for (unsigned int i = 0; i < num; i++) { + for (unsigned i = 0; i < num; i++) { if (components[i].size() > 1) { if (i == crack_component) { glColor3d(1.0, 0.0, 0.0); diff --git a/src/animate.hpp b/src/animate.hpp index 423eba7..fcb89fc 100644 --- a/src/animate.hpp +++ b/src/animate.hpp @@ -12,11 +12,11 @@ class animate : public hooks { Graph G; public: long double lv; - std::list> avalanches; + std::list> avalanches; - animate(double Lx, double Ly, unsigned int window_size, int argc, char *argv[]); + animate(double Lx, double Ly, unsigned window_size, int argc, char *argv[]); void pre_fracture(const network &) override; - void bond_broken(const network& net, const current_info& cur, unsigned int i) override; + void bond_broken(const network& net, const current_info& cur, unsigned i) override; void post_fracture(network &n) override; }; diff --git a/src/animate_fracture.cpp b/src/animate_fracture.cpp index 9ae79cc..2d64072 100644 --- a/src/animate_fracture.cpp +++ b/src/animate_fracture.cpp @@ -30,7 +30,7 @@ int main(int argc, char* argv[]) { int opt; - unsigned int N = 1; + unsigned N = 1; double Lx = 16.0; double Ly = 16.0; double beta = 0.5; @@ -38,7 +38,7 @@ int main(int argc, char* argv[]) { while ((opt = getopt(argc, argv, "X:Y:N:b:")) != -1) { switch (opt) { case 'N': - N = (unsigned int)atof(optarg); + N = (unsigned)atof(optarg); break; case 'X': Lx = atof(optarg); @@ -62,7 +62,7 @@ int main(int argc, char* argv[]) { randutils::auto_seed_128 seeds; std::mt19937 rng{seeds}; - for (unsigned int trial = 0; trial < N; trial++) { + for (unsigned trial = 0; trial < N; trial++) { graph G(Lx, Ly, rng); network network(G, &c); network.set_thresholds(beta, rng); diff --git a/src/animate_fracture_square.cpp b/src/animate_fracture_square.cpp index 512486f..d2efde9 100644 --- a/src/animate_fracture_square.cpp +++ b/src/animate_fracture_square.cpp @@ -30,7 +30,7 @@ int main(int argc, char* argv[]) { int opt; - unsigned int N = 1; + unsigned N = 1; unsigned Lx = 16; unsigned Ly = 16; double beta = 0.5; @@ -38,7 +38,7 @@ int main(int argc, char* argv[]) { while ((opt = getopt(argc, argv, "X:Y:N:b:")) != -1) { switch (opt) { case 'N': - N = (unsigned int)atof(optarg); + N = (unsigned)atof(optarg); break; case 'X': Lx = atoi(optarg); @@ -65,7 +65,7 @@ int main(int argc, char* argv[]) { graph G(Lx, Ly); network perm_network(G, &c); - for (unsigned int trial = 0; trial < N; trial++) { + for (unsigned trial = 0; trial < N; trial++) { network tmp_network(perm_network); tmp_network.set_thresholds(beta, rng); tmp_network.fracture(meas); diff --git a/src/fracture.cpp b/src/fracture.cpp index e260e14..6712ac3 100644 --- a/src/fracture.cpp +++ b/src/fracture.cpp @@ -30,7 +30,7 @@ int main(int argc, char* argv[]) { int opt; - unsigned int N = 1; + unsigned N = 1; double Lx = 16; double Ly = 16; double beta = 0.5; @@ -38,7 +38,7 @@ int main(int argc, char* argv[]) { while ((opt = getopt(argc, argv, "N:X:Y:b:")) != -1) { switch (opt) { case 'N': - N = (unsigned int)atof(optarg); + N = (unsigned)atof(optarg); break; case 'X': Lx = atof(optarg); @@ -62,7 +62,7 @@ int main(int argc, char* argv[]) { randutils::auto_seed_128 seeds; std::mt19937 rng{seeds}; - for (unsigned int trial = 0; trial < N; trial++) { + for (unsigned trial = 0; trial < N; trial++) { while (true) { try { graph G(Lx, Ly, rng); diff --git a/src/fracture_square.cpp b/src/fracture_square.cpp index 03b0113..47d7d67 100644 --- a/src/fracture_square.cpp +++ b/src/fracture_square.cpp @@ -30,7 +30,7 @@ int main(int argc, char* argv[]) { int opt; - unsigned int N = 1; + unsigned N = 1; unsigned Lx = 16; unsigned Ly = 16; double beta = 0.5; @@ -38,7 +38,7 @@ int main(int argc, char* argv[]) { while ((opt = getopt(argc, argv, "N:X:Y:b:")) != -1) { switch (opt) { case 'N': - N = (unsigned int)atof(optarg); + N = (unsigned)atof(optarg); break; case 'X': Lx = atoi(optarg); @@ -64,7 +64,7 @@ int main(int argc, char* argv[]) { randutils::auto_seed_128 seeds; std::mt19937 rng{seeds}; - for (unsigned int trial = 0; trial < N; trial++) { + for (unsigned trial = 0; trial < N; trial++) { while (true) { try { network tmp_network(perm_network); diff --git a/src/measurements.cpp b/src/measurements.cpp index ffff06d..17fbdee 100644 --- a/src/measurements.cpp +++ b/src/measurements.cpp @@ -2,7 +2,7 @@ #include "measurements.hpp" #include -void update_distribution_file(std::string id, const std::vector& data, unsigned int N, double Lx, double Ly, double beta) { +void update_distribution_file(std::string id, const std::vector& data, unsigned N, double Lx, double Ly, double beta) { std::string filename = "fracture_" + std::to_string(Lx) + "_" + std::to_string(Ly) + "_" + std::to_string(beta) + "_" + id + ".dat"; std::ifstream file(filename); @@ -11,7 +11,7 @@ void update_distribution_file(std::string id, const std::vector& data, if (file.is_open()) { file >> N_old; - for (unsigned int i = 0; i < data.size(); i++) { + for (unsigned i = 0; i < data.size(); i++) { uint64_t num; file >> num; data_old[i] = num; @@ -23,7 +23,7 @@ void update_distribution_file(std::string id, const std::vector& data, std::ofstream file_out(filename); file_out <& data, } template -void update_field_file(std::string id, const std::vector& data, unsigned int N, double Lx, double Ly, double beta, unsigned int Mx, unsigned int My) { +void update_field_file(std::string id, const std::vector& data, unsigned N, double Lx, double Ly, double beta, unsigned Mx, unsigned My) { std::string filename = "fracture_" + std::to_string(Lx) + "_" + std::to_string(Ly) + "_" + std::to_string(beta) + "_" + id + "_" + std::to_string(Mx) + "_" + std::to_string(My) + ".dat"; std::ifstream file(filename); @@ -44,7 +44,7 @@ void update_field_file(std::string id, const std::vector& data, unsigned int if (file.is_open()) { file >> N_old; for (unsigned j = 0; j < data.size(); j++) { - for (unsigned int i = 0; i < data[j].size(); i++) { + for (unsigned i = 0; i < data[j].size(); i++) { file >> data_old[j][i]; } } @@ -55,7 +55,7 @@ void update_field_file(std::string id, const std::vector& data, unsigned int file_out <& data, unsigned int } template -std::vector data_transform(unsigned int Mx, unsigned int My, const std::vector& data, fftw_plan forward_plan, double *fftw_forward_in, fftw_complex *fftw_forward_out) { - for (unsigned int i = 0; i < Mx * My; i++) { +std::vector data_transform(unsigned Mx, unsigned My, const std::vector& data, fftw_plan forward_plan, double *fftw_forward_in, fftw_complex *fftw_forward_out) { + for (unsigned i = 0; i < Mx * My; i++) { fftw_forward_in[i] = (double)data[i]; } @@ -74,7 +74,7 @@ std::vector data_transform(unsigned int Mx, unsigned int My, const std::vector output(Mx * (My / 2 + 1)); - for (unsigned int i = 0; i < Mx * (My / 2 + 1); i++) { + for (unsigned i = 0; i < Mx * (My / 2 + 1); i++) { output[i][0] = fftw_forward_out[i][0]; output[i][1] = fftw_forward_out[i][1]; } @@ -83,24 +83,24 @@ std::vector data_transform(unsigned int Mx, unsigned int My, const } template -void correlation(unsigned int Mx, unsigned int My, std::vector& data, const std::vector& tx1, const std::vector& tx2, fftw_plan reverse_plan, fftw_complex *fftw_reverse_in, double *fftw_reverse_out) { - for (unsigned int i = 0; i < Mx * (My / 2 + 1); i++) { +void correlation(unsigned Mx, unsigned My, std::vector& data, const std::vector& tx1, const std::vector& tx2, fftw_plan reverse_plan, fftw_complex *fftw_reverse_in, double *fftw_reverse_out) { + for (unsigned i = 0; i < Mx * (My / 2 + 1); i++) { fftw_reverse_in[i][0] = tx1[i][0] * tx2[i][0] + tx1[i][1] * tx2[i][1]; fftw_reverse_in[i][1] = tx1[i][0] * tx2[i][1] - tx1[i][1] * tx2[i][0]; } fftw_execute(reverse_plan); - for (unsigned int i = 0; i < (Mx / 2 + 1) * (My / 2 + 1); i++) { + for (unsigned i = 0; i < (Mx / 2 + 1) * (My / 2 + 1); i++) { data[i] += (T)(fftw_reverse_out[Mx * (i / (Mx / 2 + 1)) + i % (Mx / 2 + 1)] / (Mx * My)); } } template -void autocorrelation(unsigned int Mx, unsigned int My, std::vector>& out_data, fftw_plan forward_plan, double *fftw_forward_in, fftw_complex *fftw_forward_out, fftw_plan reverse_plan, fftw_complex *fftw_reverse_in, double *fftw_reverse_out) { +void autocorrelation(unsigned Mx, unsigned My, std::vector>& out_data, fftw_plan forward_plan, double *fftw_forward_in, fftw_complex *fftw_forward_out, fftw_plan reverse_plan, fftw_complex *fftw_reverse_in, double *fftw_reverse_out) { fftw_execute(forward_plan); - for (unsigned int i = 0; i < My * (Mx / 2 + 1); i++) { + for (unsigned i = 0; i < My * (Mx / 2 + 1); i++) { fftw_reverse_in[i][0] = pow(fftw_forward_out[i][0], 2) + pow(fftw_forward_out[i][1], 2); fftw_reverse_in[i][1] = 0.0; } @@ -108,23 +108,23 @@ void autocorrelation(unsigned int Mx, unsigned int My, std::vector lv && avalanches.back().size() > 0) { sa[avalanches.back().size() - 1]++; @@ -221,10 +221,10 @@ void ma::bond_broken(const network& net, const current_info& cur, unsigned int i } void ma::post_fracture(network &n) { - std::vector component(boost::num_vertices(G)); - unsigned int num = boost::connected_components(G, &component[0]); + std::vector component(boost::num_vertices(G)); + unsigned num = boost::connected_components(G, &component[0]); - std::list crack = find_minimal_crack(G, n); + std::list crack = find_minimal_crack(G, n); // crack surface correlations std::fill_n(fftw_forward_in, Mx * My, 0.0); @@ -236,17 +236,17 @@ void ma::post_fracture(network &n) { autocorrelation(Mx, My, Css, forward_plan, fftw_forward_in, fftw_forward_out, reverse_plan, fftw_reverse_in, fftw_reverse_out); - unsigned int crack_component = component[n.G.dual_edges[crack.front()].v[0]]; + unsigned crack_component = component[n.G.dual_edges[crack.front()].v[0]]; - std::vector> components(num); + std::vector> components(num); - for (unsigned int i = 0; i < n.G.dual_vertices.size(); i++) { + for (unsigned i = 0; i < n.G.dual_vertices.size(); i++) { components[component[i]].push_back(i); } // non-spanning clusters std::fill_n(fftw_forward_in, Mx * My, 0.0); - for (unsigned int i = 0; i < num; i++) { + for (unsigned i = 0; i < num; i++) { if (i != crack_component && components[i].size() > 0) { for (auto it = components[i].begin(); it != components[i].end(); it++) { fftw_forward_in[edge_r_to_ind(n.G.dual_vertices[*it].r, Lx, Ly, Mx, My)] += 1.0; @@ -275,7 +275,7 @@ void ma::post_fracture(network &n) { autocorrelation(Mx, My, Cmm, forward_plan, fftw_forward_in, fftw_forward_out, reverse_plan, fftw_reverse_in, fftw_reverse_out); - std::function inCrack = [&](unsigned int i) -> bool { + std::function inCrack = [&](unsigned i) -> bool { return component[n.G.dual_edges[i].v[0]] == crack_component; }; @@ -303,11 +303,11 @@ void ma::post_fracture(network &n) { autocorrelation(Mx, My, Cll, forward_plan, fftw_forward_in, fftw_forward_out, reverse_plan, fftw_reverse_in, fftw_reverse_out); // damage size distribution - unsigned int total_broken = 0; + unsigned total_broken = 0; std::fill_n(fftw_forward_in, Mx * My, 0.0); - for (unsigned int i = 0; i < n.G.edges.size(); i++) { + for (unsigned i = 0; i < n.G.edges.size(); i++) { if (n.fuses[i]) { total_broken++; fftw_forward_in[edge_r_to_ind(n.G.edges[i].r, Lx, Ly, Mx, My)] += 1.0; @@ -322,7 +322,7 @@ void ma::post_fracture(network &n) { unsigned ii = avalanches.back().front(); long double c = logl(cur.conductivity / fabs(cur.currents[ii])) + n.thresholds[ii]; - for (unsigned int i = 0; i < n.G.edges.size(); i++) { + for (unsigned i = 0; i < n.G.edges.size(); i++) { double x; if (!n.fuses[i]) { stress_file << std::scientific << fabs(cur.currents[i]) << " "; diff --git a/src/measurements.hpp b/src/measurements.hpp index aa41fd1..ba52720 100644 --- a/src/measurements.hpp +++ b/src/measurements.hpp @@ -25,11 +25,11 @@ class ma : public hooks { double *fftw_reverse_out; fftw_plan forward_plan; fftw_plan reverse_plan; - unsigned int N; + unsigned N; double Lx; double Ly; - unsigned int Mx; - unsigned int My; + unsigned Mx; + unsigned My; double beta; Graph G; // std::ofstream stress_file; @@ -57,13 +57,13 @@ class ma : public hooks { long double lv; - std::list> avalanches; + std::list> avalanches; - ma(double Lx, double Ly, unsigned int Mx, unsigned int My, double beta, unsigned Ncum); + ma(double Lx, double Ly, unsigned Mx, unsigned My, double beta, unsigned Ncum); ~ma(); void pre_fracture(const network &) override; - void bond_broken(const network& net, const current_info& cur, unsigned int i) override; + void bond_broken(const network& net, const current_info& cur, unsigned i) override; void post_fracture(network &n) override; }; -- cgit v1.2.3-70-g09d2