summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/include/graph.hpp4
-rw-r--r--lib/include/hooks.hpp2
-rw-r--r--lib/include/network.hpp2
-rw-r--r--lib/src/graph.cpp82
-rw-r--r--lib/src/network.cpp40
-rw-r--r--src/analysis_tools.cpp24
-rw-r--r--src/analysis_tools.hpp4
-rw-r--r--src/animate.cpp26
-rw-r--r--src/animate.hpp6
-rw-r--r--src/animate_fracture.cpp6
-rw-r--r--src/animate_fracture_square.cpp6
-rw-r--r--src/fracture.cpp6
-rw-r--r--src/fracture_square.cpp6
-rw-r--r--src/measurements.cpp70
-rw-r--r--src/measurements.hpp12
15 files changed, 148 insertions, 148 deletions
diff --git a/lib/include/graph.hpp b/lib/include/graph.hpp
index 38c8edd..1089925 100644
--- a/lib/include/graph.hpp
+++ b/lib/include/graph.hpp
@@ -24,7 +24,7 @@ class graph {
} vertex;
typedef struct edge {
- std::array<unsigned int, 2> v;
+ std::array<unsigned, 2> v;
coordinate r;
std::array<bool, 2> crossings;
} edge;
@@ -37,7 +37,7 @@ class graph {
std::vector<vertex> dual_vertices;
std::vector<edge> dual_edges;
- graph(unsigned int Nx, unsigned int Ny);
+ graph(unsigned Nx, unsigned Ny);
graph(double Lx, double Ly, std::mt19937& rng);
};
diff --git a/lib/include/hooks.hpp b/lib/include/hooks.hpp
index e617ac3..67313cc 100644
--- a/lib/include/hooks.hpp
+++ b/lib/include/hooks.hpp
@@ -8,7 +8,7 @@ class network;
class hooks {
public:
virtual void pre_fracture(const network&) {};
- virtual void bond_broken(const network&, const current_info&, unsigned int) {};
+ virtual void bond_broken(const network&, const current_info&, unsigned) {};
virtual void post_fracture(network&) {}; // post fracture hook can be destructive
};
diff --git a/lib/include/network.hpp b/lib/include/network.hpp
index 70173e6..f12c9c7 100644
--- a/lib/include/network.hpp
+++ b/lib/include/network.hpp
@@ -43,7 +43,7 @@ class network {
~network();
void set_thresholds(double, std::mt19937&);
- void break_edge(unsigned int, bool unbreak = false);
+ void break_edge(unsigned, bool unbreak = false);
current_info get_current_info();
void fracture(hooks&, double cutoff = 1e-13);
};
diff --git a/lib/src/graph.cpp b/lib/src/graph.cpp
index 0cc6a18..526ffeb 100644
--- a/lib/src/graph.cpp
+++ b/lib/src/graph.cpp
@@ -18,11 +18,11 @@ double mod(double a, double b) {
}
}
-graph::graph(unsigned int Nx, unsigned int Ny) {
+graph::graph(unsigned Nx, unsigned Ny) {
L = {(double)Nx, (double)Ny};
- unsigned int ne = Nx * Ny;
- unsigned int nv = ne / 2;
+ unsigned ne = Nx * Ny;
+ unsigned nv = ne / 2;
vertices.resize(nv);
edges.reserve(ne);
@@ -30,7 +30,7 @@ graph::graph(unsigned int Nx, unsigned int Ny) {
dual_vertices.resize(nv);
dual_edges.reserve(ne);
- for (unsigned int i = 0; i < nv; i++) {
+ for (unsigned i = 0; i < nv; i++) {
vertices[i].r.x = (double)((1 + i / (Nx / 2)) % 2 + 2 * (i % (Nx / 2)));
vertices[i].r.y = (double)(i / (Nx / 2));
vertices[i].polygon = {
@@ -50,18 +50,18 @@ graph::graph(unsigned int Nx, unsigned int Ny) {
};
}
- for (unsigned int y = 0; y < Ny; y++) {
- for (unsigned int x = 0; x < Nx; x++) {
- unsigned int v1 = (Nx * y) / 2 + ((x + y % 2) / 2) % (Nx / 2);
- unsigned int v2 = ((Nx * (y + 1)) / 2 + ((x + (y + 1) % 2) / 2) % (Nx / 2)) % nv;
+ for (unsigned y = 0; y < Ny; y++) {
+ for (unsigned x = 0; x < Nx; x++) {
+ unsigned v1 = (Nx * y) / 2 + ((x + y % 2) / 2) % (Nx / 2);
+ unsigned v2 = ((Nx * (y + 1)) / 2 + ((x + (y + 1) % 2) / 2) % (Nx / 2)) % nv;
bool crossed_x = x == Nx - 1;
bool crossed_y = y == Ny - 1;
edges.push_back({{v1, v2}, {0.5 + (double)x, 0.5 + (double)y}, {crossed_x, crossed_y}});
- unsigned int dv1 = (Nx * y) / 2 + ((x + (y + 1) % 2) / 2) % (Nx / 2);
- unsigned int dv2 = ((Nx * (y + 1)) / 2 + ((x + y % 2) / 2) % (Nx / 2)) % nv;
+ unsigned dv1 = (Nx * y) / 2 + ((x + (y + 1) % 2) / 2) % (Nx / 2);
+ unsigned dv2 = ((Nx * (y + 1)) / 2 + ((x + y % 2) / 2) % (Nx / 2)) % nv;
dual_edges.push_back({{dv1, dv2}, {0.5 + (double)x, 0.5 + (double)y}, {crossed_x, crossed_y}});
}
@@ -93,21 +93,21 @@ class triangleException: public std::exception
}
} triex;
-unsigned int get_triangle_signature(unsigned int j1, unsigned int j2, unsigned int j3) {
- // this yucky function takes three unsigned integers representing the
+unsigned get_triangle_signature(unsigned j1, unsigned j2, unsigned j3) {
+ // this yucky function takes three unsignedegers representing the
// location in the nine periodic copies of each corner of a delauney triangle
- // and returns a signature for that triangle, which is an unsigned integer
+ // and returns a signature for that triangle, which is an unsignedeger
// that uniquely labels the way the triangle crosses boundaries of the
// copies. This allows us to differentiate delauney triangles with identical
// vertices but which should be identified with different faces
- unsigned int x1 = j1 % 3;
- unsigned int y1 = j1 / 3;
+ unsigned x1 = j1 % 3;
+ unsigned y1 = j1 / 3;
- unsigned int x2 = j2 % 3;
- unsigned int y2 = j2 / 3;
+ unsigned x2 = j2 % 3;
+ unsigned y2 = j2 / 3;
- unsigned int x3 = j3 % 3;
- unsigned int y3 = j3 / 3;
+ unsigned x3 = j3 % 3;
+ unsigned y3 = j3 / 3;
if ((j1 == j2) && (j2 == j3)) {
return 0;
@@ -146,9 +146,9 @@ graph::graph(double Lx, double Ly, std::mt19937& rng) {
// randomly choose N to be floor(Lx * Ly / 2) or ceil(Lx * Ly / 2) with
// probability proportional to the distance from each
std::uniform_real_distribution<double> d(0.0, 1.0);
- unsigned int N = round(Lx * Ly / 2 + d(rng) - 0.5);
+ unsigned N = round(Lx * Ly / 2 + d(rng) - 0.5);
- unsigned int nv = N;
+ unsigned nv = N;
vertices.resize(nv);
// the coordinates of the lattice, from which a delaunay triangulation
@@ -164,7 +164,7 @@ graph::graph(double Lx, double Ly, std::mt19937& rng) {
jcv_rect bounds = {{-Lx, -Ly}, {2 * Lx, 2 * Ly}};
std::vector<jcv_point> points(9 * nv);
- for (unsigned int i = 0; i < nv; i++) {
+ for (unsigned i = 0; i < nv; i++) {
const vertex& v = vertices[i];
points[9 * i + 0] = {v.r.x - L.x, v.r.y - L.y};
points[9 * i + 1] = {v.r.x + 0.0, v.r.y - L.y};
@@ -181,7 +181,7 @@ graph::graph(double Lx, double Ly, std::mt19937& rng) {
const jcv_site* sites = jcv_diagram_get_sites(&diagram);
- std::unordered_map<std::array<unsigned int, 4>, unsigned int> known_vertices;
+ std::unordered_map<std::array<unsigned, 4>, unsigned> known_vertices;
for (int i = 0; i < diagram.numsites; i++) {
const jcv_site* site = &sites[i];
@@ -189,8 +189,8 @@ graph::graph(double Lx, double Ly, std::mt19937& rng) {
// we only care about processing the cells of our original, central sites
if (site->index % 9 == 4) {
bool self_bonded = false;
- unsigned int i1 = (unsigned int)(site->index / 9);
- unsigned int j1 = (unsigned int)(site->index % 9);
+ unsigned i1 = (unsigned)(site->index / 9);
+ unsigned j1 = (unsigned)(site->index % 9);
const jcv_graphedge* e = site->edges;
const jcv_graphedge* ep = site->edges;
while (ep->next) {
@@ -205,27 +205,27 @@ graph::graph(double Lx, double Ly, std::mt19937& rng) {
if (neighbor == NULL) {
throw clippingex;
}
- unsigned int i2 = (unsigned int)(neighbor->index / 9);
- unsigned int j2 = (unsigned int)(neighbor->index % 9);
- unsigned int x2 = j2 % 3;
- unsigned int y2 = j2 / 3;
+ unsigned i2 = (unsigned)(neighbor->index / 9);
+ unsigned j2 = (unsigned)(neighbor->index % 9);
+ unsigned x2 = j2 % 3;
+ unsigned y2 = j2 / 3;
vertices[i1].polygon.push_back({e->pos[0].x, e->pos[0].y});
if (ep->neighbor == NULL) {
throw clippingex;
}
- unsigned int i3p = (unsigned int)(ep->neighbor->index / 9);
- unsigned int j3p = (unsigned int)(ep->neighbor->index % 9);
+ unsigned i3p = (unsigned)(ep->neighbor->index / 9);
+ unsigned j3p = (unsigned)(ep->neighbor->index % 9);
- unsigned int sig1 = get_triangle_signature(j1, j2, j3p);
+ unsigned sig1 = get_triangle_signature(j1, j2, j3p);
- std::array<unsigned int, 4> t1 = {i1, i2, i3p, sig1};
+ std::array<unsigned, 4> t1 = {i1, i2, i3p, sig1};
std::sort(t1.begin(), t1.begin() + 3);
auto it1 = known_vertices.find(t1);
- unsigned int vi1;
+ unsigned vi1;
if (it1 == known_vertices.end()) {
vi1 = dual_vertices.size();
@@ -259,17 +259,17 @@ graph::graph(double Lx, double Ly, std::mt19937& rng) {
throw clippingex;
}
- unsigned int i3n = (unsigned int)(en->neighbor->index / 9);
- unsigned int j3n = (unsigned int)(en->neighbor->index % 9);
+ unsigned i3n = (unsigned)(en->neighbor->index / 9);
+ unsigned j3n = (unsigned)(en->neighbor->index % 9);
- unsigned int sig2 = get_triangle_signature(j1, j2, j3n);
+ unsigned sig2 = get_triangle_signature(j1, j2, j3n);
- std::array<unsigned int, 4> t2 = {i1, i2, i3n, sig2};
+ std::array<unsigned, 4> t2 = {i1, i2, i3n, sig2};
std::sort(t2.begin(), t2.begin() + 3);
auto it2 = known_vertices.find(t2);
- unsigned int vi2;
+ unsigned vi2;
if (it2 == known_vertices.end()) {
vi2 = dual_vertices.size();
@@ -279,8 +279,8 @@ graph::graph(double Lx, double Ly, std::mt19937& rng) {
vi2 = it2->second;
}
- bool dcrossed_x = (unsigned int)floor(e->pos[0].x / L.x) != (unsigned int)floor(e->pos[1].x / L.x);
- bool dcrossed_y = (unsigned int)floor(e->pos[0].y / L.y) != (unsigned int)floor(e->pos[1].y / L.y);
+ bool dcrossed_x = (unsigned)floor(e->pos[0].x / L.x) != (unsigned)floor(e->pos[1].x / L.x);
+ bool dcrossed_y = (unsigned)floor(e->pos[0].y / L.y) != (unsigned)floor(e->pos[1].y / L.y);
dual_edges.push_back({{vi1, vi2},
{mod((e->pos[0].x + e->pos[1].x) / 2, L.x),
diff --git a/lib/src/network.cpp b/lib/src/network.cpp
index 3812f43..027946a 100644
--- a/lib/src/network.cpp
+++ b/lib/src/network.cpp
@@ -3,7 +3,7 @@
network::network(const graph& G, cholmod_common *c) : c(c), G(G), fuses(G.edges.size(), false), thresholds(G.edges.size(), 1) {
b = CHOL_F(zeros)(G.vertices.size(), 1, CHOLMOD_REAL, c);
- for (unsigned int i = 0; i < G.edges.size(); i++) {
+ for (unsigned i = 0; i < G.edges.size(); i++) {
double v0y = G.vertices[G.edges[i].v[0]].r.y;
double v1y = G.vertices[G.edges[i].v[1]].r.y;
@@ -15,29 +15,29 @@ network::network(const graph& G, cholmod_common *c) : c(c), G(G), fuses(G.edges.
}
}
- unsigned int nnz = G.vertices.size() + G.edges.size();
+ unsigned nnz = G.vertices.size() + G.edges.size();
cholmod_triplet *t = CHOL_F(allocate_triplet)(G.vertices.size(), G.vertices.size(), nnz, 1, CHOLMOD_REAL, c);
- for (unsigned int i = 0; i < G.vertices.size(); i++) {
+ for (unsigned i = 0; i < G.vertices.size(); i++) {
((CHOL_INT *)t->i)[i] = i;
((CHOL_INT *)t->j)[i] = i;
((double *)t->x)[i] = 0.0;
}
- unsigned int terms = G.vertices.size();
+ unsigned terms = G.vertices.size();
- std::unordered_map<std::array<unsigned int, 2>, unsigned int> known_edges;
+ std::unordered_map<std::array<unsigned, 2>, unsigned> known_edges;
- for (unsigned int i = 0; i < G.edges.size(); i++) {
- unsigned int v0 = G.edges[i].v[0];
- unsigned int v1 = G.edges[i].v[1];
+ for (unsigned i = 0; i < G.edges.size(); i++) {
+ unsigned v0 = G.edges[i].v[0];
+ unsigned v1 = G.edges[i].v[1];
((double *)t->x)[v0]++;
((double *)t->x)[v1]++;
- unsigned int s0 = v0 < v1 ? v0 : v1;
- unsigned int s1 = v0 < v1 ? v1 : v0;
+ unsigned s0 = v0 < v1 ? v0 : v1;
+ unsigned s1 = v0 < v1 ? v1 : v0;
auto it = known_edges.find({s0, s1});
@@ -67,7 +67,7 @@ network::network(const graph& G, cholmod_common *c) : c(c), G(G), fuses(G.edges.
t->nnz = 2 * G.edges.size();
- for (unsigned int i = 0; i < G.edges.size(); i++) {
+ for (unsigned i = 0; i < G.edges.size(); i++) {
((CHOL_INT *)t->i)[2 * i] = i;
((CHOL_INT *)t->j)[2 * i] = G.edges[i].v[0];
((double *)t->x)[2 * i] = 1.0;
@@ -106,16 +106,16 @@ void network::set_thresholds(double beta, std::mt19937& rng) {
}
}
-void network::break_edge(unsigned int e, bool unbreak) {
+void network::break_edge(unsigned e, bool unbreak) {
fuses[e] = !unbreak;
- unsigned int v0 = G.edges[e].v[0];
- unsigned int v1 = G.edges[e].v[1];
+ unsigned v0 = G.edges[e].v[0];
+ unsigned v1 = G.edges[e].v[1];
- unsigned int n = factor->n;
+ unsigned n = factor->n;
cholmod_sparse *update_mat = CHOL_F(allocate_sparse)(n, n, 2, true, true, 0, CHOLMOD_REAL, c);
- unsigned int s1, s2;
+ unsigned s1, s2;
s1 = v0 < v1 ? v0 : v1;
s2 = v0 < v1 ? v1 : v0;
@@ -123,11 +123,11 @@ void network::break_edge(unsigned int e, bool unbreak) {
CHOL_INT *ii = (CHOL_INT *)update_mat->i;
double *xx = (double *)update_mat->x;
- for (unsigned int i = 0; i <= s1; i++) {
+ for (unsigned i = 0; i <= s1; i++) {
pp[i] = 0;
}
- for (unsigned int i = s1 + 1; i <= n; i++) {
+ for (unsigned i = s1 + 1; i <= n; i++) {
pp[i] = 2;
}
@@ -210,10 +210,10 @@ void network::fracture(hooks& m, double cutoff) {
break;
}
- unsigned int max_pos = UINT_MAX;
+ unsigned max_pos = UINT_MAX;
long double max_val = std::numeric_limits<long double>::lowest();
- for (unsigned int i = 0; i < G.edges.size(); i++) {
+ for (unsigned i = 0; i < G.edges.size(); i++) {
if (!fuses[i] && fabs(ci.currents[i]) > cutoff) {
long double val = logl(fabs(ci.currents[i])) - thresholds[i];
if (val > max_val) {
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<boost::undirected_tag,unsigned long>)
return true;
}
-std::list<unsigned int> find_minimal_crack(const Graph& G, const network& n) {
+std::list<unsigned> find_minimal_crack(const Graph& G, const network& n) {
Graph Gtmp(n.G.vertices.size());
- std::list<unsigned int> removed_edges;
+ std::list<unsigned> removed_edges;
class add_tree_edges : public boost::default_dfs_visitor {
public:
Graph& G;
- std::list<unsigned int>& E;
+ std::list<unsigned>& E;
- add_tree_edges(Graph& G, std::list<unsigned int>& E) : G(G), E(E) {}
+ add_tree_edges(Graph& G, std::list<unsigned>& E) : G(G), E(E) {}
void tree_edge(boost::graph_traits<Graph>::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<unsigned int> find_minimal_crack(const Graph& G, const network& n) {
class find_cycle : public boost::default_dfs_visitor {
public:
- std::list<unsigned int>& E;
- unsigned int end;
+ std::list<unsigned>& E;
+ unsigned end;
struct done{};
- find_cycle(std::list<unsigned int>& E, unsigned int end) : E(E), end(end) {}
+ find_cycle(std::list<unsigned>& E, unsigned end) : E(E), end(end) {}
void discover_vertex(boost::graph_traits<Graph>::vertex_descriptor v, const Graph& g) {
if (v == end) {
@@ -58,10 +58,10 @@ std::list<unsigned int> find_minimal_crack(const Graph& G, const network& n) {
}
};
- std::list<std::list<unsigned int>> cycles;
+ std::list<std::list<unsigned>> cycles;
for (auto edge : removed_edges) {
- std::list<unsigned int> cycle = {edge};
+ std::list<unsigned> cycle = {edge};
find_cycle vis(cycle, n.G.dual_edges[edge].v[1]);
std::vector<boost::default_color_type> new_color_map(boost::num_vertices(Gtmp));
try {
@@ -85,8 +85,8 @@ std::list<unsigned int> 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<uint8_t> new_bool_cycle = (*it1) ^ (*it2);
- std::list<unsigned int> new_cycle;
- unsigned int pos = 0;
+ std::list<unsigned> 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<unsigned int> 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<unsigned int, 2> crossing_count{0,0};
+ std::array<unsigned, 2> 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 <network.hpp>
struct EdgeProperties {
- unsigned int index;
+ unsigned index;
};
typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS, boost::no_property, EdgeProperties> Graph;
@@ -25,5 +25,5 @@ bool is_shorter(const std::list<T> &, const std::list<T> &);
bool trivial(boost::detail::edge_desc_impl<boost::undirected_tag,unsigned long>);
-std::list<unsigned int> find_minimal_crack(const Graph &, const network &);
+std::list<unsigned> 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<unsigned int> component(boost::num_vertices(G));
- unsigned int num = boost::connected_components(G, &component[0]);
+ std::vector<unsigned> component(boost::num_vertices(G));
+ unsigned num = boost::connected_components(G, &component[0]);
- std::list<unsigned int> crack = find_minimal_crack(G, n);
- unsigned int crack_component = component[n.G.dual_edges[crack.front()].v[0]];
+ std::list<unsigned> crack = find_minimal_crack(G, n);
+ unsigned crack_component = component[n.G.dual_edges[crack.front()].v[0]];
- std::vector<std::list<unsigned int>> components(num);
+ std::vector<std::list<unsigned>> 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<std::list<unsigned int>> avalanches;
+ std::list<std::list<unsigned>> 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 <iostream>
-void update_distribution_file(std::string id, const std::vector<uint64_t>& data, unsigned int N, double Lx, double Ly, double beta) {
+void update_distribution_file(std::string id, const std::vector<uint64_t>& 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<uint64_t>& 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<uint64_t>& data,
std::ofstream file_out(filename);
file_out <<std::fixed<< N_old + N << "\n";
- for (unsigned int i = 0; i < data.size(); i++) {
+ for (unsigned i = 0; i < data.size(); i++) {
file_out <<std::fixed<< data_old[i] + data[i] << " ";
}
@@ -31,7 +31,7 @@ void update_distribution_file(std::string id, const std::vector<uint64_t>& data,
}
template <class T>
-void update_field_file(std::string id, const std::vector<T>& 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<T>& 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<T>& 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<T>& data, unsigned int
file_out <<std::fixed<< N_old + N << "\n";
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_out << data_old[j][i] + data[j][i] << " ";
}
file_out << "\n";
@@ -65,8 +65,8 @@ void update_field_file(std::string id, const std::vector<T>& data, unsigned int
}
template <class T>
-std::vector<fftw_complex> data_transform(unsigned int Mx, unsigned int My, const std::vector<T>& 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<fftw_complex> data_transform(unsigned Mx, unsigned My, const std::vector<T>& 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<fftw_complex> data_transform(unsigned int Mx, unsigned int My, const
std::vector<fftw_complex> 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<fftw_complex> data_transform(unsigned int Mx, unsigned int My, const
}
template <class T>
-void correlation(unsigned int Mx, unsigned int My, std::vector<T>& data, const std::vector<fftw_complex>& tx1, const std::vector<fftw_complex>& 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<T>& data, const std::vector<fftw_complex>& tx1, const std::vector<fftw_complex>& 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 <class T>
-void autocorrelation(unsigned int Mx, unsigned int My, std::vector<std::vector<T>>& 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<std::vector<T>>& 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<std::vector<T
fftw_execute(reverse_plan);
for (unsigned j = 0; j < out_data.size(); j++) {
- 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++) {
out_data[j][i] += (T)pow(fftw_reverse_out[Mx * (i / (Mx / 2 + 1)) + i % (Mx / 2 + 1)] / (Mx * My), j + 1);
}
}
}
-unsigned int edge_r_to_ind(graph::coordinate r, double Lx, double Ly, unsigned int Mx, unsigned int My) {
+unsigned edge_r_to_ind(graph::coordinate r, double Lx, double Ly, unsigned Mx, unsigned My) {
return floor((Mx * r.x) / Lx) + Mx * floor((My * r.y) / Ly);
}
-ma::ma(double Lx, double Ly, unsigned int Mx, unsigned int My, double beta, unsigned Ncum) :
- Lx(Lx), Ly(Ly), Mx(Mx), My(My), beta(beta), G(2 * (unsigned int)ceil(Lx * Ly / 2)),
- sc(2 * (unsigned int)ceil(Lx * Ly / 2), 0),
- sa(2 * (unsigned int)ceil(Lx * Ly / 2), 0),
- sC(2 * (unsigned int)ceil(Lx * Ly / 2), 0),
- sA(2 * (unsigned int)ceil(Lx * Ly / 2), 0),
- sd(3 * (unsigned int)ceil(Lx * Ly / 2), 0),
+ma::ma(double Lx, double Ly, unsigned Mx, unsigned My, double beta, unsigned Ncum) :
+ Lx(Lx), Ly(Ly), Mx(Mx), My(My), beta(beta), G(2 * (unsigned)ceil(Lx * Ly / 2)),
+ sc(2 * (unsigned)ceil(Lx * Ly / 2), 0),
+ sa(2 * (unsigned)ceil(Lx * Ly / 2), 0),
+ sC(2 * (unsigned)ceil(Lx * Ly / 2), 0),
+ sA(2 * (unsigned)ceil(Lx * Ly / 2), 0),
+ sd(3 * (unsigned)ceil(Lx * Ly / 2), 0),
Ccc(Ncum),
Css(Ncum),
Cmm(Ncum),
@@ -195,7 +195,7 @@ void ma::pre_fracture(const network&) {
boost::remove_edge_if(trivial, G);
}
-void ma::bond_broken(const network& net, const current_info& cur, unsigned int i) {
+void ma::bond_broken(const network& net, const current_info& cur, unsigned i) {
long double c = logl(cur.conductivity / fabs(cur.currents[i])) + net.thresholds[i];
if (c > 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<unsigned int> component(boost::num_vertices(G));
- unsigned int num = boost::connected_components(G, &component[0]);
+ std::vector<unsigned> component(boost::num_vertices(G));
+ unsigned num = boost::connected_components(G, &component[0]);
- std::list<unsigned int> crack = find_minimal_crack(G, n);
+ std::list<unsigned> 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<std::list<unsigned int>> components(num);
+ std::vector<std::list<unsigned>> 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<bool(unsigned int)> inCrack = [&](unsigned int i) -> bool {
+ std::function<bool(unsigned)> 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<std::list<unsigned int>> avalanches;
+ std::list<std::list<unsigned>> 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;
};