From 4c4ebb87ead363d6d6e11a8b95b07a0f93af5c88 Mon Sep 17 00:00:00 2001 From: pants Date: Tue, 6 Sep 2016 15:05:27 -0400 Subject: finished implementing embedded systems, refactored a bunch --- src/homo_square_fracture.c | 50 +++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src/homo_square_fracture.c') diff --git a/src/homo_square_fracture.c b/src/homo_square_fracture.c index 9103317..e3e8ad3 100644 --- a/src/homo_square_fracture.c +++ b/src/homo_square_fracture.c @@ -126,10 +126,10 @@ int main(int argc, char *argv[]) { } - fnet *network = ini_square_network(L, boundary, false, &c); - finst *perm_instance = create_instance(network, inf, use_voltage_boundaries, true, &c); - unsigned int c_dist_size = network->num_dual_verts; - unsigned int a_dist_size = network->num_verts; + graph_t *network = ini_square_network(L, boundary, false, &c); + net_t *perm_instance = create_instance(network, inf, use_voltage_boundaries, true, &c); + unsigned int c_dist_size = network->dnv; + unsigned int a_dist_size = network->nv; // define arrays for saving cluster and avalanche distributions unsigned int *cluster_size_dist; @@ -193,9 +193,9 @@ int main(int argc, char *argv[]) { for (unsigned int i = 0; i < N; i++) { printf("\033[F\033[JFRACTURE: %0*d / %d\n", (int)log10(N) + 1, i + 1, N); - double *fuse_thres = gen_fuse_thres(network->num_edges, network->edge_coords, beta, beta_scaling_flat); - finst *instance = copy_instance(perm_instance, &c); - break_data *breaking_data = fracture_network(instance, fuse_thres, &c, cutoff); + double *fuse_thres = gen_fuse_thres(network->ne, network->edge_coords, beta, beta_scaling_flat); + net_t *instance = copy_instance(perm_instance, &c); + data_t *breaking_data = fracture_network(instance, fuse_thres, &c, cutoff); free_instance(instance, &c); free(fuse_thres); @@ -216,7 +216,7 @@ int main(int argc, char *argv[]) { breaking_data->extern_field[max_pos]; } - finst *tmp_instance = copy_instance(perm_instance, &c); + net_t *tmp_instance = copy_instance(perm_instance, &c); unsigned int av_size = 0; double cur_val = DBL_MAX; @@ -240,7 +240,7 @@ int main(int argc, char *argv[]) { if (save_conductivity) { if (!use_voltage_boundaries) { double *tmp_voltage = get_voltage(tmp_instance, &c); - conductivity[i] = 1/fabs(tmp_voltage[tmp_instance->network->num_verts + 1] - tmp_voltage[tmp_instance->network->num_verts]); + conductivity[i] = 1/fabs(tmp_voltage[tmp_instance->graph->nv + 1] - tmp_voltage[tmp_instance->graph->nv]); free(tmp_voltage); } else { conductivity[i] = breaking_data->conductivity[max_pos]; @@ -265,12 +265,12 @@ int main(int argc, char *argv[]) { } if (save_damage) { - damage[i] = ((double)max_pos) / tmp_instance->network->num_edges; + damage[i] = ((double)max_pos) / tmp_instance->graph->ne; } if (save_cluster_dist) { unsigned int *tmp_cluster_dist = get_cluster_dist(tmp_instance, &c); - for (unsigned int j = 0; j < tmp_instance->network->num_dual_verts; j++) { + for (unsigned int j = 0; j < tmp_instance->graph->dnv; j++) { cluster_size_dist[j] += tmp_cluster_dist[j]; } free(tmp_cluster_dist); @@ -278,7 +278,7 @@ int main(int argc, char *argv[]) { if (save_corr) { double *tmp_corr = get_corr(tmp_instance, dists, &c); - for (unsigned int j = 0; j < tmp_instance->network->num_dual_verts; j++) { + for (unsigned int j = 0; j < tmp_instance->graph->dnv; j++) { avg_corr[i] += tmp_corr[j] / N; } free(tmp_corr); @@ -286,27 +286,27 @@ int main(int argc, char *argv[]) { if (save_network) { FILE *net_out = fopen("network.txt", "w"); - for (unsigned int j = 0; j < network->num_verts; j++) { + for (unsigned int j = 0; j < network->nv; j++) { fprintf(net_out, "%f %f ", network->vert_coords[2 * j], - tmp_instance->network->vert_coords[2 * j + 1]); + tmp_instance->graph->vert_coords[2 * j + 1]); } fprintf(net_out, "\n"); - for (unsigned int j = 0; j < tmp_instance->network->num_edges; j++) { - fprintf(net_out, "%u %u ", tmp_instance->network->edges_to_verts[2 * j], - tmp_instance->network->edges_to_verts[2 * j + 1]); + for (unsigned int j = 0; j < tmp_instance->graph->ne; j++) { + fprintf(net_out, "%u %u ", tmp_instance->graph->ev[2 * j], + tmp_instance->graph->ev[2 * j + 1]); } fprintf(net_out, "\n"); - for (unsigned int j = 0; j < tmp_instance->network->num_dual_verts; j++) { - fprintf(net_out, "%f %f ", tmp_instance->network->dual_vert_coords[2 * j], - tmp_instance->network->dual_vert_coords[2 * j + 1]); + for (unsigned int j = 0; j < tmp_instance->graph->dnv; j++) { + fprintf(net_out, "%f %f ", tmp_instance->graph->dual_vert_coords[2 * j], + tmp_instance->graph->dual_vert_coords[2 * j + 1]); } fprintf(net_out, "\n"); - for (unsigned int j = 0; j < tmp_instance->network->num_edges; j++) { - fprintf(net_out, "%u %u ", tmp_instance->network->dual_edges_to_verts[2 * j], - tmp_instance->network->dual_edges_to_verts[2 * j + 1]); + for (unsigned int j = 0; j < tmp_instance->graph->ne; j++) { + fprintf(net_out, "%u %u ", tmp_instance->graph->dev[2 * j], + tmp_instance->graph->dev[2 * j + 1]); } fprintf(net_out, "\n"); - for (unsigned int j = 0; j < tmp_instance->network->num_edges; j++) { + for (unsigned int j = 0; j < tmp_instance->graph->ne; j++) { fprintf(net_out, "%d ", tmp_instance->fuses[j]); } fclose(net_out); @@ -328,7 +328,7 @@ int main(int argc, char *argv[]) { printf("\033[F\033[JFRACTURE: COMPLETE\n"); free_instance(perm_instance, &c); - free_fnet(network, &c); + free_net(network, &c); if (save_cluster_dist) { FILE *cluster_out = fopen(c_filename, "w"); -- cgit v1.2.3-70-g09d2