From 8b84bc6b4b6861987b41425e550e72f9a6511453 Mon Sep 17 00:00:00 2001 From: Kjetil Olsen Lye Date: Sat, 8 Feb 2025 12:50:56 +0100 Subject: [PATCH 1/3] Using the CriticalException in PreconditionerFactory and ISTLSolver --- opm/simulators/linalg/ISTLSolver.hpp | 8 +++++--- opm/simulators/linalg/PreconditionerFactory_impl.hpp | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/opm/simulators/linalg/ISTLSolver.hpp b/opm/simulators/linalg/ISTLSolver.hpp index 053a6fbc6..93ef60c75 100644 --- a/opm/simulators/linalg/ISTLSolver.hpp +++ b/opm/simulators/linalg/ISTLSolver.hpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -377,10 +378,11 @@ std::unique_ptr blockJacobiAdjacency(const Grid& grid, void prepare(const Matrix& M, Vector& b) { OPM_TIMEBLOCK(istlSolverPrepare); + OPM_BEGIN_TRY_CATCH_RETHROW_AS_CRITICAL_ERROR(); + initPrepare(M,b); - initPrepare(M,b); - - prepareFlexibleSolver(); + prepareFlexibleSolver(); + OPM_END_TRY_CATCH_RETHROW_AS_CRITICAL_ERROR(); } diff --git a/opm/simulators/linalg/PreconditionerFactory_impl.hpp b/opm/simulators/linalg/PreconditionerFactory_impl.hpp index 44287b6eb..b6dca5f0a 100644 --- a/opm/simulators/linalg/PreconditionerFactory_impl.hpp +++ b/opm/simulators/linalg/PreconditionerFactory_impl.hpp @@ -20,6 +20,7 @@ #include +#include #include #include @@ -776,7 +777,7 @@ PreconditionerFactory::create(const Operator& op, const std::function& weightsCalculator, std::size_t pressureIndex) { - return instance().doCreate(op, prm, weightsCalculator, pressureIndex); + OPM_TRY_THROW_AS_CRITICAL_ERROR(return instance().doCreate(op, prm, weightsCalculator, pressureIndex)); } template @@ -787,7 +788,7 @@ PreconditionerFactory::create(const Operator& op, const Comm& comm, std::size_t pressureIndex) { - return instance().doCreate(op, prm, weightsCalculator, pressureIndex, comm); + OPM_TRY_THROW_AS_CRITICAL_ERROR(return instance().doCreate(op, prm, weightsCalculator, pressureIndex, comm)); } @@ -798,7 +799,7 @@ PreconditionerFactory::create(const Operator& op, const Comm& comm, std::size_t pressureIndex) { - return instance().doCreate(op, prm, std::function(), pressureIndex, comm); + OPM_TRY_THROW_AS_CRITICAL_ERROR(return instance().doCreate(op, prm, std::function(), pressureIndex, comm)); } template From 264a8d44d39c63c5ee8e237b29cab28c96cf2bc7 Mon Sep 17 00:00:00 2001 From: Kjetil Olsen Lye Date: Sat, 8 Feb 2025 19:39:15 +0100 Subject: [PATCH 2/3] Removed rethrow from PreconditionerFactory::create --- opm/simulators/linalg/PreconditionerFactory_impl.hpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/opm/simulators/linalg/PreconditionerFactory_impl.hpp b/opm/simulators/linalg/PreconditionerFactory_impl.hpp index b6dca5f0a..44287b6eb 100644 --- a/opm/simulators/linalg/PreconditionerFactory_impl.hpp +++ b/opm/simulators/linalg/PreconditionerFactory_impl.hpp @@ -20,7 +20,6 @@ #include -#include #include #include @@ -777,7 +776,7 @@ PreconditionerFactory::create(const Operator& op, const std::function& weightsCalculator, std::size_t pressureIndex) { - OPM_TRY_THROW_AS_CRITICAL_ERROR(return instance().doCreate(op, prm, weightsCalculator, pressureIndex)); + return instance().doCreate(op, prm, weightsCalculator, pressureIndex); } template @@ -788,7 +787,7 @@ PreconditionerFactory::create(const Operator& op, const Comm& comm, std::size_t pressureIndex) { - OPM_TRY_THROW_AS_CRITICAL_ERROR(return instance().doCreate(op, prm, weightsCalculator, pressureIndex, comm)); + return instance().doCreate(op, prm, weightsCalculator, pressureIndex, comm); } @@ -799,7 +798,7 @@ PreconditionerFactory::create(const Operator& op, const Comm& comm, std::size_t pressureIndex) { - OPM_TRY_THROW_AS_CRITICAL_ERROR(return instance().doCreate(op, prm, std::function(), pressureIndex, comm)); + return instance().doCreate(op, prm, std::function(), pressureIndex, comm); } template From 791e5974f240c283b3ec03ec5788c16817f4391a Mon Sep 17 00:00:00 2001 From: Kjetil Olsen Lye Date: Mon, 10 Feb 2025 16:08:43 +0100 Subject: [PATCH 3/3] Now providing a message for CritcalError when rethrowing in ISTLSolver --- opm/simulators/linalg/ISTLSolver.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opm/simulators/linalg/ISTLSolver.hpp b/opm/simulators/linalg/ISTLSolver.hpp index 93ef60c75..e118fb647 100644 --- a/opm/simulators/linalg/ISTLSolver.hpp +++ b/opm/simulators/linalg/ISTLSolver.hpp @@ -378,11 +378,11 @@ std::unique_ptr blockJacobiAdjacency(const Grid& grid, void prepare(const Matrix& M, Vector& b) { OPM_TIMEBLOCK(istlSolverPrepare); - OPM_BEGIN_TRY_CATCH_RETHROW_AS_CRITICAL_ERROR(); + try { initPrepare(M,b); prepareFlexibleSolver(); - OPM_END_TRY_CATCH_RETHROW_AS_CRITICAL_ERROR(); + } OPM_CATCH_AND_RETHROW_AS_CRITICAL_ERROR("This is likely due to a faulty linear solver JSON specification. Check for errors related to missing nodes."); }