From c57e37fffeea1e924eee4abdaf5fd1af67d022be Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 13 Dec 2022 12:53:01 +0100 Subject: [PATCH] use exception classes from opm-common --- examples/art2dgf.cpp | 6 ++--- opm/models/blackoil/blackoilnewtonmethod.hh | 4 ++- opm/models/blackoil/blackoilsolventmodules.hh | 5 ++-- opm/models/common/darcyfluxmodule.hh | 12 +++++---- opm/models/common/forchheimerfluxmodule.hh | 7 ++--- .../discretefracture/discretefracturemodel.hh | 3 +-- .../common/fvbasediscretization.hh | 2 +- .../discretization/common/fvbaselinearizer.hh | 8 +++--- .../common/fvbaseprimaryvariables.hh | 3 ++- .../discretization/common/tpfalinearizer.hh | 7 ++--- opm/models/discretization/vcfv/vcfvstencil.hh | 3 +-- opm/models/io/vtkscalarfunction.hh | 5 ++-- opm/models/io/vtkvectorfunction.hh | 5 ++-- opm/models/ncp/ncpmodel.hh | 7 ++--- opm/models/ncp/ncpnewtonmethod.hh | 10 +++---- opm/models/nonlinear/newtonmethod.hh | 26 ++++++++++--------- opm/models/pvs/pvsmodel.hh | 5 ++-- opm/models/pvs/pvsprimaryvariables.hh | 5 ++-- opm/simulators/linalg/bicgstabsolver.hh | 12 ++++----- .../linalg/overlappingpreconditioner.hh | 8 +++--- opm/simulators/linalg/parallelbasebackend.hh | 4 ++- 21 files changed, 79 insertions(+), 68 deletions(-) diff --git a/examples/art2dgf.cpp b/examples/art2dgf.cpp index 683b1cc1b..a06b2825b 100644 --- a/examples/art2dgf.cpp +++ b/examples/art2dgf.cpp @@ -20,7 +20,6 @@ module for the precise wording of the license and the list of copyright holders. */ -#include #include #include @@ -29,10 +28,11 @@ #include #include #include -#include +#include +#include #include #include -#include +#include namespace Ewoms { /*! diff --git a/opm/models/blackoil/blackoilnewtonmethod.hh b/opm/models/blackoil/blackoilnewtonmethod.hh index cea69bc16..813aa7967 100644 --- a/opm/models/blackoil/blackoilnewtonmethod.hh +++ b/opm/models/blackoil/blackoilnewtonmethod.hh @@ -30,6 +30,8 @@ #include "blackoilproperties.hh" +#include + #include #include #include "blackoilmicpmodules.hh" @@ -227,7 +229,7 @@ public: succeeded = comm.min(succeeded); if (!succeeded) - throw NumericalIssue("A process did not succeed in adapting the primary variables"); + throw NumericalProblem("A process did not succeed in adapting the primary variables"); numPriVarsSwitched_ = comm.sum(numPriVarsSwitched_); } diff --git a/opm/models/blackoil/blackoilsolventmodules.hh b/opm/models/blackoil/blackoilsolventmodules.hh index d84bc67df..b194d1bef 100644 --- a/opm/models/blackoil/blackoilsolventmodules.hh +++ b/opm/models/blackoil/blackoilsolventmodules.hh @@ -30,6 +30,8 @@ #include "blackoilproperties.hh" +#include + #include #include #include @@ -49,7 +51,6 @@ #endif #include -#include #include @@ -1189,7 +1190,7 @@ public: solventPGrad[dimIdx] += f[dimIdx]; if (!isfinite(solventPGrad[dimIdx])) - throw NumericalIssue("Non-finite potential gradient for solvent 'phase'"); + throw NumericalProblem("Non-finite potential gradient for solvent 'phase'"); } } diff --git a/opm/models/common/darcyfluxmodule.hh b/opm/models/common/darcyfluxmodule.hh index c4788ecf2..097908543 100644 --- a/opm/models/common/darcyfluxmodule.hh +++ b/opm/models/common/darcyfluxmodule.hh @@ -31,10 +31,12 @@ #define EWOMS_DARCY_FLUX_MODULE_HH #include "multiphasebaseproperties.hh" + +#include + #include #include -#include #include #include @@ -280,8 +282,8 @@ protected: for (unsigned dimIdx = 0; dimIdx < potentialGrad_[phaseIdx].size(); ++dimIdx) { if (!isfinite(potentialGrad_[phaseIdx][dimIdx])) { - throw NumericalIssue("Non-finite potential gradient for phase '" - +std::string(FluidSystem::phaseName(phaseIdx))+"'"); + throw NumericalProblem("Non-finite potential gradient for phase '" + + std::string(FluidSystem::phaseName(phaseIdx))+"'"); } } } @@ -399,8 +401,8 @@ protected: Valgrind::CheckDefined(potentialGrad_[phaseIdx]); for (unsigned dimIdx = 0; dimIdx < potentialGrad_[phaseIdx].size(); ++dimIdx) { if (!isfinite(potentialGrad_[phaseIdx][dimIdx])) { - throw NumericalIssue("Non finite potential gradient for phase '" - +std::string(FluidSystem::phaseName(phaseIdx))+"'"); + throw NumericalProblem("Non-finite potential gradient for phase '" + + std::string(FluidSystem::phaseName(phaseIdx))+"'"); } } } diff --git a/opm/models/common/forchheimerfluxmodule.hh b/opm/models/common/forchheimerfluxmodule.hh index 3d141caf7..04876784a 100644 --- a/opm/models/common/forchheimerfluxmodule.hh +++ b/opm/models/common/forchheimerfluxmodule.hh @@ -32,10 +32,11 @@ #include "darcyfluxmodule.hh" +#include + #include #include -#include #include #include @@ -448,8 +449,8 @@ protected: unsigned newtonIter = 0; while (deltaV.one_norm() > 1e-11) { if (newtonIter >= 50) - throw NumericalIssue("Could not determine Forchheimer velocity within " - +std::to_string(newtonIter)+" iterations"); + throw NumericalProblem("Could not determine Forchheimer velocity within " + + std::to_string(newtonIter)+" iterations"); ++newtonIter; // calculate the residual and its Jacobian matrix diff --git a/opm/models/discretefracture/discretefracturemodel.hh b/opm/models/discretefracture/discretefracturemodel.hh index bc903227f..f4f9427a3 100644 --- a/opm/models/discretefracture/discretefracturemodel.hh +++ b/opm/models/discretefracture/discretefracturemodel.hh @@ -40,8 +40,7 @@ #include #include -#include - +#include #include namespace Opm { diff --git a/opm/models/discretization/common/fvbasediscretization.hh b/opm/models/discretization/common/fvbasediscretization.hh index 8d485963a..4cd201243 100644 --- a/opm/models/discretization/common/fvbasediscretization.hh +++ b/opm/models/discretization/common/fvbasediscretization.hh @@ -58,7 +58,6 @@ #include #include -#include #include #include @@ -74,6 +73,7 @@ #include #include +#include #include #include #include diff --git a/opm/models/discretization/common/fvbaselinearizer.hh b/opm/models/discretization/common/fvbaselinearizer.hh index d0e2c55a4..bf7315f8f 100644 --- a/opm/models/discretization/common/fvbaselinearizer.hh +++ b/opm/models/discretization/common/fvbaselinearizer.hh @@ -31,13 +31,13 @@ #include "fvbaseproperties.hh" #include "linearizationtype.hh" +#include + #include #include #include #include -#include - #include #include #include @@ -219,7 +219,7 @@ public: succeeded = gridView_().comm().min(succeeded); if (!succeeded) - throw NumericalIssue("A process did not succeed in linearizing the system"); + throw NumericalProblem("A process did not succeed in linearizing the system"); } void finalize() @@ -252,7 +252,7 @@ public: succeeded = comm.min(succeeded); if (!succeeded) - throw NumericalIssue("linearization of an auxiliary equation failed"); + throw NumericalProblem("linearization of an auxiliary equation failed"); } } diff --git a/opm/models/discretization/common/fvbaseprimaryvariables.hh b/opm/models/discretization/common/fvbaseprimaryvariables.hh index e6b66744a..38f54136b 100644 --- a/opm/models/discretization/common/fvbaseprimaryvariables.hh +++ b/opm/models/discretization/common/fvbaseprimaryvariables.hh @@ -33,10 +33,11 @@ #include "fvbaseproperties.hh" #include "linearizationtype.hh" #include -#include #include +#include + namespace Opm { /*! diff --git a/opm/models/discretization/common/tpfalinearizer.hh b/opm/models/discretization/common/tpfalinearizer.hh index a5f6161cd..181fa4f95 100644 --- a/opm/models/discretization/common/tpfalinearizer.hh +++ b/opm/models/discretization/common/tpfalinearizer.hh @@ -31,9 +31,10 @@ #include "fvbaseproperties.hh" #include "linearizationtype.hh" +#include + #include -#include #include #include @@ -202,7 +203,7 @@ public: succeeded = gridView_().comm().min(succeeded); if (!succeeded) - throw NumericalIssue("A process did not succeed in linearizing the system"); + throw NumericalProblem("A process did not succeed in linearizing the system"); } void finalize() @@ -235,7 +236,7 @@ public: succeeded = comm.min(succeeded); if (!succeeded) - throw NumericalIssue("linearization of an auxiliary equation failed"); + throw NumericalProblem("linearization of an auxiliary equation failed"); } } diff --git a/opm/models/discretization/vcfv/vcfvstencil.hh b/opm/models/discretization/vcfv/vcfvstencil.hh index cadba839b..734bc8480 100644 --- a/opm/models/discretization/vcfv/vcfvstencil.hh +++ b/opm/models/discretization/vcfv/vcfvstencil.hh @@ -30,8 +30,6 @@ #include -#include - #include #include #include @@ -42,6 +40,7 @@ #include +#include #include namespace Opm { diff --git a/opm/models/io/vtkscalarfunction.hh b/opm/models/io/vtkscalarfunction.hh index 8efe825f9..1b0ff68f8 100644 --- a/opm/models/io/vtkscalarfunction.hh +++ b/opm/models/io/vtkscalarfunction.hh @@ -34,10 +34,9 @@ #include #include -#include - -#include #include +#include +#include #include namespace Opm { diff --git a/opm/models/io/vtkvectorfunction.hh b/opm/models/io/vtkvectorfunction.hh index 482a060ac..b4ab8dd7e 100644 --- a/opm/models/io/vtkvectorfunction.hh +++ b/opm/models/io/vtkvectorfunction.hh @@ -34,10 +34,9 @@ #include #include -#include - -#include #include +#include +#include #include namespace Opm { diff --git a/opm/models/ncp/ncpmodel.hh b/opm/models/ncp/ncpmodel.hh index 4345efcb1..a6fa153ae 100644 --- a/opm/models/ncp/ncpmodel.hh +++ b/opm/models/ncp/ncpmodel.hh @@ -40,6 +40,8 @@ #include "ncpnewtonmethod.hh" #include "ncpindices.hh" +#include + #include #include #include @@ -48,7 +50,6 @@ #include #include -#include #include @@ -381,8 +382,8 @@ public: Opm::Valgrind::CheckDefined(minActivityCoeff_[globalIdx][compIdx]); } if (minActivityCoeff_[globalIdx][compIdx] <= 0) - throw Opm::NumericalIssue("The minimum activity coefficient for component "+std::to_string(compIdx) - +" on DOF "+std::to_string(globalIdx)+" is negative or zero!"); + throw NumericalProblem("The minimum activity coefficient for component "+std::to_string(compIdx) + +" on DOF "+std::to_string(globalIdx)+" is negative or zero!"); } } } diff --git a/opm/models/ncp/ncpnewtonmethod.hh b/opm/models/ncp/ncpnewtonmethod.hh index d7e5d60c3..e64b5b5ec 100644 --- a/opm/models/ncp/ncpnewtonmethod.hh +++ b/opm/models/ncp/ncpnewtonmethod.hh @@ -30,9 +30,9 @@ #include "ncpproperties.hh" -#include +#include -#include +#include #include @@ -118,9 +118,9 @@ protected: // make sure that the error never grows beyond the maximum // allowed one if (this->error_ > EWOMS_GET_PARAM(TypeTag, Scalar, NewtonMaxError)) - throw Opm::NumericalIssue("Newton: Error "+std::to_string(double(this->error_))+ - +" is larger than maximum allowed error of " - +std::to_string(double(EWOMS_GET_PARAM(TypeTag, Scalar, NewtonMaxError)))); + throw Opm::NumericalProblem("Newton: Error "+std::to_string(double(this->error_))+ + + " is larger than maximum allowed error of " + + std::to_string(double(EWOMS_GET_PARAM(TypeTag, Scalar, NewtonMaxError)))); } /*! diff --git a/opm/models/nonlinear/newtonmethod.hh b/opm/models/nonlinear/newtonmethod.hh index 1fb71d71f..d3dbc73b8 100644 --- a/opm/models/nonlinear/newtonmethod.hh +++ b/opm/models/nonlinear/newtonmethod.hh @@ -30,13 +30,15 @@ #include "nullconvergencewriter.hh" #include "newtonmethodproperties.hh" -#include -#include -#include + +#include #include -#include +#include +#include + +#include #include #include @@ -407,7 +409,7 @@ public: return false; } - catch (const NumericalIssue& e) + catch (const NumericalProblem& e) { if (asImp_().verbose_()) std::cout << "Newton method caught exception: \"" @@ -574,7 +576,7 @@ protected: succeeded = comm.min(succeeded); if (!succeeded) - throw NumericalIssue("pre processing of the problem failed"); + throw NumericalProblem("pre processing of the problem failed"); lastError_ = error_; } @@ -626,9 +628,9 @@ protected: // make sure that the error never grows beyond the maximum // allowed one if (error_ > newtonMaxError) - throw NumericalIssue("Newton: Error "+std::to_string(double(error_)) - +" is larger than maximum allowed error of " - +std::to_string(double(newtonMaxError))); + throw NumericalProblem("Newton: Error "+std::to_string(double(error_)) + + " is larger than maximum allowed error of " + + std::to_string(double(newtonMaxError))); } /*! @@ -669,7 +671,7 @@ protected: succeeded = comm.min(succeeded); if (!succeeded) - throw NumericalIssue("post processing of an auxilary equation failed"); + throw NumericalProblem("post processing of an auxilary equation failed"); } } @@ -700,7 +702,7 @@ protected: // make sure not to swallow non-finite values at this point if (!std::isfinite(solutionUpdate.one_norm())) - throw NumericalIssue("Non-finite update!"); + throw NumericalProblem("Non-finite update!"); size_t numGridDof = model().numGridDof(); for (unsigned dofIdx = 0; dofIdx < numGridDof; ++dofIdx) { @@ -798,7 +800,7 @@ protected: succeeded = comm.min(succeeded); if (!succeeded) - throw NumericalIssue("post processing of the problem failed"); + throw NumericalProblem("post processing of the problem failed"); if (asImp_().verbose_()) { std::cout << "Newton iteration " << numIterations_ << "" diff --git a/opm/models/pvs/pvsmodel.hh b/opm/models/pvs/pvsmodel.hh index 624e7ca1b..87d24a8e5 100644 --- a/opm/models/pvs/pvsmodel.hh +++ b/opm/models/pvs/pvsmodel.hh @@ -40,6 +40,8 @@ #include "pvsextensivequantities.hh" #include "pvsindices.hh" +#include + #include #include #include @@ -49,7 +51,6 @@ #include #include -#include #include #include @@ -545,7 +546,7 @@ public: succeeded = this->simulator_.gridView().comm().min(succeeded); if (!succeeded) - throw Opm::NumericalIssue("A process did not succeed in adapting the primary variables"); + throw NumericalProblem("A process did not succeed in adapting the primary variables"); // make sure that if there was a variable switch in an // other partition we will also set the switch flag diff --git a/opm/models/pvs/pvsprimaryvariables.hh b/opm/models/pvs/pvsprimaryvariables.hh index 7c61223b3..d272f4127 100644 --- a/opm/models/pvs/pvsprimaryvariables.hh +++ b/opm/models/pvs/pvsprimaryvariables.hh @@ -31,13 +31,14 @@ #include "pvsindices.hh" #include "pvsproperties.hh" +#include + #include #include #include #include #include -#include #include @@ -303,7 +304,7 @@ public: // some phase must be present if (phasePresence_ == 0) - throw Opm::NumericalIssue("Phase state was 0, i.e., no fluid is present"); + throw NumericalProblem("Phase state was 0, i.e., no fluid is present"); // set the primary variables which correspond to mole // fractions of the present phase which has the lowest index. diff --git a/opm/simulators/linalg/bicgstabsolver.hh b/opm/simulators/linalg/bicgstabsolver.hh index 574ec7537..ce0037368 100644 --- a/opm/simulators/linalg/bicgstabsolver.hh +++ b/opm/simulators/linalg/bicgstabsolver.hh @@ -34,7 +34,7 @@ #include #include -#include +#include #include @@ -198,7 +198,7 @@ public: // beta = (rho_i/rho_(i-1))*(alpha/omega_(i-1)) if (std::abs(rho) <= breakdownEps || std::abs(omega) <= breakdownEps) - throw Opm::NumericalIssue("Breakdown of the BiCGStab solver (division by zero)"); + throw NumericalProblem("Breakdown of the BiCGStab solver (division by zero)"); Scalar beta = (rho_i/rho)*(alpha/omega); // make rho correspond to the current iteration (i.e., forget rho_(i-1)) @@ -230,10 +230,10 @@ public: // alpha = rho_i/(r0hat,v_i) Scalar denom = scalarProduct_.dot(r0hat, v); if (std::abs(denom) <= breakdownEps) - throw Opm::NumericalIssue("Breakdown of the BiCGStab solver (division by zero)"); + throw NumericalProblem("Breakdown of the BiCGStab solver (division by zero)"); alpha = rho_i/denom; if (std::abs(alpha) <= breakdownEps) - throw Opm::NumericalIssue("Breakdown of the BiCGStab solver (stagnation detected)"); + throw NumericalProblem("Breakdown of the BiCGStab solver (stagnation detected)"); // h = x_(i-1) + alpha*y // s = r_(i-1) - alpha*v_i @@ -286,10 +286,10 @@ public: // omega_i = (t*s)/(t*t) denom = scalarProduct_.dot(t, t); if (std::abs(denom) <= breakdownEps) - throw Opm::NumericalIssue("Breakdown of the BiCGStab solver (division by zero)"); + throw NumericalProblem("Breakdown of the BiCGStab solver (division by zero)"); omega = scalarProduct_.dot(t, s)/denom; if (std::abs(omega) <= breakdownEps) - throw Opm::NumericalIssue("Breakdown of the BiCGStab solver (stagnation detected)"); + throw NumericalProblem("Breakdown of the BiCGStab solver (stagnation detected)"); // x_i = h + omega_i*z // x = h; // not necessary because x and h are the same object diff --git a/opm/simulators/linalg/overlappingpreconditioner.hh b/opm/simulators/linalg/overlappingpreconditioner.hh index 9b07cf18d..d09cb46dd 100644 --- a/opm/simulators/linalg/overlappingpreconditioner.hh +++ b/opm/simulators/linalg/overlappingpreconditioner.hh @@ -29,7 +29,7 @@ #include "overlappingscalarproduct.hh" -#include +#include #include //definitions needed in next header #include @@ -88,7 +88,7 @@ public: x.sync(); } else - throw Opm::NumericalIssue("Preconditioner threw an exception in pre() method on some process."); + throw NumericalProblem("Preconditioner threw an exception in pre() method on some process."); #else seqPreCond_.pre(x, y); #endif @@ -133,7 +133,7 @@ public: x.sync(); } else - throw Opm::NumericalIssue("Preconditioner threw an exception on some process."); + throw NumericalProblem("Preconditioner threw an exception on some process."); } else #endif // HAVE_MPI @@ -170,7 +170,7 @@ public: x.sync(); } else - throw Opm::NumericalIssue("Preconditioner threw an exception in post() method on " + throw NumericalProblem("Preconditioner threw an exception in post() method on " "some process."); #else seqPreCond_.post(x); diff --git a/opm/simulators/linalg/parallelbasebackend.hh b/opm/simulators/linalg/parallelbasebackend.hh index 64b72f86d..6d8537841 100644 --- a/opm/simulators/linalg/parallelbasebackend.hh +++ b/opm/simulators/linalg/parallelbasebackend.hh @@ -27,6 +27,8 @@ #ifndef EWOMS_PARALLEL_BASE_BACKEND_HH #define EWOMS_PARALLEL_BASE_BACKEND_HH +#include + #include #include #include @@ -329,7 +331,7 @@ protected: // ranks. preconditionerIsReady = simulator_.gridView().comm().min(preconditionerIsReady); if (!preconditionerIsReady) - throw Opm::NumericalIssue("Creating the preconditioner failed"); + throw NumericalProblem("Creating the preconditioner failed"); // create the parallel preconditioner return std::make_shared(precWrapper_.get(), overlappingMatrix_->overlap());