tuse diameter instead of radius in granular(5) format - granular - granular dynamics simulation
(HTM) git clone git://src.adamsgaard.dk/granular
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 4a19dc89eaa19b3f3b61c14805371cbbdf9f35ac
(DIR) parent d870e1e1b84ce4097a00fa48fafceb556257c323
(HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Thu, 25 Mar 2021 18:09:38 +0100
use diameter instead of radius in granular(5) format
Diffstat:
M grain.c | 11 +++++++----
M granular.5 | 2 +-
M granular2pdf | 2 +-
M granularpacking.1 | 14 +++++++++-----
4 files changed, 18 insertions(+), 11 deletions(-)
---
(DIR) diff --git a/grain.c b/grain.c
t@@ -22,7 +22,7 @@ grain_defaults(struct grain *g)
{
size_t i;
- g->radius = 1.0;
+ g->radius = 0.5;
for (i = 0; i < 3; i++) {
g->pos[i]
= g->vel[i]
t@@ -73,7 +73,7 @@ print_padded_nd_int(FILE *stream, const size_t *arr)
void
grain_print(FILE *stream, const struct grain *g)
{
- fprintf(stream, "%.*g\t", FLOATPREC, g->radius);
+ fprintf(stream, "%.*g\t", FLOATPREC, g->radius * 2.0);
print_padded_nd_double(stream, g->pos);
print_padded_nd_double(stream, g->vel);
print_padded_nd_double(stream, g->acc);
t@@ -104,12 +104,13 @@ grain_print(FILE *stream, const struct grain *g)
struct grain *
grain_read(char *line)
{
+ double diameter;
struct grain *g;
if (!(g = malloc(sizeof(struct grain))))
err(1, "%s: grain malloc", __func__);
- if (sscanf(line, "%lg\t" /* radius */
+ if (sscanf(line, "%lg\t" /* 2.0 * radius */
"%lg\t%lg\t%lg\t" /* pos */
"%lg\t%lg\t%lg\t" /* vel */
"%lg\t%lg\t%lg\t" /* acc */
t@@ -135,7 +136,7 @@ grain_read(char *line)
"%lg\t%lg\t%lg\t" /* contact_stress */
"%lg\t" /* thermal_energy */
"%d\n", /* color */
- &g->radius,
+ &diameter,
&g->pos[0], &g->pos[1], &g->pos[2],
&g->vel[0], &g->vel[1], &g->vel[2],
&g->acc[0], &g->acc[1], &g->acc[2],
t@@ -163,6 +164,8 @@ grain_read(char *line)
&g->color) != 50)
errx(1, "%s: could not read line: %s", __func__, line);
+ g->radius = 0.5 * diameter;
+
if (grain_check_values(g))
errx(1, "%s: invalid values in grain line: %s", __func__, line);
(DIR) diff --git a/granular.5 b/granular.5
t@@ -16,7 +16,7 @@ The order, content, and units of the fields are:
.Pp
.Bl -enum -width Ss -compact
.It
-radius [m]
+diameter [m]
.It
position, x [m]
.It
(DIR) diff --git a/granular2pdf b/granular2pdf
t@@ -1,6 +1,6 @@
#!/bin/sh
-awk -F' ' '{print $2, $3, $1, $1*2.0}' \
+awk -F' ' '{print $2, $3, $1 / 2.0, $1}' \
| gnuplot -e "set term pdf;\
set xlabel 'x [m]';\
set ylabel 'y [m]';\
(DIR) diff --git a/granularpacking.1 b/granularpacking.1
t@@ -8,6 +8,8 @@
.Nm
.Op Fl h
.Op Fl t
+.Op Fl D Ar max-radius
+.Op Fl d Ar min-radius
.Op Fl X Ar x-offset
.Op Fl x Ar nx
.Op Fl Y Ar y-offset
t@@ -24,16 +26,18 @@ format.
.Pp
The options are as wollows:
.Bl -tag -width Ds
+.It Fl D Ar max-radius
+Specify maximum diameter of generated grains (default 1.0).
+.It Fl d Ar min-radius
+Specify minimum diameter of generated grains (default 1.0).
.It Fl h
Show help text.
.It Fl t
Generate triangular packing (default: rectangular).
.It Fl p Ar padding-factor
-Add padding between grains and add corresponding random variation to placement with the specified multiplier, respective to thegrain radius (default 0.0).
-.It Fl R Ar max-radius
-Specify maximum radius of generated grains (default 1.0).
-.It Fl r Ar min-radius
-Specify minimum radius of generated grains (default 1.0).
+Add padding between grains and add corresponding random variation
+to placement with the specified multiplier, respective to the grain
+radius (default 0.0).
.It Fl X Ar x-offset
Add the specified offset to all output x positions (default 0.0).
.It Fl x Ar nx