tMerge branch 'master' of src.adamsgaard.dk:src/1d_fd_simple_shear - cngf-pf - … | |
git clone git://src.adamsgaard.dk/cngf-pf | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit cf09a47ec659fcea6e7f35ddb1fcb442e55a72e6 | |
parent 0e50f90cc1bafdc83a03a8a8f7d8f0d9f36492c0 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Wed, 13 Nov 2019 21:32:35 +0100 | |
Merge branch 'master' of src.adamsgaard.dk:src/1d_fd_simple_shear | |
Diffstat: | |
M README.md | 16 ++++++++++------ | |
M main.c | 18 ++++++++++++++++++ | |
2 files changed, 28 insertions(+), 6 deletions(-) | |
--- | |
diff --git a/README.md b/README.md | |
t@@ -1,14 +1,18 @@ | |
# 1d_fd_simple_shear | |
-[![pipeline status](https://gitlab.com/admesg/1d_fd_simple_shear/badges/master… | |
This project contains a 1d implementation of the [Henann and Kamrin | |
-2013](https://doi.org/10.1073/pnas.1219153110) model under simple shear, with | |
-various extensions such as diffusive fluid coupling and cohesion. | |
+2013](https://doi.org/10.1073/pnas.1219153110) model under | |
+simple shear, with various extensions such as diffusive | |
+fluid coupling and cohesion. The granular material is | |
+assumed to be in the critical state with constant porosity. See | |
+[1d_fd_simple_shear_transient](https://src.adamsgaard.dk/1d_fd_simple_shear_tr… | |
+for a second version with variable porosity and strength. | |
## How to run | |
-The implementation in C requires a C99-compatible compiler (e.g. `gcc` or | |
-`clang`). Visualization requires `gnuplot`. To run, simply run `make` in this | |
-directory and an output PNG figure is generated. | |
+The implementation in C requires a C99-compatible compiler (e.g. `gcc` | |
+or `clang`). Visualization requires `gnuplot`. Tests can be run with | |
+`make test`, and examples (found in the `examples/` directory) can be | |
+run with `make examples`. | |
### Advanced usage | |
The majority of simulation parameters can be adjusted from the command line: | |
diff --git a/main.c b/main.c | |
t@@ -4,6 +4,7 @@ | |
#include <math.h> | |
#include <getopt.h> | |
#include <string.h> | |
+#include <time.h> | |
#include "simulation.h" | |
#include "fluid.h" | |
t@@ -25,6 +26,9 @@ | |
#define RTOL_STRESS 1e-3 | |
#define MAX_ITER_STRESS 20000 | |
+/* uncomment to print time spent per time step to stdout */ | |
+/*#define BENCHMARK_PERFORMANCE*/ | |
+ | |
static void | |
usage(void) | |
{ | |
t@@ -140,6 +144,10 @@ main(int argc, char* argv[]) | |
const char* optstring; | |
unsigned long iter, stressiter; | |
double new_phi, new_k, filetimeclock, res_norm, mu_wall_orig; | |
+#ifdef BENCHMARK_PERFORMANCE | |
+ clock_t t_begin, t_end; | |
+ double t_elapsed; | |
+#endif | |
#ifdef __OpenBSD__ | |
if (pledge("stdio wpath cpath", NULL) == -1) { | |
t@@ -353,6 +361,10 @@ main(int argc, char* argv[]) | |
res_norm = NAN; | |
while (sim.t <= sim.t_end) { | |
+#ifdef BENCHMARK_PERFORMANCE | |
+ t_begin = clock(); | |
+#endif | |
+ | |
stressiter = 0; | |
do { | |
if (sim.fluid) { | |
t@@ -398,6 +410,12 @@ main(int argc, char* argv[]) | |
} while ((!isnan(sim.v_x_fix) || !isnan(sim.v_x_limit)) | |
&& fabs(res_norm) > RTOL_STRESS); | |
+#ifdef BENCHMARK_PERFORMANCE | |
+ t_end = clock(); | |
+ t_elapsed = (double)(t_end - t_begin)/CLOCKS_PER_SEC; | |
+ printf("time spent per time step = %g s\n", t_elapsed); | |
+#endif | |
+ | |
if (!isnan(sim.v_x_limit)) | |
sim.mu_wall = mu_wall_orig; | |
sim.t += sim.dt; |