summaryrefslogtreecommitdiff
path: root/lib/include/network.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/include/network.hpp')
-rw-r--r--lib/include/network.hpp62
1 files changed, 18 insertions, 44 deletions
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;
};