tCheck solution residual for transient solutions - cngf-pf - continuum model for granular flows with pore-pressure dynamics (renamed from 1d_fd_simple_shear)
(HTM) git clone git://src.adamsgaard.dk/cngf-pf
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit d9168f9f815c36795fe12bac4cb8b147afcc59e6
(DIR) parent 5e65e6215183d5f05212487071b69408d72bbe28
(HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Thu, 16 Apr 2020 15:12:00 +0200
Check solution residual for transient solutions
Diffstat:
M simulation.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/simulation.c b/simulation.c
t@@ -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)) {