mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Improves exceptions and message and resort to OPM_THROW for flexible solvers.
This commit is contained in:
parent
ff0d54d4ea
commit
74b958c258
@ -164,9 +164,7 @@ private:
|
||||
linsolver_.reset(new Dune::UMFPack<MatrixType>(linearoperator_->getmat(), verbosity, dummy));
|
||||
#endif
|
||||
} else {
|
||||
std::string msg("Solver not known ");
|
||||
msg += solver_type;
|
||||
throw std::runtime_error(msg);
|
||||
OPM_THROW(std::invalid_argument, "Properties: Solver " << solver_type << " not known.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include <opm/simulators/linalg/FlexibleSolver.hpp>
|
||||
#include <opm/simulators/linalg/setupPropertyTree.hpp>
|
||||
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
|
||||
#include <memory>
|
||||
@ -182,7 +184,8 @@ public:
|
||||
return this->getTrueImpesWeights(b, pressureIndex);
|
||||
};
|
||||
}else{
|
||||
throw std::runtime_error("no such weights implemented for cpr");
|
||||
OPM_THROW(std::invalid_argument, "Weights type " << weightsType << "not implemented for cpr."
|
||||
<< " Please use quasiimpes or trueimpes.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <opm/simulators/linalg/getQuasiImpesWeights.hpp>
|
||||
#include <opm/simulators/linalg/twolevelmethodcpr.hh>
|
||||
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
|
||||
#include <dune/common/fmatrix.hh>
|
||||
#include <dune/istl/bcrsmatrix.hh>
|
||||
#include <dune/istl/paamg/amg.hh>
|
||||
@ -104,9 +106,10 @@ public:
|
||||
, prm_(prm)
|
||||
{
|
||||
if (prm.get<int>("verbosity", 0) > 10) {
|
||||
std::ofstream outfile(prm.get<std::string>("weights_filename", "impes_weights.txt"));
|
||||
std::string filename = prm.get<std::string>("weights_filename", "impes_weights.txt");
|
||||
std::ofstream outfile(filename);
|
||||
if (!outfile) {
|
||||
throw std::runtime_error("Could not write weights");
|
||||
OPM_THROW(std::ofstream::failure, "Could not write weights to file " << filename << ".");
|
||||
}
|
||||
Dune::writeMatrixMarket(weights_, outfile);
|
||||
}
|
||||
@ -133,10 +136,11 @@ public:
|
||||
{
|
||||
//Opm::Amg::getQuasiImpesWeights<MatrixType, VectorType>(
|
||||
// linearoperator.getmat(), prm.get<int>("pressure_var_index"), transpose))
|
||||
if (prm.get<int>("verbosity", 0) > 10) {
|
||||
std::ofstream outfile(prm.get<std::string>("weights_filename", "impes_weights.txt"));
|
||||
if (prm.get<int>("verbosity", 0) > 10 && comm.communicator().rank() == 0) {
|
||||
auto filename = prm.get<std::string>("weights_filename", "impes_weights.txt");
|
||||
std::ofstream outfile(filename);
|
||||
if (!outfile) {
|
||||
throw std::runtime_error("Could not write weights");
|
||||
OPM_THROW(std::ofstream::failure, "Could not write weights to file " << filename << ".");
|
||||
}
|
||||
Dune::writeMatrixMarket(weights_, outfile);
|
||||
}
|
||||
|
@ -226,9 +226,7 @@ private:
|
||||
auto sargs = amgSmootherArgs<Smoother>(prm);
|
||||
return std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(op, crit, sargs, comm);
|
||||
} else {
|
||||
std::string msg("No such smoother: ");
|
||||
msg += smoother;
|
||||
throw std::runtime_error(msg);
|
||||
OPM_THROW(std::invalid_argument, "Properties: No smoother with name " << smoother <<".");
|
||||
}
|
||||
});
|
||||
doAddCreator("cpr", [](const O& op, const P& prm, const std::function<Vector()> weightsCalculator, const C& comm) {
|
||||
@ -312,9 +310,7 @@ private:
|
||||
#endif
|
||||
return makeAmgPreconditioner<Smoother>(op, prm);
|
||||
} else {
|
||||
std::string msg("No such smoother: ");
|
||||
msg += smoother;
|
||||
throw std::runtime_error(msg);
|
||||
OPM_THROW(std::invalid_argument, "Properties: No smoother with name " << smoother <<".");
|
||||
}
|
||||
});
|
||||
doAddCreator("kamg", [](const O& op, const P& prm, const std::function<Vector()>&) {
|
||||
@ -338,9 +334,7 @@ private:
|
||||
using Smoother = SeqILUn<M, V, V>;
|
||||
return makeAmgPreconditioner<Smoother>(op, prm, true);
|
||||
} else {
|
||||
std::string msg("No such smoother: ");
|
||||
msg += smoother;
|
||||
throw std::runtime_error(msg);
|
||||
OPM_THROW(std::invalid_argument, "Properties: No smoother with name " << smoother <<".");
|
||||
}
|
||||
});
|
||||
doAddCreator("famg", [](const O& op, const P& prm, const std::function<Vector()>&) {
|
||||
@ -387,7 +381,7 @@ private:
|
||||
msg << prec.first << ' ';
|
||||
}
|
||||
msg << std::endl;
|
||||
throw std::runtime_error(msg.str());
|
||||
OPM_THROW(std::invalid_argument, msg.str());
|
||||
}
|
||||
return it->second(op, prm, weightsCalculator);
|
||||
}
|
||||
@ -405,7 +399,7 @@ private:
|
||||
msg << prec.first << ' ';
|
||||
}
|
||||
msg << std::endl;
|
||||
throw std::runtime_error(msg.str());
|
||||
OPM_THROW(std::invalid_argument, msg.str());
|
||||
}
|
||||
return it->second(op, prm, weightsCalculator, comm);
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ setupPropertyTree(const FlowLinearSolverParameters& p)
|
||||
if (p.linear_solver_configuration_ == "file") {
|
||||
#if BOOST_VERSION / 100 % 1000 > 48
|
||||
if (p.linear_solver_configuration_json_file_ == "none"){
|
||||
throw std::runtime_error("No linear-solver-configuration-json-file given for linear-solver-configuration=file ");
|
||||
OPM_THROW(std::invalid_argument, p.linear_solver_configuration_ << "is not a valid setting for --linear-solver-configuration."
|
||||
<< " Please use ilu0, cpr_trueimpes, or cpr_quasiimpes");
|
||||
}else{
|
||||
boost::property_tree::read_json(p.linear_solver_configuration_json_file_, prm);
|
||||
}
|
||||
@ -78,7 +79,8 @@ setupPropertyTree(const FlowLinearSolverParameters& p)
|
||||
}
|
||||
} else {
|
||||
if(p.linear_solver_configuration_ != "ilu0"){
|
||||
throw std::runtime_error("Not a valid setting for linear_solver_configuration");
|
||||
OPM_THROW(std::invalid_argument, p.linear_solver_configuration_ << "is not a valid setting for --linear-solver-configuration."
|
||||
<< " Please use ilu0, cpr_trueimpes, or cpr_quasiimpes");
|
||||
}
|
||||
prm.put("tol", p.linear_solver_reduction_);
|
||||
prm.put("maxiter", p.linear_solver_maxiter_);
|
||||
|
Loading…
Reference in New Issue
Block a user