summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fracture.c20
-rw-r--r--src/fracture.h59
2 files changed, 44 insertions, 35 deletions
diff --git a/src/fracture.c b/src/fracture.c
index 718fc05..260f04f 100644
--- a/src/fracture.c
+++ b/src/fracture.c
@@ -300,24 +300,32 @@ int main(int argc, char *argv[]) {
uint_t av_size = 0;
double cur_val = 0;
- uint_t notch_edge;
+ uint_t notch_mark = 0;
if (crack_growth_crit) {
- for (uint_t i = 0; i < net->graph->ne; i++) {
- if (net->fuses[i]) {
- notch_edge = i;
+ uint_t n_edge = UINT_MAX;
+ for (uint_t j = 0; j < g->ne; j++) {
+ // right now the only fuses broken are from a notch
+ if (net->fuses[j]) {
+ n_edge = j;
break;
}
}
+
+ if (n_edge < UINT_MAX) {
+ uint_t n_vert = g->dev[2 * n_edge];
+ notch_mark = net->dual_marks[n_vert];
+ }
}
for (uint_t j = 0; j < max_pos; j++) {
uint_t next_broken = data->break_list[j];
- bool attached_to_notch = net->dual_marks[next_broken] == net->dual_marks[notch_edge];
- bool grew_forward = net->graph->ex[2 * next_broken] > crack_len;
+ bool attached_to_notch = net->dual_marks[g->dev[2*next_broken]] == notch_mark;
+ bool grew_forward = g->ex[2 * next_broken] > crack_len;
if (crack_growth_crit && attached_to_notch && grew_forward) {
+ printf("whoops\n\n");
max_pos = j;
break;
}
diff --git a/src/fracture.h b/src/fracture.h
index f0a22e8..0b078ff 100644
--- a/src/fracture.h
+++ b/src/fracture.h
@@ -76,42 +76,42 @@ typedef struct {
double inf;
cholmod_dense *boundary_cond;
cholmod_factor *factor;
- unsigned int *marks;
- unsigned int *dual_marks;
+ uint_t *marks;
+ uint_t *dual_marks;
bool voltage_bound;
- unsigned int num_components;
+ uint_t num_components;
cholmod_sparse *adjacency;
cholmod_sparse *dual_adjacency;
bool debug_stop;
} net_t;
typedef struct {
- unsigned int num_broken;
- unsigned int *break_list;
+ uint_t num_broken;
+ uint_t *break_list;
double *conductivity;
double *extern_field;
} data_t;
-intptr_t *run_voronoi(unsigned int num_coords, double *coords, bool periodic, double xmin, double xmax, double ymin, double ymax);
+intptr_t *run_voronoi(uint_t num_coords, double *coords, bool periodic, double xmin, double xmax, double ymin, double ymax);
-int update_components(const cholmod_sparse *laplacian, unsigned int *marks,
+int update_components(const cholmod_sparse *laplacian, uint_t *marks,
int old_num_components, int v1, int v2, int exclude);
-unsigned int *find_components(const cholmod_sparse *laplacian, unsigned int skip);
+uint_t *find_components(const cholmod_sparse *laplacian, uint_t skip);
cholmod_sparse *gen_adjacency(const net_t *instance, bool dual, bool breakv,
- unsigned int pad, cholmod_common *c);
+ uint_t pad, cholmod_common *c);
cholmod_sparse *gen_laplacian(const net_t *instance, cholmod_common *c,
bool symmetric);
-int edge_to_verts(unsigned int width, bool periodic, unsigned int edge,
+int edge_to_verts(uint_t width, bool periodic, uint_t edge,
bool index);
-int dual_edge_to_verts(unsigned int width, bool periodic, unsigned int edge,
+int dual_edge_to_verts(uint_t width, bool periodic, uint_t edge,
bool index);
-double dual_vert_to_coord(unsigned int width, bool periodic, unsigned int vert,
+double dual_vert_to_coord(uint_t width, bool periodic, uint_t vert,
bool index);
void factor_update(cholmod_factor *factor, uint_t v1, uint_t v2, cholmod_common *c);
@@ -124,19 +124,19 @@ double net_conductivity(const net_t *net, const double *voltages);
void update_boundary(net_t *instance, const double *avg_field);
-FILE *get_file(const char *prefix, unsigned int width, unsigned int crack,
- double beta, unsigned int iter, unsigned int num_iter,
- unsigned int num, bool read);
+FILE *get_file(const char *prefix, uint_t width, uint_t crack,
+ double beta, uint_t iter, uint_t num_iter,
+ uint_t num, bool read);
-double update_beta(double beta, unsigned int width, const double *stress,
+double update_beta(double beta, uint_t width, const double *stress,
const double *damage, double bound_total);
-cholmod_sparse *gen_voltcurmat(unsigned int num_edges, unsigned int num_verts,
- unsigned int *edges_to_verts, cholmod_common *c);
+cholmod_sparse *gen_voltcurmat(uint_t num_edges, uint_t num_verts,
+ uint_t *edges_to_verts, cholmod_common *c);
net_t *net_copy(const net_t *net, cholmod_common *c);
-graph_t *ini_square_network(unsigned int width, bound_t boundary, bool side_bounds,
+graph_t *ini_square_network(uint_t width, bound_t boundary, bool side_bounds,
cholmod_common *c);
void graph_free(graph_t *network, cholmod_common *c);
@@ -144,29 +144,30 @@ void net_free(net_t *instance, cholmod_common *c);
net_t *net_create(const graph_t *g, double inf, double beta, double notch_len, bool vb, cholmod_common *c);
-graph_t *ini_voro_graph(unsigned int L, bound_t boundary, bool use_dual,
- double *(*genfunc)(unsigned int, bound_t, gsl_rng *, unsigned int *),
+graph_t *ini_voro_graph(uint_t L, bound_t boundary, bool use_dual,
+ double *(*genfunc)(uint_t, bound_t, gsl_rng *, uint_t *),
cholmod_common *c);
-bool break_edge(net_t *instance, unsigned int edge, cholmod_common *c);
+bool break_edge(net_t *instance, uint_t edge, cholmod_common *c);
void finish_instance(net_t *instance, cholmod_common *c);
net_t *coursegrain_square(net_t *instance, graph_t *network_p, cholmod_common *c);
-unsigned int *get_clusters(net_t *instance, cholmod_common *c);
+uint_t *get_clusters(net_t *instance, cholmod_common *c);
-unsigned int *get_cluster_dist(net_t *instance, cholmod_common *c);
+uint_t *get_cluster_dist(net_t *instance, cholmod_common *c);
-double *genfunc_uniform(unsigned int L, bound_t boundary, gsl_rng *r, unsigned int *num);
-double *genfunc_hyperuniform(unsigned int L, bound_t boundary, gsl_rng *r, unsigned int *num);
+double *genfunc_uniform(uint_t L, bound_t boundary, gsl_rng *r, uint_t *num);
+double *genfunc_hyperuniform(uint_t L, bound_t boundary, gsl_rng *r, uint_t *num);
void randfunc_flat(gsl_rng *r, double *x, double *y);
void randfunc_gaus(gsl_rng *r, double *x, double *y);
-unsigned int **get_dists(const graph_t *network);
-double *get_corr(net_t *instance, unsigned int **dists, cholmod_common *c);
+uint_t **get_dists(const graph_t *network);
+uint_t *dijkstra(const graph_t *g, uint_t source);
+double *get_corr(net_t *instance, uint_t **dists, cholmod_common *c);
-double *bin_values(graph_t *network, unsigned int width, double *values);
+double *bin_values(graph_t *network, uint_t width, double *values);
cholmod_dense *bound_set(const graph_t *g, bool vb, double notch_len, cholmod_common *c);