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 76510832b863589eaf491e7555b6557a470e8fe3
parent d7784f92664ba94b5c19934fc6f585b268b8d54d
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Tue, 12 Nov 2019 16:47:52 +0100

Add compile-time option to report performance to stdout

Diffstat:
Mmain.c | 18++++++++++++++++++
1 file changed, 18 insertions(+), 0 deletions(-)

diff --git a/main.c b/main.c @@ -3,6 +3,7 @@ #include <math.h> #include <getopt.h> #include <string.h> +#include <time.h> #include "simulation.h" #include "fluid.h" @@ -24,6 +25,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) { @@ -139,6 +143,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 /* load with default values */ sim = init_sim(); @@ -345,6 +353,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) { @@ -390,6 +402,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;