summaryrefslogtreecommitdiff
path: root/lib/include
diff options
context:
space:
mode:
Diffstat (limited to 'lib/include')
-rw-r--r--lib/include/array_hash.hpp34
-rw-r--r--lib/include/clusters.hpp2
-rw-r--r--lib/include/graph.hpp79
-rw-r--r--lib/include/hooks.hpp9
-rw-r--r--lib/include/network.hpp61
-rw-r--r--lib/include/problem.hpp41
6 files changed, 110 insertions, 116 deletions
diff --git a/lib/include/array_hash.hpp b/lib/include/array_hash.hpp
index 3b35e4a..fd0d0f7 100644
--- a/lib/include/array_hash.hpp
+++ b/lib/include/array_hash.hpp
@@ -4,24 +4,18 @@
#include <array>
#include <unordered_map>
-namespace std
-{
- template<typename T, size_t N>
- struct hash<array<T, N> >
- {
- typedef array<T, N> argument_type;
- typedef size_t result_type;
-
- result_type operator()(const argument_type& a) const
- {
- hash<T> hasher;
- result_type h = 0;
- for (result_type i = 0; i < N; ++i)
- {
- h = h * 31 + hasher(a[i]);
- }
- return h;
- }
- };
-}
+namespace std {
+template <typename T, size_t N> struct hash<array<T, N>> {
+ typedef array<T, N> argument_type;
+ typedef size_t result_type;
+ result_type operator()(const argument_type& a) const {
+ hash<T> hasher;
+ result_type h = 0;
+ for (result_type i = 0; i < N; ++i) {
+ h = h * 31 + hasher(a[i]);
+ }
+ return h;
+ }
+};
+} // namespace std
diff --git a/lib/include/clusters.hpp b/lib/include/clusters.hpp
index 4cc9073..0c562d8 100644
--- a/lib/include/clusters.hpp
+++ b/lib/include/clusters.hpp
@@ -1,6 +1,6 @@
-#include <vector>
#include "graph.hpp"
+#include <vector>
class ClusterTree {
private:
diff --git a/lib/include/graph.hpp b/lib/include/graph.hpp
index 0452339..9d2b5a1 100644
--- a/lib/include/graph.hpp
+++ b/lib/include/graph.hpp
@@ -1,50 +1,49 @@
#pragma once
-#include <cmath>
-#include <vector>
+#include <algorithm>
#include <array>
-#include <unordered_map>
-#include <random>
-#include <list>
+#include <cmath>
#include <exception>
-#include <algorithm>
+#include <list>
+#include <random>
+#include <unordered_map>
+#include <vector>
#include "array_hash.hpp"
class graph {
- public:
- typedef struct coordinate {
- double x;
- double y;
- } coordinate;
-
- typedef struct vertex {
- coordinate r;
- std::vector<unsigned> nd;
- std::vector<unsigned> ne;
- std::vector<coordinate> polygon;
- } vertex;
-
- typedef struct edge {
- std::array<unsigned, 2> v;
- coordinate r;
- std::array<bool, 2> crossings;
- } edge;
-
- coordinate L;
-
- std::vector<vertex> vertices;
- std::vector<edge> edges;
-
- std::vector<vertex> dual_vertices;
- std::vector<edge> dual_edges;
-
- graph(unsigned Nx, unsigned Ny);
- graph(double Lx, double Ly, std::mt19937& rng);
- graph(unsigned n, double a, std::mt19937& rng);
-
- void helper(unsigned n, std::mt19937& rng);
- graph const rotate();
+public:
+ typedef struct coordinate {
+ double x;
+ double y;
+ } coordinate;
+
+ typedef struct vertex {
+ coordinate r;
+ std::vector<unsigned> nd;
+ std::vector<unsigned> ne;
+ std::vector<coordinate> polygon;
+ } vertex;
+
+ typedef struct edge {
+ std::array<unsigned, 2> v;
+ coordinate r;
+ std::array<bool, 2> crossings;
+ } edge;
+
+ coordinate L;
+
+ std::vector<vertex> vertices;
+ std::vector<edge> edges;
+
+ std::vector<vertex> dual_vertices;
+ std::vector<edge> dual_edges;
+
+ graph(unsigned Nx, unsigned Ny);
+ graph(double Lx, double Ly, std::mt19937& rng);
+ graph(unsigned n, double a, std::mt19937& rng);
+
+ void helper(unsigned n, std::mt19937& rng);
+ graph const rotate();
};
-
diff --git a/lib/include/hooks.hpp b/lib/include/hooks.hpp
index 67313cc..ba85ff7 100644
--- a/lib/include/hooks.hpp
+++ b/lib/include/hooks.hpp
@@ -6,9 +6,8 @@
class network;
class hooks {
- public:
- virtual void pre_fracture(const network&) {};
- virtual void bond_broken(const network&, const current_info&, unsigned) {};
- virtual void post_fracture(network&) {}; // post fracture hook can be destructive
+public:
+ virtual void pre_fracture(const network&){};
+ 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 8748ea9..29bf55a 100644
--- a/lib/include/network.hpp
+++ b/lib/include/network.hpp
@@ -1,20 +1,20 @@
#pragma once
-#include <vector>
#include <functional>
-#include <utility>
-#include <random>
#include <limits>
-#include <valarray>
+#include <random>
#include <set>
+#include <utility>
+#include <valarray>
+#include <vector>
-#include "problem.hpp"
-#include "graph.hpp"
-#include "hooks.hpp"
-#include "current_info.hpp"
#include "array_hash.hpp"
#include "clusters.hpp"
+#include "current_info.hpp"
+#include "graph.hpp"
+#include "hooks.hpp"
+#include "problem.hpp"
#define CURRENT_CUTOFF 1e-10
@@ -27,7 +27,7 @@ class network {
friend class elastic_network;
friend class percolation_network;
- private:
+private:
problem px;
problem py;
std::unordered_map<std::array<unsigned, 2>, bool> seen_pairs;
@@ -36,14 +36,15 @@ class network {
void break_edge(unsigned, bool unbreak = false);
void get_cycle_edges_helper(std::set<unsigned>&, std::set<unsigned>&, unsigned, unsigned) const;
std::set<unsigned> get_cycle_edges(unsigned) const;
- bool find_cycle_helper(std::array<unsigned, 2>&, const std::set<unsigned>&, unsigned, unsigned, unsigned) const;
+ bool find_cycle_helper(std::array<unsigned, 2>&, const std::set<unsigned>&, unsigned, unsigned,
+ unsigned) const;
std::array<unsigned, 2> find_cycle(const std::set<unsigned>&, unsigned, unsigned) const;
void get_cluster_edges_helper(std::set<unsigned>&, unsigned) const;
std::set<unsigned> get_cluster_edges(unsigned) const;
void get_tie_flaps_helper(std::set<unsigned>&, unsigned, unsigned) const;
std::list<std::set<unsigned>> get_tie_flaps(unsigned) const;
- public:
+public:
const graph& G;
ClusterTree C;
@@ -57,36 +58,38 @@ class network {
void set_thresholds(double, std::mt19937&);
void fracture(hooks&, bool one_axis = true);
- virtual current_info get_current_info() {current_info empty; return empty;};
+ virtual current_info get_current_info() {
+ current_info empty;
+ return empty;
+ };
};
class fuse_network : public network {
- private:
- double weight;
+private:
+ double weight;
- public:
- fuse_network(const graph&, cholmod_common*, double weight = 1.0);
- fuse_network(const fuse_network&);
+public:
+ fuse_network(const graph&, cholmod_common*, double weight = 1.0);
+ fuse_network(const fuse_network&);
- current_info get_current_info() override;
+ current_info get_current_info() override;
};
class elastic_network : public network {
- private:
- double weight;
+private:
+ double weight;
- public:
- elastic_network(const graph&, cholmod_common*, double weight = 0.5);
- elastic_network(const elastic_network&);
+public:
+ elastic_network(const graph&, cholmod_common*, double weight = 0.5);
+ elastic_network(const elastic_network&);
- current_info get_current_info() override;
+ current_info get_current_info() override;
};
class percolation_network : public network {
- public:
- percolation_network(const graph&, cholmod_common*);
- percolation_network(const percolation_network&);
+public:
+ percolation_network(const graph&, cholmod_common*);
+ percolation_network(const percolation_network&);
- current_info get_current_info() override;
+ current_info get_current_info() override;
};
-
diff --git a/lib/include/problem.hpp b/lib/include/problem.hpp
index 740751d..c454a35 100644
--- a/lib/include/problem.hpp
+++ b/lib/include/problem.hpp
@@ -1,10 +1,10 @@
-#include <vector>
#include <limits>
+#include <vector>
-#include <cholmod.h>
-#include "graph.hpp"
#include "current_info.hpp"
+#include "graph.hpp"
+#include <cholmod.h>
#ifdef FRACTURE_LONGINT
@@ -19,22 +19,21 @@
#endif
class problem {
- private:
- const graph& G;
- unsigned axis;
- cholmod_dense* b;
- cholmod_factor* factor;
- cholmod_sparse* voltcurmat;
- cholmod_common* c;
-
- public:
- current_info sol;
-
- problem(const graph&, unsigned, cholmod_common*);
- problem(const graph&, unsigned, cholmod_sparse*, cholmod_common*);
- problem(const problem&);
- ~problem();
- void solve(std::vector<bool>& fuses);
- void break_edge(unsigned, bool unbreak = false);
+private:
+ const graph& G;
+ unsigned axis;
+ cholmod_dense* b;
+ cholmod_factor* factor;
+ cholmod_sparse* voltcurmat;
+ cholmod_common* c;
+
+public:
+ current_info sol;
+
+ problem(const graph&, unsigned, cholmod_common*);
+ problem(const graph&, unsigned, cholmod_sparse*, cholmod_common*);
+ problem(const problem&);
+ ~problem();
+ void solve(std::vector<bool>& fuses);
+ void break_edge(unsigned, bool unbreak = false);
};
-