use exception classes from opm-common

This commit is contained in:
Arne Morten Kvarving 2022-12-13 12:54:27 +01:00
parent bb649097b9
commit f17a90170d
11 changed files with 70 additions and 52 deletions

View File

@ -28,9 +28,11 @@
#ifndef EWOMS_ECL_NEWTON_METHOD_HH
#define EWOMS_ECL_NEWTON_METHOD_HH
#include <opm/common/Exceptions.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/models/blackoil/blackoilnewtonmethod.hh>
#include <opm/models/utils/signum.hh>
#include <opm/common/OpmLog/OpmLog.hpp>
namespace Opm::Properties {
@ -229,16 +231,16 @@ public:
// make sure that the error never grows beyond the maximum
// allowed one
if (this->error_ > newtonMaxError)
throw NumericalIssue("Newton: Error "+std::to_string(double(this->error_))
+" is larger than maximum allowed error of "
+std::to_string(double(newtonMaxError)));
throw NumericalProblem("Newton: Error "+std::to_string(double(this->error_))
+ " is larger than maximum allowed error of "
+ std::to_string(double(newtonMaxError)));
// make sure that the error never grows beyond the maximum
// allowed one
if (errorSum_ > newtonMaxError)
throw NumericalIssue("Newton: Sum of the error "+std::to_string(double(errorSum_))
+" is larger than maximum allowed error of "
+std::to_string(double(newtonMaxError)));
throw NumericalProblem("Newton: Sum of the error "+std::to_string(double(errorSum_))
+ " is larger than maximum allowed error of "
+ std::to_string(double(newtonMaxError)));
}
void endIteration_(SolutionVector& nextSolution,

View File

@ -27,6 +27,9 @@
#ifndef EWOMS_ECL_OUTPUT_BLACK_OIL_MODULE_HH
#define EWOMS_ECL_OUTPUT_BLACK_OIL_MODULE_HH
#include <opm/common/Exceptions.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/models/blackoil/blackoilproperties.hh>
#include <opm/models/utils/propertysystem.hh>
@ -41,8 +44,6 @@
#include <opm/output/eclipse/EclipseIO.hpp>
#include <opm/output/eclipse/Inplace.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <ebos/eclgenericoutputblackoilmodule.hh>
#include <dune/common/fvector.hh>
@ -420,7 +421,7 @@ public:
try {
this->bubblePointPressure_[globalDofIdx] = getValue(FluidSystem::bubblePointPressure(fs, intQuants.pvtRegionIndex()));
}
catch (const NumericalIssue&) {
catch (const NumericalProblem&) {
const auto cartesianIdx = elemCtx.simulator().vanguard().cartesianIndex(globalDofIdx);
this->failedCellsPb_.push_back(cartesianIdx);
}
@ -429,7 +430,7 @@ public:
try {
this->dewPointPressure_[globalDofIdx] = getValue(FluidSystem::dewPointPressure(fs, intQuants.pvtRegionIndex()));
}
catch (const NumericalIssue&) {
catch (const NumericalProblem&) {
const auto cartesianIdx = elemCtx.simulator().vanguard().cartesianIndex(globalDofIdx);
this->failedCellsPd_.push_back(cartesianIdx);
}

View File

@ -27,28 +27,30 @@
#include <ebos/eclproblem.hh>
#include <opm/models/utils/start.hh>
#include <opm/simulators/timestepping/AdaptiveTimeSteppingEbos.hpp>
#include <opm/simulators/flow/NonlinearSolverEbos.hpp>
#include <opm/simulators/flow/BlackoilModelParametersEbos.hpp>
#include <opm/simulators/wells/BlackoilWellModel.hpp>
#include <opm/simulators/aquifers/BlackoilAquiferModel.hpp>
#include <opm/simulators/wells/WellConnectionAuxiliaryModule.hpp>
#include <opm/simulators/flow/countGlobalCells.hpp>
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
#include <opm/grid/UnstructuredGrid.h>
#include <opm/simulators/timestepping/SimulatorReport.hpp>
#include <opm/core/props/phaseUsageFromDeck.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <opm/common/Exceptions.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/input/eclipse/Units/Units.hpp>
#include <opm/simulators/timestepping/SimulatorTimer.hpp>
#include <opm/core/props/phaseUsageFromDeck.hpp>
#include <opm/grid/UnstructuredGrid.h>
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/EclipseState/Tables/TableManager.hpp>
#include <opm/input/eclipse/Units/Units.hpp>
#include <opm/simulators/aquifers/BlackoilAquiferModel.hpp>
#include <opm/simulators/flow/countGlobalCells.hpp>
#include <opm/simulators/flow/NonlinearSolverEbos.hpp>
#include <opm/simulators/flow/BlackoilModelParametersEbos.hpp>
#include <opm/simulators/linalg/ISTLSolverEbos.hpp>
#include <opm/simulators/timestepping/AdaptiveTimeSteppingEbos.hpp>
#include <opm/simulators/timestepping/SimulatorReport.hpp>
#include <opm/simulators/timestepping/SimulatorTimer.hpp>
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
#include <opm/simulators/wells/BlackoilWellModel.hpp>
#include <opm/simulators/wells/WellConnectionAuxiliaryModule.hpp>
#include <dune/istl/owneroverlapcopy.hh>
#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 7)
@ -397,9 +399,9 @@ namespace Opm {
// Throw if any NaN or too large residual found.
if (severity == ConvergenceReport::Severity::NotANumber) {
OPM_THROW(NumericalIssue, "NaN residual found!");
OPM_THROW(NumericalProblem, "NaN residual found!");
} else if (severity == ConvergenceReport::Severity::TooLarge) {
OPM_THROW_NOLOG(NumericalIssue, "Too large residual found!");
OPM_THROW_NOLOG(NumericalProblem, "Too large residual found!");
}
}
report.update_time += perfTimer.stop();

View File

@ -27,6 +27,7 @@
#include <ebos/eclbasevanguard.hh>
#include <opm/common/ErrorMacros.hpp>
#include <opm/common/Exceptions.hpp>
#include <opm/models/discretization/common/fvbaseproperties.hh>
#include <opm/models/common/multiphasebaseproperties.hh>
@ -432,7 +433,7 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
// Check for failure of linear solver.
if (!parameters_.ignoreConvergenceFailure_ && !result.converged) {
const std::string msg("Convergence failure for linear solver.");
OPM_THROW_NOLOG(NumericalIssue, msg);
OPM_THROW_NOLOG(NumericalProblem, msg);
}
}
protected:

View File

@ -6,17 +6,21 @@
#include <iostream>
#include <utility>
#include <opm/simulators/timestepping/SimulatorReport.hpp>
#include <opm/grid/utility/StopWatch.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/Exceptions.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/core/props/phaseUsageFromDeck.hpp>
#include <opm/grid/utility/StopWatch.hpp>
#include <opm/input/eclipse/Schedule/ScheduleState.hpp>
#include <opm/simulators/timestepping/SimulatorReport.hpp>
#include <opm/simulators/timestepping/SimulatorTimer.hpp>
#include <opm/simulators/timestepping/AdaptiveSimulatorTimer.hpp>
#include <opm/simulators/timestepping/TimeStepControlInterface.hpp>
#include <opm/simulators/timestepping/TimeStepControl.hpp>
#include <opm/core/props/phaseUsageFromDeck.hpp>
#include <opm/input/eclipse/Schedule/ScheduleState.hpp>
#include <opm/common/Exceptions.hpp>
namespace Opm::Properties {
@ -429,7 +433,7 @@ namespace Opm {
logException_(e, solverVerbose_);
// since linearIterations is < 0 this will restart the solver
}
catch (const NumericalIssue& e) {
catch (const NumericalProblem& e) {
substepReport = solver.failureReport();
causeOfFailure = "Solver convergence failure - Numerical problem encountered";
@ -544,7 +548,7 @@ namespace Opm {
if (solverVerbose_) {
OpmLog::error(msg);
}
OPM_THROW_NOLOG(NumericalIssue, msg);
OPM_THROW_NOLOG(NumericalProblem, msg);
}
// The new, chopped timestep.
@ -560,7 +564,7 @@ namespace Opm {
if (solverVerbose_) {
OpmLog::error(msg);
}
OPM_THROW_NOLOG(NumericalIssue, msg);
OPM_THROW_NOLOG(NumericalProblem, msg);
}
// Define utility function for chopping timestep.

View File

@ -21,11 +21,11 @@
#ifndef OPM_DEFERREDLOGGINGERRORHELPERS_HPP
#define OPM_DEFERREDLOGGINGERRORHELPERS_HPP
#include <opm/common/Exceptions.hpp>
#include <opm/simulators/utils/DeferredLogger.hpp>
#include <opm/simulators/utils/gatherDeferredLogger.hpp>
#include <opm/material/common/Exceptions.hpp>
#include <opm/simulators/utils/ParallelCommunication.hpp>
#include <string>
@ -69,7 +69,7 @@ void _throw(Opm::ExceptionType::ExcEnum exc_type,
throw std::invalid_argument(message);
break;
case Opm::ExceptionType::NUMERICAL_ISSUE:
throw Opm::NumericalIssue(message);
throw Opm::NumericalProblem(message);
break;
case Opm::ExceptionType::DEFAULT:
case Opm::ExceptionType::LOGIC_ERROR:
@ -124,7 +124,7 @@ try {
/// There is a clause that will catch anything
#define OPM_PARALLEL_CATCH_CLAUSE(obptc_exc_type, \
obptc_exc_msg) \
catch (const Opm::NumericalIssue& e){ \
catch (const Opm::NumericalProblem& e){ \
obptc_exc_type = Opm::ExceptionType::NUMERICAL_ISSUE; \
obptc_exc_msg = e.what(); \
} catch (const std::runtime_error& e) { \

View File

@ -121,7 +121,7 @@ applyUMFPack(Dune::UMFPack<MatrixType>& linsolver,
if (std::isinf(y[i_block][i_elem]) || std::isnan(y[i_block][i_elem]) ) {
const std::string msg{"nan or inf value found after UMFPack solve due to singular matrix"};
OpmLog::debug(msg);
OPM_THROW_NOLOG(NumericalIssue, msg);
OPM_THROW_NOLOG(NumericalProblem, msg);
}
}
}
@ -207,7 +207,7 @@ invDX(const MatrixType& D, VectorType x, DeferredLogger& deferred_logger)
linsolver.apply(y, x, res);
if ( !res.converged ) {
OPM_DEFLOG_THROW(NumericalIssue, "the invDX did not converge ", deferred_logger);
OPM_DEFLOG_THROW(NumericalProblem, "the invDX did not converge ", deferred_logger);
}
return y;

View File

@ -18,12 +18,14 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/common/Exceptions.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/input/eclipse/Schedule/MSW/Valve.hpp>
#include <opm/simulators/wells/MultisegmentWellAssemble.hpp>
#include <opm/simulators/wells/WellBhpThpCalculator.hpp>
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
#include <opm/input/eclipse/Schedule/MSW/Valve.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <string>
#include <algorithm>
@ -829,9 +831,9 @@ namespace Opm
const Value d = 1.0 - rv * rs;
if (getValue(d) == 0.0) {
OPM_DEFLOG_THROW(NumericalIssue, "Zero d value obtained for well " << this->name()
<< " during flux calculation"
<< " with rs " << rs << " and rv " << rv, deferred_logger);
OPM_DEFLOG_THROW(NumericalProblem, "Zero d value obtained for well " << this->name()
<< " during flux calculation"
<< " with rs " << rs << " and rv " << rv, deferred_logger);
}
const Value tmp_oil = (cmix_s[oilCompIdx] - rv * cmix_s[gasCompIdx]) / d;

View File

@ -22,6 +22,8 @@
#include <config.h>
#include <opm/simulators/wells/StandardWellPrimaryVariables.hpp>
#include <opm/common/Exceptions.hpp>
#include <dune/common/dynvector.hh>
#include <dune/istl/bvector.hh>
@ -694,7 +696,7 @@ checkFinite(DeferredLogger& deferred_logger) const
{
for (const Scalar v : value_) {
if (!isfinite(v))
OPM_DEFLOG_THROW(NumericalIssue, "Infinite primary variable after update from wellState well: " << well_.name(), deferred_logger);
OPM_DEFLOG_THROW(NumericalProblem, "Infinite primary variable after update from wellState well: " << well_.name(), deferred_logger);
}
}

View File

@ -19,6 +19,8 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/common/Exceptions.hpp>
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
#include <opm/simulators/wells/StandardWellAssemble.hpp>
#include <opm/simulators/wells/VFPHelpers.hpp>
@ -555,7 +557,7 @@ namespace Opm
try {
this->linSys_.invert();
} catch( ... ) {
OPM_DEFLOG_THROW(NumericalIssue,"Error when inverting local well equations for well " + name(), deferred_logger);
OPM_DEFLOG_THROW(NumericalProblem, "Error when inverting local well equations for well " + name(), deferred_logger);
}
}

View File

@ -19,6 +19,8 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/common/Exceptions.hpp>
#include <opm/input/eclipse/Schedule/ScheduleTypes.hpp>
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
#include <opm/simulators/wells/GroupState.hpp>
@ -407,7 +409,7 @@ namespace Opm
bool converged = false;
try {
converged = this->iterateWellEqWithControl(ebosSimulator, dt, inj_controls, prod_controls, well_state, group_state, deferred_logger);
} catch (NumericalIssue& e ) {
} catch (NumericalProblem& e ) {
const std::string msg = "Inner well iterations failed for well " + this->name() + " Treat the well as unconverged. ";
deferred_logger.warning("INNER_ITERATION_FAILED", msg);
converged = false;