summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpants <jaron@kent-dobias.com>2016-08-30 13:57:08 -0400
committerpants <jaron@kent-dobias.com>2016-08-30 13:57:08 -0400
commitc2164e4a38b79c8a02bd7c0f4481f222c7b4dae6 (patch)
treebfc884782ff1171f1987deef09fcc137e4e9db29
parent68c9e7c4937d391cad533a4e417bd11bfdb1e8b7 (diff)
downloadfuse_networks-c2164e4a38b79c8a02bd7c0f4481f222c7b4dae6.tar.gz
fuse_networks-c2164e4a38b79c8a02bd7c0f4481f222c7b4dae6.tar.bz2
fuse_networks-c2164e4a38b79c8a02bd7c0f4481f222c7b4dae6.zip
added ability to fracture triangulation instead of tiling
-rw-r--r--src/fracture.h2
-rw-r--r--src/homo_voronoi_fracture.c10
-rw-r--r--src/ini_network.c20
3 files changed, 27 insertions, 5 deletions
diff --git a/src/fracture.h b/src/fracture.h
index 4ee7050..fea0caf 100644
--- a/src/fracture.h
+++ b/src/fracture.h
@@ -142,7 +142,7 @@ 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,
+fnet *ini_voronoi_network(unsigned int L, boundary_type boundary, bool use_dual,
double *(*genfunc)(unsigned int, gsl_rng *, unsigned int *),
cholmod_common *c);
diff --git a/src/homo_voronoi_fracture.c b/src/homo_voronoi_fracture.c
index 4ba0244..4e2d67a 100644
--- a/src/homo_voronoi_fracture.c
+++ b/src/homo_voronoi_fracture.c
@@ -9,7 +9,7 @@ int main(int argc, char *argv[]) {
unsigned int N, L, filename_len;
double beta, inf, cutoff;
boundary_type boundary;
- bool include_breaking, save_cluster_dist, use_voltage_boundaries, save_network,
+ bool include_breaking, save_cluster_dist, use_voltage_boundaries, use_dual, save_network,
save_crit_stress, save_toughness, save_corr, save_conductivity,
save_damage;
@@ -24,6 +24,7 @@ int main(int argc, char *argv[]) {
include_breaking = false;
save_cluster_dist = false;
use_voltage_boundaries = false;
+ use_dual = false;
save_network = false;
save_crit_stress = false;
save_damage = false;
@@ -34,7 +35,7 @@ int main(int argc, char *argv[]) {
int boundary_int;
char boundc2 = 'f';
- while ((opt = getopt(argc, argv, "n:L:b:B:dVcoNsCrt")) != -1) {
+ while ((opt = getopt(argc, argv, "n:L:b:B:dVcoNsCrtD")) != -1) {
switch (opt) {
case 'n':
N = atoi(optarg);
@@ -71,6 +72,9 @@ int main(int argc, char *argv[]) {
case 'V':
use_voltage_boundaries = true;
break;
+ case 'D':
+ use_dual = true;
+ break;
case 'c':
save_cluster_dist = true;
break;
@@ -203,7 +207,7 @@ 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);
- fnet *network = ini_voronoi_network(L, boundary, genfunc_hyperuniform, &c);
+ fnet *network = ini_voronoi_network(L, boundary, use_dual, genfunc_hyperuniform, &c);
finst *perm_instance = create_instance(network, inf, use_voltage_boundaries, true, &c);
double *fuse_thres = gen_fuse_thres(network->num_edges, network->edge_coords, beta, beta_scaling_flat);
finst *instance = copy_instance(perm_instance, &c);
diff --git a/src/ini_network.c b/src/ini_network.c
index 0434d98..f1dbe70 100644
--- a/src/ini_network.c
+++ b/src/ini_network.c
@@ -300,7 +300,7 @@ unsigned int *get_voro_dual_edges(unsigned int num_edges,
return dual_edges;
}
-fnet *ini_voronoi_network(unsigned int L, boundary_type boundary,
+fnet *ini_voronoi_network(unsigned int L, boundary_type boundary, bool use_dual,
double *(*genfunc)(unsigned int, gsl_rng *, unsigned int *),
cholmod_common *c) {
fnet *network = (fnet *)calloc(1, sizeof(fnet));
@@ -337,6 +337,24 @@ fnet *ini_voronoi_network(unsigned int L, boundary_type boundary,
unsigned int *tmp_dual_edges =
get_voro_dual_edges(tmp_num_edges, tmp_num_verts, tmp_edges, tmp_tris);
+ // when use_dual is specificed, the edge and vertex sets are swapped with the
+ // dual edge and dual vertex sets. once formally relabelled, everything
+ // works the same way
+ if (use_dual) {
+ unsigned int *tmp_tmp_dual_edges = tmp_edges;
+ double *tmp_lattice = tmp_vert_coords;
+ unsigned int tmp_num = tmp_num_verts;
+
+ tmp_edges = tmp_dual_edges;
+ tmp_dual_edges = tmp_tmp_dual_edges;
+
+ tmp_vert_coords = lattice;
+ lattice = tmp_lattice;
+
+ tmp_num_verts = num;
+ num = tmp_num;
+ }
+
// prune the edges of the lattice and assign boundary vertices based on the
// desired boundary conditions
unsigned int num_bounds;