Merge pull request #765 from akva2/use_common_exceptions

use exception classes from opm-common
This commit is contained in:
Bård Skaflestad 2022-12-14 09:44:14 +01:00 committed by GitHub
commit 58f01949b7
21 changed files with 79 additions and 68 deletions

View File

@ -20,7 +20,6 @@
module for the precise wording of the license and the list of
copyright holders.
*/
#include <opm/material/common/Exceptions.hpp>
#include <dune/common/version.hh>
#include <dune/common/fvector.hh>
@ -29,10 +28,11 @@
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <vector>
#include <memory>
#include <stdexcept>
#include <sstream>
#include <string>
#include <memory>
#include <vector>
namespace Ewoms {
/*!

View File

@ -30,6 +30,8 @@
#include "blackoilproperties.hh"
#include <opm/common/Exceptions.hpp>
#include <opm/models/utils/signum.hh>
#include <opm/models/nonlinear/newtonmethod.hh>
#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_);
}

View File

@ -30,6 +30,8 @@
#include "blackoilproperties.hh"
#include <opm/common/Exceptions.hpp>
#include <opm/models/blackoil/blackoilsolventparams.hh>
#include <opm/models/io/vtkblackoilsolventmodule.hh>
#include <opm/models/common/quantitycallbacks.hh>
@ -49,7 +51,6 @@
#endif
#include <opm/material/common/Valgrind.hpp>
#include <opm/material/common/Exceptions.hpp>
#include <dune/common/fvector.hh>
@ -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'");
}
}

View File

@ -31,10 +31,12 @@
#define EWOMS_DARCY_FLUX_MODULE_HH
#include "multiphasebaseproperties.hh"
#include <opm/common/Exceptions.hpp>
#include <opm/models/common/quantitycallbacks.hh>
#include <opm/material/common/Valgrind.hpp>
#include <opm/material/common/Exceptions.hpp>
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
@ -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))+"'");
}
}
}

View File

@ -32,10 +32,11 @@
#include "darcyfluxmodule.hh"
#include <opm/common/Exceptions.hpp>
#include <opm/models/discretization/common/fvbaseproperties.hh>
#include <opm/material/common/Valgrind.hpp>
#include <opm/material/common/Exceptions.hpp>
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
@ -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

View File

@ -40,8 +40,7 @@
#include <opm/models/immiscible/immisciblemodel.hh>
#include <opm/models/io/vtkdiscretefracturemodule.hh>
#include <opm/material/common/Exceptions.hpp>
#include <stdexcept>
#include <string>
namespace Opm {

View File

@ -58,7 +58,6 @@
#include <opm/material/common/MathToolbox.hpp>
#include <opm/material/common/Valgrind.hpp>
#include <opm/material/common/Exceptions.hpp>
#include <dune/common/version.hh>
#include <dune/common/fvector.hh>
@ -74,6 +73,7 @@
#include <limits>
#include <list>
#include <stdexcept>
#include <sstream>
#include <string>
#include <vector>

View File

@ -31,13 +31,13 @@
#include "fvbaseproperties.hh"
#include "linearizationtype.hh"
#include <opm/common/Exceptions.hpp>
#include <opm/models/parallel/gridcommhandles.hh>
#include <opm/models/parallel/threadmanager.hh>
#include <opm/models/parallel/threadedentityiterator.hh>
#include <opm/models/discretization/common/baseauxiliarymodule.hh>
#include <opm/material/common/Exceptions.hpp>
#include <dune/common/version.hh>
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
@ -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");
}
}

View File

@ -33,10 +33,11 @@
#include "fvbaseproperties.hh"
#include "linearizationtype.hh"
#include <opm/material/common/Valgrind.hpp>
#include <opm/material/common/Exceptions.hpp>
#include <dune/common/fvector.hh>
#include <stdexcept>
namespace Opm {
/*!

View File

@ -31,9 +31,10 @@
#include "fvbaseproperties.hh"
#include "linearizationtype.hh"
#include <opm/common/Exceptions.hpp>
#include <opm/models/discretization/common/baseauxiliarymodule.hh>
#include <opm/material/common/Exceptions.hpp>
#include <opm/grid/utility/SparseTable.hpp>
#include <opm/input/eclipse/EclipseState/Grid/FaceDir.hpp>
@ -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");
}
}

View File

@ -30,8 +30,6 @@
#include <opm/models/utils/quadraturegeometries.hh>
#include <opm/material/common/Exceptions.hpp>
#include <dune/grid/common/intersectioniterator.hh>
#include <dune/grid/common/mcmgmapper.hh>
#include <dune/geometry/referenceelements.hh>
@ -42,6 +40,7 @@
#include <dune/common/version.hh>
#include <stdexcept>
#include <vector>
namespace Opm {

View File

@ -34,10 +34,9 @@
#include <dune/common/fvector.hh>
#include <dune/common/version.hh>
#include <opm/material/common/Exceptions.hpp>
#include <string>
#include <limits>
#include <stdexcept>
#include <string>
#include <vector>
namespace Opm {

View File

@ -34,10 +34,9 @@
#include <dune/common/fvector.hh>
#include <dune/common/version.hh>
#include <opm/material/common/Exceptions.hpp>
#include <string>
#include <limits>
#include <stdexcept>
#include <string>
#include <vector>
namespace Opm {

View File

@ -40,6 +40,8 @@
#include "ncpnewtonmethod.hh"
#include "ncpindices.hh"
#include <opm/common/Exceptions.hpp>
#include <opm/models/common/multiphasebasemodel.hh>
#include <opm/models/common/energymodule.hh>
#include <opm/models/common/diffusionmodule.hh>
@ -48,7 +50,6 @@
#include <opm/models/io/vtkdiffusionmodule.hh>
#include <opm/material/common/Valgrind.hpp>
#include <opm/material/common/Exceptions.hpp>
#include <dune/common/fvector.hh>
@ -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!");
}
}
}

View File

@ -30,9 +30,9 @@
#include "ncpproperties.hh"
#include <opm/models/nonlinear/newtonmethod.hh>
#include <opm/common/Exceptions.hpp>
#include <opm/material/common/Exceptions.hpp>
#include <opm/models/nonlinear/newtonmethod.hh>
#include <algorithm>
@ -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))));
}
/*!

View File

@ -30,13 +30,15 @@
#include "nullconvergencewriter.hh"
#include "newtonmethodproperties.hh"
#include <opm/models/utils/timer.hh>
#include <opm/models/utils/timerguard.hh>
#include <opm/simulators/linalg/linalgproperties.hh>
#include <opm/common/Exceptions.hpp>
#include <opm/material/densead/Math.hpp>
#include <opm/material/common/Exceptions.hpp>
#include <opm/models/utils/timer.hh>
#include <opm/models/utils/timerguard.hh>
#include <opm/simulators/linalg/linalgproperties.hh>
#include <dune/istl/istlexception.hh>
#include <dune/common/classname.hh>
@ -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_ << ""

View File

@ -40,6 +40,8 @@
#include "pvsextensivequantities.hh"
#include "pvsindices.hh"
#include <opm/common/Exceptions.hpp>
#include <opm/models/common/multiphasebasemodel.hh>
#include <opm/models/common/diffusionmodule.hh>
#include <opm/models/common/energymodule.hh>
@ -49,7 +51,6 @@
#include <opm/material/fluidmatrixinteractions/NullMaterial.hpp>
#include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
#include <opm/material/common/Exceptions.hpp>
#include <iostream>
#include <sstream>
@ -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

View File

@ -31,13 +31,14 @@
#include "pvsindices.hh"
#include "pvsproperties.hh"
#include <opm/common/Exceptions.hpp>
#include <opm/models/discretization/common/fvbaseprimaryvariables.hh>
#include <opm/models/common/energymodule.hh>
#include <opm/material/constraintsolvers/NcpFlash.hpp>
#include <opm/material/fluidstates/CompositionalFluidState.hpp>
#include <opm/material/common/Valgrind.hpp>
#include <opm/material/common/Exceptions.hpp>
#include <dune/common/fvector.hh>
@ -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.

View File

@ -34,7 +34,7 @@
#include <opm/models/utils/timer.hh>
#include <opm/models/utils/timerguard.hh>
#include <opm/material/common/Exceptions.hpp>
#include <opm/common/Exceptions.hpp>
#include <memory>
@ -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

View File

@ -29,7 +29,7 @@
#include "overlappingscalarproduct.hh"
#include <opm/material/common/Exceptions.hpp>
#include <opm/common/Exceptions.hpp>
#include <opm/simulators/linalg/ilufirstelement.hh> //definitions needed in next header
#include <dune/istl/preconditioner.hh>
@ -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);

View File

@ -27,6 +27,8 @@
#ifndef EWOMS_PARALLEL_BASE_BACKEND_HH
#define EWOMS_PARALLEL_BASE_BACKEND_HH
#include <opm/common/Exceptions.hpp>
#include <opm/simulators/linalg/istlsparsematrixadapter.hh>
#include <opm/simulators/linalg/overlappingbcrsmatrix.hh>
#include <opm/simulators/linalg/overlappingblockvector.hh>
@ -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<ParallelPreconditioner>(precWrapper_.get(), overlappingMatrix_->overlap());