Introduction
Introduction Statistics Contact Development Disclaimer Help
tgranularpacking.c - granular - granular dynamics simulation
git clone git://src.adamsgaard.dk/granular
Log
Files
Refs
README
LICENSE
---
tgranularpacking.c (1896B)
---
1 #include <stdlib.h>
2 #include <err.h>
3 #include <unistd.h>
4 #include "granular.h"
5 #include "arg.h"
6
7 char *argv0;
8
9 static void
10 usage(void)
11 {
12 errx(1, "usage: %s "
13 "[-D max-diameter] "
14 "[-d min-diameter] "
15 "[-hP] "
16 "[-p padding-factor] "
17 "[-t] "
18 "[-X x-offset] "
19 "[-x nx] "
20 "[-Y y-offset] "
21 "[-y ny] "
22 "[-Z z-offset] "
23 "[-z nz]", argv0);
24 }
25
26 int
27 main(int argc, char *argv[])
28 {
29 size_t n[] = {10, 10, 1};
30 double origo[] = {0.0, 0.0, 0.0};
31 double padding = 0.0;
32 double d_max = 1.0, d_min = 1.0;
33 struct simulation sim = sim_new();
34 int packing = 0;
35 double (*sizefunc)(double min, double max) = random_value_unifor…
36
37 #ifdef __OpenBSD__
38 if (pledge("stdio", NULL) == -1)
39 err(2, "pledge")
40 #endif
41
42 ARGBEGIN {
43 case 'D':
44 d_max = atof(EARGF(usage()));
45 break;
46 case 'd':
47 d_min = atof(EARGF(usage()));
48 break;
49 case 'h':
50 usage();
51 break;
52 case 'P':
53 sizefunc = (*random_value_powerlaw);
54 break;
55 case 'p':
56 padding = atof(EARGF(usage()));
57 break;
58 case 't':
59 packing = 1;
60 break;
61 case 'X':
62 origo[0] = atof(EARGF(usage()));
63 break;
64 case 'x':
65 n[0] = atoi(EARGF(usage()));
66 break;
67 case 'Y':
68 origo[1] = atof(EARGF(usage()));
69 break;
70 case 'y':
71 n[1] = atoi(EARGF(usage()));
72 break;
73 case 'Z':
74 origo[2] = atof(EARGF(usage()));
75 break;
76 case 'z':
77 n[2] = atoi(EARGF(usage()));
78 break;
79 default:
80 usage();
81 } ARGEND;
82
83 if (argc > 1)
84 usage();
85
86 switch (packing) {
87 case 0:
88 sim.ng += rectangular_packing(&sim.grains, n,
89 d_min / 2.0, d_max / 2.0,
90 sizefunc, padding, origo);
91 break;
92 case 1:
93 sim.ng += triangular_packing(&sim.grains, n,
94 d_min / 2.0, d_max / 2.0,
95 sizefunc, padding, origo);
96 break;
97 default:
98 errx(1, "unknown packing mode");
99 }
100
101 sim_print_grains(&sim, stdout);
102 sim_free(&sim);
103
104 return 0;
105 }
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.