summaryrefslogtreecommitdiff
path: root/lib/include
diff options
context:
space:
mode:
Diffstat (limited to 'lib/include')
-rw-r--r--lib/include/current_info.hpp2
-rw-r--r--lib/include/network.hpp62
-rw-r--r--lib/include/problem.hpp38
3 files changed, 57 insertions, 45 deletions
diff --git a/lib/include/current_info.hpp b/lib/include/current_info.hpp
index 90dd3c7..a84fb5b 100644
--- a/lib/include/current_info.hpp
+++ b/lib/include/current_info.hpp
@@ -4,7 +4,7 @@
#include <vector>
typedef struct current_info {
- double conductivity;
+ std::array<double, 2> conductivity;
std::vector<double> currents;
} current_info;
diff --git a/lib/include/network.hpp b/lib/include/network.hpp
index 15cb8ea..1ffe742 100644
--- a/lib/include/network.hpp
+++ b/lib/include/network.hpp
@@ -6,44 +6,14 @@
#include <utility>
#include <random>
#include <limits>
+#include <valarray>
-#include <cholmod.h>
-
+#include "problem.hpp"
#include "graph.hpp"
#include "hooks.hpp"
#include "current_info.hpp"
#include "array_hash.hpp"
-#ifdef FRACTURE_LONGINT
-
-#define CHOL_F(x) cholmod_l_##x
-#define CHOL_INT long int
-
-#else
-
-#define CHOL_F(x) cholmod_##x
-#define CHOL_INT int
-
-#endif
-
-class problem {
- private:
- const graph& G;
- cholmod_dense* b;
- cholmod_factor* factor;
- cholmod_sparse* voltcurmat;
- cholmod_common* c;
- unsigned axis;
-
- public:
- problem(const graph&, unsigned axis, cholmod_common*);
- problem(const graph&, unsigned axis, cholmod_sparse*, cholmod_common*);
- problem(const problem&);
- ~problem();
- current_info solve(std::vector<bool>& fuses);
- void break_edge(unsigned, bool unbreak = false);
-};
-
class network {
public:
const graph& G;
@@ -54,45 +24,49 @@ class network {
network(const network&);
void set_thresholds(double, std::mt19937&);
+ void fracture(hooks&, bool one_axis = false);
+
virtual void break_edge(unsigned e, bool unbreak = false) {fuses[e] = !unbreak;};
virtual current_info get_current_info() {current_info empty; return empty;};
};
class fuse_network : public network {
- public:
- problem ohm;
+ private:
+ double weight;
+ problem ohm_x;
+ problem ohm_y;
- fuse_network(const graph&, cholmod_common*);
+ public:
+ fuse_network(const graph&, cholmod_common*, double weight = 1.0);
+ fuse_network(const fuse_network&);
- void fracture(hooks&, double cutoff = 1e-13);
+ void break_edge(unsigned, bool unbreak = false) override;
+ current_info get_current_info() override;
};
class elastic_network : public network {
private:
double weight;
- public:
problem hook_x;
problem hook_y;
- elastic_network(const graph&, cholmod_common*);
+ public:
+ elastic_network(const graph&, cholmod_common*, double weight = 0.5);
elastic_network(const elastic_network&);
- void fracture(hooks&, double weight = 0.5, double cutoff = 1e-10);
void break_edge(unsigned, bool unbreak = false) override;
current_info get_current_info() override;
};
class percolation_network : public network {
private:
- double weight;
- public:
- problem hook_x;
- problem hook_y;
+ problem px;
+ problem py;
+ public:
percolation_network(const graph&, cholmod_common*);
percolation_network(const percolation_network&);
- void fracture(hooks&, double weight = 0.5, double cutoff = 1e-10);
void break_edge(unsigned, bool unbreak = false) override;
current_info get_current_info() override;
};
diff --git a/lib/include/problem.hpp b/lib/include/problem.hpp
new file mode 100644
index 0000000..c2c9e09
--- /dev/null
+++ b/lib/include/problem.hpp
@@ -0,0 +1,38 @@
+
+#include <vector>
+#include <limits>
+
+#include <cholmod.h>
+#include "graph.hpp"
+#include "current_info.hpp"
+
+#ifdef FRACTURE_LONGINT
+
+#define CHOL_F(x) cholmod_l_##x
+#define CHOL_INT long int
+
+#else
+
+#define CHOL_F(x) cholmod_##x
+#define CHOL_INT int
+
+#endif
+
+class problem {
+ private:
+ const graph& G;
+ unsigned axis;
+ cholmod_dense* b;
+ cholmod_factor* factor;
+ cholmod_sparse* voltcurmat;
+ cholmod_common* c;
+
+ public:
+ problem(const graph&, unsigned, cholmod_common*);
+ problem(const graph&, unsigned, cholmod_sparse*, cholmod_common*);
+ problem(const problem&);
+ ~problem();
+ current_info solve(std::vector<bool>& fuses);
+ void break_edge(unsigned, bool unbreak = false);
+};
+