From f861195c1416220c4039bda4d1cbf8c3aab07528 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Sun, 24 Feb 2019 17:19:52 -0500 Subject: added support for specifiying voronoi graphs with number of points and aspect ratio, and added support for "infinite" beta (everything has the some threshold) --- src/fracture.cpp | 74 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 19 deletions(-) (limited to 'src/fracture.cpp') diff --git a/src/fracture.cpp b/src/fracture.cpp index 53a11a5..b1bde45 100644 --- a/src/fracture.cpp +++ b/src/fracture.cpp @@ -35,7 +35,11 @@ int main(int argc, char* argv[]) { double Ly = 16; double beta = 0.5; - while ((opt = getopt(argc, argv, "N:X:Y:b:")) != -1) { + unsigned n = 128; + double a = 1.0; + bool use_aN = false; + + while ((opt = getopt(argc, argv, "N:X:Y:b:n:a:")) != -1) { switch (opt) { case 'N': N = (unsigned)atof(optarg); @@ -49,6 +53,14 @@ int main(int argc, char* argv[]) { case 'b': beta = atof(optarg); break; + case 'n': + n = (unsigned)atof(optarg); + use_aN = true; + break; + case 'a': + a = atof(optarg); + use_aN = true; + break; default: exit(1); } @@ -57,30 +69,54 @@ int main(int argc, char* argv[]) { cholmod_common c; CHOL_F(start)(&c); - // fourier transforms of powers of two are faster - unsigned Mx = pow(2, ceil(log2(4*Lx))); - unsigned My = pow(2, ceil(log2(4*Ly))); - - ma meas(Lx, Ly, Mx, My, beta); - randutils::auto_seed_128 seeds; std::mt19937 rng{seeds}; - for (unsigned trial = 0; trial < N; trial++) { - while (true) { - try { - graph G(Lx, Ly, rng); - network network(G, &c); - network.set_thresholds(beta, rng); - network.fracture(meas); - break; - } catch (std::exception &e) { - std::cout << e.what() << '\n'; + if (use_aN) { + unsigned Mx = pow(2, ceil(log2(4*2*n*a))); + unsigned My = pow(2, ceil(log2(4*2*n/a))); + + ma meas(n, a, Mx, My, beta); + + for (unsigned trial = 0; trial < N; trial++) { + while (true) { + try { + graph G(n, a, rng); + network network(G, &c); + network.set_thresholds(beta, rng); + network.fracture(meas); + break; + } catch (std::exception &e) { + std::cout << e.what() << '\n'; + } } + + if (quit.load()) + break; } + } else { + // fourier transforms of powers of two are faster + unsigned Mx = pow(2, ceil(log2(4*Lx))); + unsigned My = pow(2, ceil(log2(4*Ly))); + + ma meas(Lx, Ly, Mx, My, beta); + + for (unsigned trial = 0; trial < N; trial++) { + while (true) { + try { + graph G(Lx, Ly, rng); + network network(G, &c); + network.set_thresholds(beta, rng); + network.fracture(meas); + break; + } catch (std::exception &e) { + std::cout << e.what() << '\n'; + } + } - if (quit.load()) - break; + if (quit.load()) + break; + } } CHOL_F(finish)(&c); -- cgit v1.2.3-70-g09d2