From 3ece960188d478d71a880339dba70407a5d0f034 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Fri, 23 Jun 2017 00:00:14 -0400 Subject: ran clang-format --- lib/net_fracture.c | 89 +++++++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 44 deletions(-) (limited to 'lib/net_fracture.c') diff --git a/lib/net_fracture.c b/lib/net_fracture.c index e7f18fc..65ede9b 100644 --- a/lib/net_fracture.c +++ b/lib/net_fracture.c @@ -2,66 +2,67 @@ #include "fracture.h" uint_t get_next_broken(net_t *net, double *currents, double cutoff) { - uint_t max_pos = UINT_MAX; - long double max_val = 0; + uint_t max_pos = UINT_MAX; + long double max_val = 0; - for (uint_t i = 0; i < net->graph->ne; i++) { - long double current = fabs(currents[i]); - bool broken = net->fuses[i]; + for (uint_t i = 0; i < net->graph->ne; i++) { + long double current = fabs(currents[i]); + bool broken = net->fuses[i]; - if (!broken && current > cutoff) { - long double val = current / net->thres[i]; + if (!broken && current > cutoff) { + long double val = current / net->thres[i]; - if (val > max_val) { - max_val = val; - max_pos = i; - } - } - } + if (val > max_val) { + max_val = val; + max_pos = i; + } + } + } - if (max_pos == UINT_MAX) { - printf("GET_NEXT_BROKEN: currents is zero or NaN, no max_val found\n"); - exit(EXIT_FAILURE); - } + if (max_pos == UINT_MAX) { + printf("GET_NEXT_BROKEN: currents is zero or NaN, no max_val found\n"); + exit(EXIT_FAILURE); + } - return max_pos; + return max_pos; } data_t *net_fracture(net_t *net, cholmod_common *c, double cutoff) { - data_t *data = data_create(net->graph->ne); + data_t *data = data_create(net->graph->ne); - uint_t n = 0; - while (true) { - n++; - double *voltages = net_voltages(net, c); - double *currents = net_currents(net, voltages, c); + uint_t n = 0; + while (true) { + n++; + double *voltages = net_voltages(net, c); + double *currents = net_currents(net, voltages, c); - double conductivity = net_conductivity(net, voltages); + double conductivity = net_conductivity(net, voltages); - if (conductivity < cutoff) { - free(voltages); - free(currents); - break; - } + if (conductivity < cutoff) { + free(voltages); + free(currents); + break; + } - uint_t last_broke = get_next_broken(net, currents, cutoff); + uint_t last_broke = get_next_broken(net, currents, cutoff); - long double sim_current; + long double sim_current; - if (net->voltage_bound) { - sim_current = conductivity; - } else { - sim_current = 1; - } + if (net->voltage_bound) { + sim_current = conductivity; + } else { + sim_current = 1; + } - data_update(data, last_broke, fabsl(sim_current * (net->thres)[last_broke] / ((long double)currents[last_broke])), conductivity); + data_update(data, last_broke, fabsl(sim_current * (net->thres)[last_broke] / + ((long double)currents[last_broke])), + conductivity); - free(voltages); - free(currents); + free(voltages); + free(currents); - break_edge(net, last_broke, c); - } + break_edge(net, last_broke, c); + } - return data; + return data; } - -- cgit v1.2.3-70-g09d2