From 8e03bf73d3f3c2da85cb8d76834d8b789143295a Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 6 May 2025 14:35:49 -0600 Subject: [PATCH] Let KINSOL throw an exception if it fails. --- source/sundials/kinsol.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/sundials/kinsol.cc b/source/sundials/kinsol.cc index e5fee93e0e..b41cfb10a4 100644 --- a/source/sundials/kinsol.cc +++ b/source/sundials/kinsol.cc @@ -564,7 +564,17 @@ namespace SUNDIALS throw; } } - AssertKINSOL(status); + // It is of course also possible that KINSOL experienced + // convergence issues even if the user-side callbacks + // succeeded. In that case, we also want to throw an exception + // that can be caught by the user -- whether that's actually + // useful to determine a different course of action (i.e., whether + // the user side can do something to recover the ability to + // converge) is a separate matter that we need not decide + // here. (One could imagine this happening in a time or load + // stepping procedure where re-starting with a smaller time step + // or load step could help.) + AssertThrow(status >= 0, ExcKINSOLError(status)); long nniters; status = KINGetNumNonlinSolvIters(kinsol_mem, &nniters); -- 2.39.5