Introduction
Introduction Statistics Contact Development Disclaimer Help
tgranularpacking.c: add powerlaw option and fix diameter options - granular - g…
git clone git://src.adamsgaard.dk/granular
Log
Files
Refs
README
LICENSE
---
commit 2be85b00f5f100ff705fda0948ac89e973ff9636
parent 39fd8dcf8a449c4d6b3c828267e3cd413b2648e6
Author: Anders Damsgaard <[email protected]>
Date: Thu, 25 Mar 2021 20:41:46 +0100
granularpacking.c: add powerlaw option and fix diameter options
Diffstat:
M granularpacking.1 | 8 ++++++--
M granularpacking.c | 32 +++++++++++++++++++----------…
M util.h | 2 +-
3 files changed, 27 insertions(+), 15 deletions(-)
---
diff --git a/granularpacking.1 b/granularpacking.1
t@@ -6,10 +6,12 @@
.Nd generate a packing of granular data
.Sh SYNOPSIS
.Nm
-.Op Fl h
-.Op Fl t
.Op Fl D Ar max-diameter
.Op Fl d Ar min-diameter
+.Op Fl h
+.Op Fl P
+.Op Fl p Ar padding-factor
+.Op Fl t
.Op Fl X Ar x-offset
.Op Fl x Ar nx
.Op Fl Y Ar y-offset
t@@ -34,6 +36,8 @@ Specify minimum size of generated grains (default 1.0).
Show help text.
.It Fl t
Generate triangular packing (default: rectangular).
+.It Fl P
+Draw random diameters using a power-law distribution (default: uniform).
.It Fl p Ar padding-factor
Add padding between grains and add corresponding random variation
to placement with the specified multiplier, respective to the grain
diff --git a/granularpacking.c b/granularpacking.c
t@@ -13,10 +13,12 @@ char *argv0;
static void
usage(void)
{
- errx(1, "usage: %s [-ht] "
+ errx(1, "usage: %s "
"[-D max-diameter] "
"[-d min-diameter] "
+ "[-hP] "
"[-p padding-factor] "
+ "[-t] "
"[-X x-offset] "
"[-x nx] "
"[-Y y-offset] "
t@@ -31,26 +33,30 @@ main(int argc, char *argv[])
size_t n[] = {10, 10, 1};
double origo[] = {0.0, 0.0, 0.0};
double padding = 0.0;
- double r_max = 1.0, r_min = 1.0;
+ double d_max = 1.0, d_min = 1.0;
struct simulation sim = sim_new();
int packing = 0;
+ double (*sizefunc)(double min, double max) = random_value_uniform;
ARGBEGIN {
+ case 'D':
+ d_max = atof(EARGF(usage()));
+ break;
+ case 'd':
+ d_min = atof(EARGF(usage()));
+ break;
case 'h':
usage();
break;
+ case 'P':
+ sizefunc = (*random_value_powerlaw);
+ break;
case 'p':
padding = atof(EARGF(usage()));
break;
case 't':
packing = 1;
break;
- case 'R':
- r_max = atof(EARGF(usage()));
- break;
- case 'r':
- r_min = atof(EARGF(usage()));
- break;
case 'X':
origo[0] = atof(EARGF(usage()));
break;
t@@ -78,12 +84,14 @@ main(int argc, char *argv[])
switch (packing) {
case 0:
- sim.np += rectangular_packing(&sim.grains, n, r_min, r_max,
- random_value_uniform, padding, o…
+ sim.np += rectangular_packing(&sim.grains, n,
+ d_min / 2.0, d_max / 2.0,
+ sizefunc, padding, origo);
break;
case 1:
- sim.np += triangular_packing(&sim.grains, n, r_min, r_max,
- random_value_uniform, padding, or…
+ sim.np += triangular_packing(&sim.grains, n,
+ d_min / 2.0, d_max / 2.0,
+ sizefunc, padding, origo);
break;
default:
errx(1, "unknown packing mode");
diff --git a/util.h b/util.h
t@@ -13,7 +13,7 @@ void check_int_non_negative(const char name[], const int val…
double residual(const double new_val, const double old_val);
double random_value_uniform(double min, double max);
-double random_value_powerlaw(double power, double min, double max);
+double random_value_powerlaw(double min, double max);
void * xreallocarray(void *m, size_t n, size_t s);
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.