diff options
author | pants <jaron@kent-dobias.com> | 2016-09-06 15:05:27 -0400 |
---|---|---|
committer | pants <jaron@kent-dobias.com> | 2016-09-06 15:05:27 -0400 |
commit | 4c4ebb87ead363d6d6e11a8b95b07a0f93af5c88 (patch) | |
tree | 9cdaaf27917c2b1562740dec501d013e47a25dd1 /src/current_scaling.c | |
parent | fd14c5e39d962be94a1f68b0d4cacb7a4aa9c3e7 (diff) | |
download | fuse_networks-4c4ebb87ead363d6d6e11a8b95b07a0f93af5c88.tar.gz fuse_networks-4c4ebb87ead363d6d6e11a8b95b07a0f93af5c88.tar.bz2 fuse_networks-4c4ebb87ead363d6d6e11a8b95b07a0f93af5c88.zip |
finished implementing embedded systems, refactored a bunch
Diffstat (limited to 'src/current_scaling.c')
-rw-r--r-- | src/current_scaling.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/current_scaling.c b/src/current_scaling.c index 6837f6b..f750cb1 100644 --- a/src/current_scaling.c +++ b/src/current_scaling.c @@ -87,15 +87,15 @@ int main(int argc, char *argv[]) { (&c)->supernodal = CHOLMOD_SIMPLICIAL; } - fnet *network = ini_square_network(width, false, true, &c); - finst *perm_instance = + graph_t *network = ini_square_network(width, false, true, &c); + net_t *perm_instance = create_instance(network, inf, voltage_bound, false, &c); gen_crack(perm_instance, crack_len, 1, &c); finish_instance(perm_instance, &c); if (voltage_bound) { (&c)->supernodal = CHOLMOD_SIMPLICIAL; - finst *tmp_instance = create_instance(network, inf, false, false, &c); + net_t *tmp_instance = create_instance(network, inf, false, false, &c); gen_crack(tmp_instance, crack_len, 1, &c); finish_instance(tmp_instance, &c); double *voltage = get_voltage(tmp_instance, &c); @@ -113,14 +113,14 @@ int main(int argc, char *argv[]) { if (supplied_bound) { FILE *bound_f = fopen(bound_file, "r"); - for (int i = 0; i < network->num_verts; i++) { + for (int i = 0; i < network->nv; i++) { double tmp; fscanf(bound_f, "%lg ", &tmp); ((double *)perm_instance->boundary_cond->x)[i] = tmp; } - ((double *)perm_instance->boundary_cond->x)[network->num_verts] = 0; - ((double *)perm_instance->boundary_cond->x)[network->num_verts + 1] = 0; + ((double *)perm_instance->boundary_cond->x)[network->nv] = 0; + ((double *)perm_instance->boundary_cond->x)[network->nv + 1] = 0; fclose(bound_f); } @@ -134,25 +134,25 @@ int main(int argc, char *argv[]) { double *damage; if (save_damage) { - damage = (double *)calloc(network->num_edges, sizeof(double)); + damage = (double *)calloc(network->ne, sizeof(double)); } - double *avg_current = (double *)calloc(network->num_edges, sizeof(double)); + double *avg_current = (double *)calloc(network->ne, sizeof(double)); unsigned int *num_current_skipped = - (unsigned int *)calloc(network->num_edges, sizeof(unsigned int)); - double *avg_voltage = (double *)calloc(network->num_verts, sizeof(double)); + (unsigned int *)calloc(network->ne, sizeof(unsigned int)); + double *avg_voltage = (double *)calloc(network->nv, sizeof(double)); unsigned int *num_voltage_skipped = - (unsigned int *)calloc(network->num_verts, sizeof(unsigned int)); + (unsigned int *)calloc(network->nv, sizeof(unsigned int)); for (int DUMB = 0; DUMB < num; DUMB++) { printf("\033[F\033[JCURRENT_SCALING: ITERATION %0*d: %0*d / %d\n", (int)log10(iter) + 1, DUMB2 + 1, (int)log10(num) + 1, DUMB + 1, num); - break_data *breaking_data = NULL; + data_t *breaking_data = NULL; while (breaking_data == NULL) { double *fuse_thres = gen_fuse_thres( - network->num_edges, network->edge_coords, beta, beta_scaling_flat); - finst *instance = copy_instance(perm_instance, &c); + network->ne, network->edge_coords, beta, beta_scaling_flat); + net_t *instance = copy_instance(perm_instance, &c); breaking_data = fracture_network(instance, fuse_thres, &c, cutoff); free_instance(instance, &c); free(fuse_thres); @@ -173,7 +173,7 @@ int main(int argc, char *argv[]) { strength[DUMB] = fabs(breaking_data->extern_field[min_pos]); } - finst *tmp_instance = copy_instance(perm_instance, &c); + net_t *tmp_instance = copy_instance(perm_instance, &c); unsigned int until = min_pos; if (use_first) @@ -188,14 +188,14 @@ int main(int argc, char *argv[]) { double *voltage = get_voltage(tmp_instance, &c); double *current = get_current(tmp_instance, &c); - for (unsigned int i = 0; i < network->num_edges; i++) { + for (unsigned int i = 0; i < network->ne; i++) { avg_current[i] += current[i]; if (current[i] == 0) num_current_skipped[i]++; } - for (unsigned int i = 0; i < network->num_verts; i++) { - if (tmp_instance->marks[i] == tmp_instance->marks[network->num_verts]) { + for (unsigned int i = 0; i < network->nv; i++) { + if (tmp_instance->marks[i] == tmp_instance->marks[network->nv]) { avg_voltage[i] += voltage[i]; } else { num_voltage_skipped[i]++; @@ -210,13 +210,13 @@ int main(int argc, char *argv[]) { free(breaking_data); } - for (int i = 0; i < network->num_edges; i++) { + for (int i = 0; i < network->ne; i++) { if (num_current_skipped[i] < num) { avg_current[i] /= num - num_current_skipped[i]; } } - for (int i = 0; i < network->num_verts; i++) { + for (int i = 0; i < network->nv; i++) { if (num_voltage_skipped[i] < num) { avg_voltage[i] /= num - num_voltage_skipped[i]; } @@ -235,7 +235,7 @@ int main(int argc, char *argv[]) { snprintf(c_filename, 100, "current_%d_%g_%d_%g.txt", width, crack_len, iter, beta); FILE *outfile = fopen(c_filename, "w"); - for (int i = 0; i < network->num_edges; i++) { + for (int i = 0; i < network->ne; i++) { fprintf(outfile, "%g ", avg_current[i]); } fclose(outfile); @@ -247,7 +247,7 @@ int main(int argc, char *argv[]) { snprintf(c_filename, 100, "damage_%d_%g_%d_%g.txt", width, crack_len, iter, beta); FILE *outfile = fopen(c_filename, "w"); - for (int i = 0; i < network->num_edges; i++) { + for (int i = 0; i < network->ne; i++) { fprintf(outfile, "%g ", damage[i]); } fclose(outfile); @@ -270,7 +270,7 @@ int main(int argc, char *argv[]) { snprintf(b_filename, 100, "bounds_%d_%g_%d_%g.txt", width, crack_len, iter, beta); FILE *outfile = fopen(b_filename, "w"); - for (int i = 0; i < network->num_verts; i++) { + for (int i = 0; i < network->nv; i++) { fprintf(outfile, "%g ", ((double *)perm_instance->boundary_cond->x)[i]); } fclose(outfile); @@ -292,7 +292,7 @@ int main(int argc, char *argv[]) { } free_instance(perm_instance, &c); - free_fnet(network, &c); + free_net(network, &c); CHOL_F(finish)(&c); |