1d_fd_simple_shear

continuum model for granular flows with pore-pressure dynamics
git clone git://src.adamsgaard.dk/1d_fd_simple_shear
Log | Files | Refs | README | LICENSE

commit cf09a47ec659fcea6e7f35ddb1fcb442e55a72e6
parent 0e50f90cc1bafdc83a03a8a8f7d8f0d9f36492c0
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Wed, 13 Nov 2019 21:32:35 +0100

Merge branch 'master' of src.adamsgaard.dk:src/1d_fd_simple_shear

Diffstat:
MREADME.md | 16++++++++++------
Mmain.c | 18++++++++++++++++++
2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md @@ -1,14 +1,18 @@ # 1d_fd_simple_shear -[![pipeline status](https://gitlab.com/admesg/1d_fd_simple_shear/badges/master/pipeline.svg)](https://gitlab.com/admesg/1d_fd_simple_shear/commits/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_transient) +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 @@ -4,6 +4,7 @@ #include <math.h> #include <getopt.h> #include <string.h> +#include <time.h> #include "simulation.h" #include "fluid.h" @@ -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) { @@ -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) { @@ -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) { @@ -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;