tpacking.c: fix malloc in 3d triangular packing and fix indentation - granular … | |
git clone git://src.adamsgaard.dk/granular | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 512cf441b47308e28c16512418bccf09855cb678 | |
parent 8401ff2fdbcfb36e625fe2154bf287f9e5777ff5 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Fri, 19 Mar 2021 18:37:37 +0100 | |
packing.c: fix malloc in 3d triangular packing and fix indentation | |
Diffstat: | |
M packing.c | 36 ++++++++++++++++-------------… | |
1 file changed, 18 insertions(+), 18 deletions(-) | |
--- | |
diff --git a/packing.c b/packing.c | |
t@@ -64,27 +64,27 @@ triangular_packing(struct grain *grains[], | |
errx(1, "%s: radius_max (%g) is smaller than radius_min (%g)", | |
__func__, radius_max, radius_min); | |
- if (!(*grains = calloc(n[0] * n[1], sizeof(struct grain)))) | |
+ if (!(*grains = calloc(n[0] * n[1] * n[2], sizeof(struct grain)))) | |
err(1, "%s: grains calloc", __func__); | |
- for (k = 0; k < n[2]; k++) | |
- for (j = 0; j < n[1]; j++) | |
- for (i = 0; i < n[0]; i++) { | |
- N++; | |
- np = idx3(i, j, k, n[0], n[1]); | |
- grain_defaults(&(*grains)[np]); | |
- (*grains)[np].radius = gsd(radius_min,… | |
- (*grains)[np].pos[0] = i * dx + 0.5 * … | |
- if (j % 2 == 0) | |
- (*grains)[np].pos[0] += 0.5 * … | |
- (*grains)[np].pos[1] = j * dy + 0.5 * … | |
- (*grains)[np].pos[2] = k * dx + 0.5 * … | |
- for (l = 0; l < 2; l++) | |
- (*grains)[np].pos[l] += | |
- random_value_uniform(-… | |
- … | |
+ for (k = 0; k < n[2]; k++) | |
+ for (j = 0; j < n[1]; j++) | |
+ for (i = 0; i < n[0]; i++) { | |
+ N++; | |
+ np = idx3(i, j, k, n[0], n[1]); | |
+ grain_defaults(&(*grains)[np]); | |
+ (*grains)[np].radius = gsd(radius_min, radius_… | |
+ (*grains)[np].pos[0] = i * dx + 0.5 * dx + ori… | |
+ if (j % 2 == 0) | |
+ (*grains)[np].pos[0] += 0.5 * dx; | |
+ (*grains)[np].pos[1] = j * dy + 0.5 * dx + ori… | |
+ (*grains)[np].pos[2] = k * dx + 0.5 * dx + ori… | |
+ for (l = 0; l < 2; l++) | |
+ (*grains)[np].pos[l] += | |
+ random_value_uniform(-0.5 * dx… | |
+ … | |
#ifdef VERBOSE | |
- printf("added grain %zu\n", np); | |
+ printf("added grain %zu\n", np); | |
#endif | |
} | |