From 873a9f9bedbbfb07d475e271923a7b86464e515f Mon Sep 17 00:00:00 2001 From: pants Date: Wed, 7 Sep 2016 14:55:30 -0400 Subject: more major refactoring --- src/fracture.h | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'src/fracture.h') diff --git a/src/fracture.h b/src/fracture.h index a9973ea..17ab8fd 100644 --- a/src/fracture.h +++ b/src/fracture.h @@ -37,38 +37,35 @@ typedef enum bound_t { } bound_t; typedef struct { - uint_t ne; // number of edges - uint_t nv; // number of vertices - uint_t dnv; // number of dual vertices + uint_t ne; + uint_t nv; + uint_t dnv; uint_t nv_break; uint_t num_bounds; - // 2*ne length array. edge i connects vertices ev[2*i], ev[2*i+1] < nv uint_t *ev; uint_t *ev_break; - // nv+1 length array. vertex i has degree vei[i+1]-vei[i], vei[0] = 0 uint_t *vei; - // vei[nv] length array. vertex i is connected to edges ve[vei[i]+j], 0 <= j < vei[i+1]-vei[i] uint_t *ve; uint_t *bound_inds; uint_t *bound_verts; - double *vert_coords; - double *edge_coords; + double *vx; + double *ex; uint_t *dev; uint_t *dvei; uint_t *dve; - double *dual_vert_coords; + double *dvx; uint_t num_spanning_edges; uint_t *spanning_edges; - double L; + uint_t L; uint_t break_dim; cholmod_sparse *voltcurmat; bound_t boundary; } graph_t; typedef struct { - graph_t *graph; - unsigned int num_remaining_edges; + const graph_t *graph; bool *fuses; + double *thres; double inf; cholmod_dense *boundary_cond; cholmod_factor *factor; @@ -112,18 +109,13 @@ double dual_vert_to_coord(unsigned int width, bool periodic, unsigned int vert, bool update_factor(cholmod_factor *factor, unsigned int v1, unsigned int v2, cholmod_common *c); -data_t *fracture_network(net_t *instance, double *fuse_thres, - cholmod_common *c, double cutoff); +data_t *net_fracture(net_t *net, cholmod_common *c, double cutoff); double *get_current(const net_t *instance, cholmod_common *c); double *get_current_v(const net_t *instance, double *voltages, cholmod_common *c); double *get_voltage(const net_t *instance, cholmod_common *c); -double *gen_fuse_thres(unsigned int num_edges, double *edge_coords, double beta, - double (*beta_scale)(double, double, double)); - -bool gen_crack(net_t *instance, double crack_len, double crack_width, - cholmod_common *c); +void net_notch(net_t *net, double notch_len, cholmod_common *c); void update_boundary(net_t *instance, const double *avg_field); @@ -137,18 +129,17 @@ double update_beta(double beta, unsigned int width, const double *stress, cholmod_sparse *gen_voltcurmat(unsigned int num_edges, unsigned int num_verts, unsigned int *edges_to_verts, cholmod_common *c); -net_t *copy_instance(const net_t *instance, 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, cholmod_common *c); -void free_net(graph_t *network, cholmod_common *c); -void free_instance(net_t *instance, cholmod_common *c); +void graph_free(graph_t *network, cholmod_common *c); +void net_free(net_t *instance, cholmod_common *c); -net_t *create_instance(graph_t *network, double inf, bool voltage_bound, - bool startnow, 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_voronoi_network(unsigned int L, bound_t boundary, bool use_dual, +graph_t *ini_voro_graph(unsigned int L, bound_t boundary, bool use_dual, double *(*genfunc)(unsigned int, bound_t, gsl_rng *, unsigned int *), cholmod_common *c); @@ -178,7 +169,7 @@ double *get_corr(net_t *instance, unsigned int **dists, cholmod_common *c); double *bin_values(graph_t *network, unsigned int width, double *values); -void voronoi_bound_ini(net_t *instance, uint_t L, double crack_len); +cholmod_dense *bound_set(const graph_t *g, bool vb, double notch_len, cholmod_common *c); data_t *alloc_break_data(unsigned int num_edges); void free_break_data(data_t *data); @@ -186,4 +177,3 @@ void update_break_data(data_t *data, unsigned int last_broke, double strength, d double get_conductivity(net_t *inst, double *current, cholmod_common *c); -void gen_voro_crack(net_t *instance, double crack_len, cholmod_common *c); -- cgit v1.2.3-70-g09d2