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 d9168f9f815c36795fe12bac4cb8b147afcc59e6
parent 5e65e6215183d5f05212487071b69408d72bbe28
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Thu, 16 Apr 2020 15:12:00 +0200

Check solution residual for transient solutions

Diffstat:
Msimulation.c | 18+++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/simulation.c b/simulation.c @@ -813,10 +813,22 @@ coupled_shear_solver(struct simulation *sim, for (i=0; i<sim->nz; ++i) r_norm[i] = residual_normalized(sim->v_x[i], v_x0[i]); r_norm_max = max(r_norm, sim->nz); - } - - } while (0); + if (r_norm_max <= rel_tol) { + break; + } + if (coupled_iter++ >= max_iter) { + free(r_norm); + free(v_x0); + fprintf(stderr, "coupled_shear_solver: "); + fprintf(stderr, "Transient solution did not converge " + "after %d iterations\n", coupled_iter); + fprintf(stderr, ".. Residual normalized error: %g\n", + r_norm_max); + return 1; + } + } + } while (sim->transient); if (!isnan(sim->v_x_limit) || !isnan(sim->v_x_fix)) { if (!isnan(sim->v_x_limit)) {