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 Back to index

commit fc73c7536cdc9f424ca75008d363afbe0e99e120
parent 1d04e33c83658efd712f1bc542d482b0cf07394b
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Thu, 16 Apr 2020 17:39:31 +0200

Fix time arithmatic in main loop, update fluid test

Diffstat:
M1d_fd_simple_shear.c | 17++++++++---------
Msimulation.c | 4++--
2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/1d_fd_simple_shear.c b/1d_fd_simple_shear.c @@ -245,7 +245,7 @@ main(int argc, char* argv[]) filetimeclock = 0.0; iter = 0; - while (sim.t <= sim.t_end) { + do { #ifdef BENCHMARK_PERFORMANCE t_begin = clock(); @@ -262,19 +262,18 @@ main(int argc, char* argv[]) printf("time spent per time step = %g s\n", t_elapsed); #endif - sim.t += sim.dt; - filetimeclock += sim.dt; - iter++; - - if ((filetimeclock - sim.dt >= sim.file_dt || iter == 1) && + if ((filetimeclock >= sim.file_dt || iter == 1) && strncmp(sim.name, DEFAULT_SIMULATION_NAME, sizeof(DEFAULT_SIMULATION_NAME)) != 0) { write_output_file(&sim, normalize); filetimeclock = 0.0; - if (iter == 1) - sim.t = 0.0; } - } + + sim.t += sim.dt; + filetimeclock += sim.dt; + iter++; + + } while (sim.t - sim.dt < sim.t_end); print_output(&sim, stdout, normalize); diff --git a/simulation.c b/simulation.c @@ -693,8 +693,8 @@ write_output_file(struct simulation *sim, const int normalize) char outfile[200]; FILE *fp; - snprintf(outfile, sizeof(outfile), "%s.output%05d.txt", - sim->name, sim->n_file++); + snprintf(outfile, sizeof(outfile), "%s.output%05d.t=%gs.txt", + sim->name, sim->n_file++, sim->t); if ((fp = fopen(outfile, "w")) != NULL) { print_output(sim, fp, normalize);