From 2bb0740b68fdb62d45adc00204b3990ca42ade77 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 22 Aug 2016 10:11:14 -0400 Subject: started repo again without all the data files gunking the works --- src/fracture.h | 182 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 src/fracture.h (limited to 'src/fracture.h') diff --git a/src/fracture.h b/src/fracture.h new file mode 100644 index 0000000..4ee7050 --- /dev/null +++ b/src/fracture.h @@ -0,0 +1,182 @@ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// these two defs allow me to switch to long int cholmod in a sitch +#define CHOL_INT long int +#define CHOL_F(x) cholmod_l_##x + +typedef enum boundary_type { + FREE_BOUND, + CYLINDER_BOUND, + TORUS_BOUND +} boundary_type; + +typedef struct { + unsigned int num_edges; + unsigned int num_verts; + unsigned int num_verts_break; + unsigned int num_bounds; + unsigned int *edges_to_verts; + unsigned int *edges_to_verts_break; + unsigned int *verts_to_edges_ind; + unsigned int *verts_to_edges; + unsigned int *bound_inds; + unsigned int *bound_verts; + double *vert_coords; + double *edge_coords; + unsigned int *dual_edges_to_verts; + unsigned int *dual_verts_to_edges_ind; + unsigned int *dual_verts_to_edges; + double *dual_vert_coords; + unsigned int num_spanning_edges; + unsigned int *spanning_edges; + double L; + unsigned int num_dual_verts; + unsigned int break_dim; + cholmod_sparse *voltcurmat; + boundary_type boundary; +} fnet; + +typedef struct { + fnet *network; + unsigned int num_remaining_edges; + bool *fuses; + double inf; + cholmod_dense *boundary_cond; + cholmod_factor *factor; + unsigned int *marks; + unsigned int *dual_marks; + bool voltage_bound; + unsigned int num_components; + cholmod_sparse *adjacency; + bool debug_stop; +} finst; + +typedef struct { + unsigned int num_broken; + unsigned int *break_list; + double *conductivity; + double *extern_field; +} break_data; + +intptr_t *run_voronoi(unsigned int num_coords, double *coords, double xmin, double xmax, double ymin, double ymax); + +int update_components(const cholmod_sparse *laplacian, unsigned int *marks, + int old_num_components, int v1, int v2, int exclude); + +unsigned int *find_components(const cholmod_sparse *laplacian, unsigned int skip); + +cholmod_sparse *gen_adjacency(const finst *instance, bool dual, bool breakv, + unsigned int pad, cholmod_common *c); + +cholmod_sparse *gen_laplacian(const finst *instance, cholmod_common *c, + bool symmetric); + +int edge_to_verts(unsigned int width, bool periodic, unsigned int edge, + bool index); + +int dual_edge_to_verts(unsigned int width, bool periodic, unsigned int edge, + bool index); + +double dual_vert_to_coord(unsigned int width, bool periodic, unsigned int vert, + bool index); + +bool update_factor(cholmod_factor *factor, unsigned int v1, unsigned int v2, + cholmod_common *c); + +break_data *fracture_network(finst *instance, double *fuse_thres, + cholmod_common *c, double cutoff); + +double *get_current(const finst *instance, cholmod_common *c); +double *get_current_v(const finst *instance, double *voltages, cholmod_common *c); +double *get_voltage(const finst *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(finst *instance, double crack_len, double crack_width, + cholmod_common *c); + +void update_boundary(finst *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); + +double update_beta(double beta, unsigned int 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); + +finst *copy_instance(const finst *instance, cholmod_common *c); + +fnet *ini_square_network(unsigned int width, boundary_type boundary, bool side_bounds, + cholmod_common *c); + +void free_fnet(fnet *network, cholmod_common *c); +void free_instance(finst *instance, cholmod_common *c); + +finst *create_instance(fnet *network, double inf, bool voltage_bound, + bool startnow, cholmod_common *c); + +fnet *ini_voronoi_network(unsigned int L, boundary_type boundary, + double *(*genfunc)(unsigned int, gsl_rng *, unsigned int *), + cholmod_common *c); + +bool check_instance(const finst *instance, cholmod_common *c); + +bool break_edge(finst *instance, unsigned int edge, cholmod_common *c); + +void finish_instance(finst *instance, cholmod_common *c); + +finst *coursegrain_square(finst *instance, fnet *network_p, cholmod_common *c); + +unsigned int *get_clusters(finst *instance, cholmod_common *c); + +unsigned int *get_cluster_dist(finst *instance, cholmod_common *c); + +double *genfunc_uniform(unsigned int L, gsl_rng *r, unsigned int *num); +double *genfunc_hyperuniform(unsigned int L, gsl_rng *r, unsigned int *num); +void randfunc_flat(gsl_rng *r, double *x, double *y); +void randfunc_gaus(gsl_rng *r, double *x, double *y); +double beta_scaling_flat(double beta, double x, double y); +double beta_scaling_gaus(double beta, double x, double y); +double beta_mag(double beta); + +unsigned int *dijkstra(fnet *network, unsigned int source); +unsigned int **get_dists(fnet *network); +double *get_corr(finst *instance, unsigned int **dists, cholmod_common *c); + +double *bin_values(fnet *network, unsigned int width, double *values); + +void voronoi_bound_ini(finst *instance, double *square_bound, + unsigned int width); + +break_data *alloc_break_data(unsigned int num_edges); +void free_break_data(break_data *data); +void update_break_data(break_data *data, unsigned int last_broke, double strength, double conductivity); + +double get_conductivity(finst *inst, double *current, cholmod_common *c); -- cgit v1.2.3-70-g09d2