summaryrefslogtreecommitdiff
path: root/src/animate_fracture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/animate_fracture.cpp')
-rw-r--r--src/animate_fracture.cpp72
1 files changed, 45 insertions, 27 deletions
diff --git a/src/animate_fracture.cpp b/src/animate_fracture.cpp
index 2b5e55c..e8de8c1 100644
--- a/src/animate_fracture.cpp
+++ b/src/animate_fracture.cpp
@@ -15,39 +15,48 @@
#include <cstring>
#include <atomic>
-std::atomic<bool> quit(false); // signal flag
-
-void got_signal(int) {
- quit.store(true);
-}
-
int main(int argc, char* argv[]) {
- struct sigaction sa;
- memset( &sa, 0, sizeof(sa) );
- sa.sa_handler = got_signal;
- sigfillset(&sa.sa_mask);
- sigaction(SIGINT, &sa, NULL);
-
int opt;
unsigned N = 1;
- unsigned n = 16;
- double a = 16.0;
+ unsigned Lx = 16;
+ unsigned Ly = 16;
double beta = 0.5;
- while ((opt = getopt(argc, argv, "n:a:N:b:")) != -1) {
+ unsigned n = 128;
+ double a = 1.0;
+ bool use_aN = false;
+ double w = 0.5;
+
+ unsigned width = 800;
+
+ while ((opt = getopt(argc, argv, "N:X:Y:b:n:a:w:W:")) != -1) {
switch (opt) {
case 'N':
N = (unsigned)atof(optarg);
break;
+ case 'X':
+ Lx = atoi(optarg);
+ break;
+ case 'Y':
+ Ly = atoi(optarg);
+ break;
+ case 'b':
+ beta = atof(optarg);
+ break;
case 'n':
- n = atoi(optarg);
+ n = (unsigned)atof(optarg);
+ use_aN = true;
break;
case 'a':
a = atof(optarg);
+ use_aN = true;
break;
- case 'b':
- beta = atof(optarg);
+ case 'w':
+ w = atof(optarg);
+ break;
+ case 'W':
+ width = atoi(optarg);
break;
default:
exit(1);
@@ -57,19 +66,28 @@ int main(int argc, char* argv[]) {
cholmod_common c;
CHOL_F(start)(&c);
- animate meas(sqrt(2*n *a), sqrt( 2*n / a), 1000, argc, argv);
-
randutils::auto_seed_128 seeds;
std::mt19937 rng{seeds};
- for (unsigned trial = 0; trial < N; trial++) {
- graph G(n, a, rng);
- elastic_network elastic_network(G, &c);
- elastic_network.set_thresholds(beta, rng);
- elastic_network.fracture(meas);
+ if (use_aN) {
+ animate meas(sqrt(2*n *a), sqrt( 2*n / a), width, argc, argv);
- if (quit.load())
- break;
+ for (unsigned trial = 0; trial < N; trial++) {
+ graph G(n, a, rng);
+ elastic_network net(G, &c, w);
+ net.set_thresholds(beta, rng);
+ net.fracture(meas);
+ }
+ } else {
+ animate meas(Lx, Ly, width, argc, argv);
+ const graph G(Lx, Ly);
+ const elastic_network plain_net(G, &c, w);
+
+ for (unsigned trial = 0; trial < N; trial++) {
+ elastic_network net = plain_net;
+ net.set_thresholds(beta, rng);
+ net.fracture(meas);
+ }
}
CHOL_F(finish)(&c);