From 1c72acfda984f73ddc96d51596f9e761a963944a Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 23 Sep 2019 23:40:02 -0400 Subject: ran clang-format --- lib/include/array_hash.hpp | 34 ++++++++------------ lib/include/clusters.hpp | 2 +- lib/include/graph.hpp | 79 +++++++++++++++++++++++----------------------- lib/include/hooks.hpp | 9 +++--- lib/include/network.hpp | 61 ++++++++++++++++++----------------- lib/include/problem.hpp | 41 ++++++++++++------------ 6 files changed, 110 insertions(+), 116 deletions(-) (limited to 'lib/include') 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 #include -namespace std -{ - template - struct hash > - { - typedef array argument_type; - typedef size_t result_type; - - result_type operator()(const argument_type& a) const - { - hash hasher; - result_type h = 0; - for (result_type i = 0; i < N; ++i) - { - h = h * 31 + hasher(a[i]); - } - return h; - } - }; -} +namespace std { +template struct hash> { + typedef array argument_type; + typedef size_t result_type; + result_type operator()(const argument_type& a) const { + hash 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 #include "graph.hpp" +#include 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 -#include +#include #include -#include -#include -#include +#include #include -#include +#include +#include +#include +#include #include "array_hash.hpp" class graph { - public: - typedef struct coordinate { - double x; - double y; - } coordinate; - - typedef struct vertex { - coordinate r; - std::vector nd; - std::vector ne; - std::vector polygon; - } vertex; - - typedef struct edge { - std::array v; - coordinate r; - std::array crossings; - } edge; - - coordinate L; - - std::vector vertices; - std::vector edges; - - std::vector dual_vertices; - std::vector 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 nd; + std::vector ne; + std::vector polygon; + } vertex; + + typedef struct edge { + std::array v; + coordinate r; + std::array crossings; + } edge; + + coordinate L; + + std::vector vertices; + std::vector edges; + + std::vector dual_vertices; + std::vector 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 #include -#include -#include #include -#include +#include #include +#include +#include +#include -#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, bool> seen_pairs; @@ -36,14 +36,15 @@ class network { void break_edge(unsigned, bool unbreak = false); void get_cycle_edges_helper(std::set&, std::set&, unsigned, unsigned) const; std::set get_cycle_edges(unsigned) const; - bool find_cycle_helper(std::array&, const std::set&, unsigned, unsigned, unsigned) const; + bool find_cycle_helper(std::array&, const std::set&, unsigned, unsigned, + unsigned) const; std::array find_cycle(const std::set&, unsigned, unsigned) const; void get_cluster_edges_helper(std::set&, unsigned) const; std::set get_cluster_edges(unsigned) const; void get_tie_flaps_helper(std::set&, unsigned, unsigned) const; std::list> 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 #include +#include -#include -#include "graph.hpp" #include "current_info.hpp" +#include "graph.hpp" +#include #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& 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& fuses); + void break_edge(unsigned, bool unbreak = false); }; - -- cgit v1.2.3-70-g09d2