commit 491b69c62c0aa413975e5bd57df9289054d80d62
parent 254e00285ee8996710ca156a1cae30ac6c935779
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Thu, 15 Jan 2026 19:24:27 +0100
fix(simulation): fix transient mode velocity residual and mu_wall reset
- Use fmax(v_x_fix, v_x[top]) as reference for velocity residual to
prevent division by near-zero when solver hasn't reached yield
- Reset mu_wall to original value after each timestep for v_x_fix
(was only done for v_x_limit), preventing accumulation across timesteps
- Re-enable cngf_pf_dry_transient test now that basic transient works
- Update skip comments for trans_undercons/overcons (solver instability)
Diffstat:
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/simulation.c b/simulation.c
@@ -837,8 +837,9 @@ int coupled_shear_solver(struct simulation *sim, const int max_iter,
if (vel_res_norm > 0.0)
vel_res_norm = 0.0;
} else {
- vel_res_norm = (sim->v_x_fix - sim->v_x[sim->nz - 1]) /
- (sim->v_x[sim->nz - 1] + 1e-12);
+ double v_ref =
+ fmax(fabs(sim->v_x_fix), fabs(sim->v_x[sim->nz - 1])) + 1e-12;
+ vel_res_norm = (sim->v_x_fix - sim->v_x[sim->nz - 1]) / v_ref;
}
sim->mu_wall *= 1.0 + (vel_res_norm * 1e-3);
}
@@ -854,7 +855,7 @@ int coupled_shear_solver(struct simulation *sim, const int max_iter,
} while ((!isnan(sim->v_x_fix) || !isnan(sim->v_x_limit)) &&
fabs(vel_res_norm) > RTOL_VELOCITY);
- if (!isnan(sim->v_x_limit))
+ if (!isnan(sim->v_x_limit) || !isnan(sim->v_x_fix))
sim->mu_wall = mu_wall_orig;
temporal_increment(sim);
diff --git a/test/Makefile b/test/Makefile
@@ -12,14 +12,17 @@ TESTS = cngf_pf_dry \
cngf_pf_wet_vari_diff \
cngf_pf_wet_vari_pulse \
cngf_pf_wet_vari_pulse_vlim \
+ cngf_pf_dry_transient \
shear_flux_dry \
shear_flux_wet
# Skipped tests:
-# - cngf_pf_dry_trans, cngf_pf_dry_trans_undercons, cngf_pf_dry_trans_overcons:
-# Transient mode broken after inertia fix (commit 91d9022)
+# - cngf_pf_dry_trans_undercons, cngf_pf_dry_trans_overcons:
+# Transient mode with fixed velocity and non-critical porosity has
+# coupled solver instability (see walkthrough for details)
# - max_depth_misc: test config uses removed -O option
+
STANDARDS := $(TESTS:=.std)
CNGF_PF_DRY_OPTS = -o 0.03 -L 0.64 -n 40e3