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/compare_voronoi_fracture.c | 124 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 src/compare_voronoi_fracture.c (limited to 'src/compare_voronoi_fracture.c') diff --git a/src/compare_voronoi_fracture.c b/src/compare_voronoi_fracture.c new file mode 100644 index 0000000..5578987 --- /dev/null +++ b/src/compare_voronoi_fracture.c @@ -0,0 +1,124 @@ + + +#include "fracture.h" + +int main(int argc, char *argv[]) { + int opt; + + // defining variables to be (potentially) set by command line flags + unsigned int N, L, filename_len; + double beta, inf, cutoff; + boundary_type boundary; + + filename_len = 100; + + N = 100; + L = 16; + beta = .3; + inf = 1e10; + cutoff = 1e-10; + boundary = FREE_BOUND; + + int boundary_int; + char boundc2 = 'f'; + + while ((opt = getopt(argc, argv, "n:L:b:B:dcoNsCrt")) != -1) { + switch (opt) { + case 'n': + N = atoi(optarg); + break; + case 'L': + L = atoi(optarg); + break; + case 'b': + beta = atof(optarg); + break; + case 'B': + boundary_int = atoi(optarg); + switch (boundary_int) { + case 0: + boundary = FREE_BOUND; + boundc2 = 'f'; + break; + case 1: + boundary = CYLINDER_BOUND; + boundc2 = 'c'; + break; + default: + printf("boundary specifier must be 0 (FREE_BOUND) or 1 (CYLINDER_BOUND).\n"); + } + break; + default: /* '?' */ + exit(EXIT_FAILURE); + } + } + + char *break_filename = (char *)malloc(filename_len * sizeof(char)); + snprintf(break_filename, filename_len, "breaks_v_vc_%c_%u_%g.txt", boundc2, L, beta); + FILE *break_out = fopen(break_filename, "a"); + free(break_filename); + + + // start cholmod + cholmod_common c; + CHOL_F(start)(&c); + + (&c)->supernodal = CHOLMOD_SIMPLICIAL; + + + fnet *network = ini_voronoi_network(L, boundary, genfunc_hyperuniform, &c); + finst *perm_voltage_instance = create_instance(network, inf, true, true, &c); + finst *perm_current_instance = create_instance(network, inf, false, true, &c); + double *fuse_thres = gen_fuse_thres(network->num_edges, network->edge_coords, beta, beta_scaling_flat); + finst *voltage_instance = copy_instance(perm_voltage_instance, &c); + finst *current_instance = copy_instance(perm_current_instance, &c); + break_data *breaking_data_voltage = fracture_network(voltage_instance, fuse_thres, &c, cutoff); + break_data *breaking_data_current = fracture_network(current_instance, fuse_thres, &c, cutoff); + free_instance(voltage_instance, &c); + free_instance(current_instance, &c); + free_instance(perm_voltage_instance, &c); + free_instance(perm_current_instance, &c); + free(fuse_thres); + + FILE *net_out = fopen("network.txt", "w"); + for (unsigned int j = 0; j < network->num_verts; j++) { + fprintf(net_out, "%f %f ", network->vert_coords[2 * j], + network->vert_coords[2 * j + 1]); + } + fprintf(net_out, "\n"); + for (unsigned int j = 0; j < network->num_edges; j++) { + fprintf(net_out, "%u %u ", network->edges_to_verts[2 * j], + network->edges_to_verts[2 * j + 1]); + } + fprintf(net_out, "\n"); + for (unsigned int j = 0; j < network->num_dual_verts; j++) { + fprintf(net_out, "%f %f ", network->dual_vert_coords[2 * j], + network->dual_vert_coords[2 * j + 1]); + } + fprintf(net_out, "\n"); + for (unsigned int j = 0; j < network->num_edges; j++) { + fprintf(net_out, "%u %u ", network->dual_edges_to_verts[2 * j], + network->dual_edges_to_verts[2 * j + 1]); + } + + free_fnet(network, &c); + + for (unsigned int j = 0; j < breaking_data_voltage->num_broken; j++) { + fprintf(break_out, "%u %g %g ", breaking_data_voltage->break_list[j], + breaking_data_voltage->extern_field[j], breaking_data_voltage->conductivity[j]); + } + fprintf(break_out, "\n"); + for (unsigned int j = 0; j < breaking_data_current->num_broken; j++) { + fprintf(break_out, "%u %g %g ", breaking_data_current->break_list[j], + breaking_data_current->extern_field[j], breaking_data_current->conductivity[j]); + } + fprintf(break_out, "\n"); + + free_break_data(breaking_data_voltage); + free_break_data(breaking_data_current); + fclose(break_out); + + CHOL_F(finish)(&c); + + return 0; +} -- cgit v1.2.3-70-g09d2