mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #4343 from akva2/remove_sstream
Remove sstream use in exception handling
This commit is contained in:
commit
d58efe3bf9
@ -122,7 +122,8 @@ class WellState;
|
||||
} else if (relaxationTypeString == "sor") {
|
||||
relaxType_ = SOR;
|
||||
} else {
|
||||
OPM_THROW(std::runtime_error, "Unknown Relaxtion Type " << relaxationTypeString);
|
||||
OPM_THROW(std::runtime_error,
|
||||
"Unknown Relaxtion Type " + relaxationTypeString);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,8 @@ namespace Dune
|
||||
linsolver_.reset(new Dune::UMFPack<MatrixType>(linearoperator_for_solver_->getmat(), verbosity, dummy));
|
||||
#endif
|
||||
} else {
|
||||
OPM_THROW(std::invalid_argument, "Properties: Solver " << solver_type << " not known.");
|
||||
OPM_THROW(std::invalid_argument,
|
||||
"Properties: Solver " + solver_type + " not known.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,8 +106,9 @@ std::function<Vector()> getWeightsCalculator(const PropertyTree& prm,
|
||||
weightsCalculator = trueFunc;
|
||||
} else {
|
||||
OPM_THROW(std::invalid_argument,
|
||||
"Weights type " << weightsType << "not implemented for cpr."
|
||||
<< " Please use quasiimpes or trueimpes.");
|
||||
"Weights type " + weightsType +
|
||||
"not implemented for cpr."
|
||||
" Please use quasiimpes or trueimpes.");
|
||||
}
|
||||
}
|
||||
return weightsCalculator;
|
||||
|
@ -339,8 +339,8 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
|
||||
} else {
|
||||
// Pointers should not change
|
||||
if ( &(M.istlMatrix()) != matrix_ ) {
|
||||
OPM_THROW(std::logic_error, "Matrix objects are expected to be reused when reassembling!"
|
||||
<<" old pointer was " << matrix_ << ", new one is " << (&M.istlMatrix()) );
|
||||
OPM_THROW(std::logic_error,
|
||||
"Matrix objects are expected to be reused when reassembling!");
|
||||
}
|
||||
}
|
||||
rhs_ = &b;
|
||||
|
@ -134,7 +134,8 @@ void milu0_decomposition(M& A, FieldFunct<M> absFunctor, FieldFunct<M> signFunct
|
||||
}
|
||||
|
||||
if ( a_ik.index() != irow.index() )
|
||||
OPM_THROW(std::logic_error, "Matrix is missing diagonal for row " << irow.index());
|
||||
OPM_THROW(std::logic_error,
|
||||
"Matrix is missing diagonal for row " + std::to_string(irow.index()));
|
||||
|
||||
int index = 0;
|
||||
for(const auto& entry: sum_dropped)
|
||||
|
@ -107,7 +107,8 @@ public:
|
||||
std::string filename = prm.get<std::string>("weights_filename", "impes_weights.txt");
|
||||
std::ofstream outfile(filename);
|
||||
if (!outfile) {
|
||||
OPM_THROW(std::ofstream::failure, "Could not write weights to file " << filename << ".");
|
||||
OPM_THROW(std::ofstream::failure,
|
||||
"Could not write weights to file " + filename + ".");
|
||||
}
|
||||
Dune::writeMatrixMarket(weights_, outfile);
|
||||
}
|
||||
@ -139,7 +140,8 @@ public:
|
||||
auto filename = prm.get<std::string>("weights_filename", "impes_weights.txt");
|
||||
std::ofstream outfile(filename);
|
||||
if (!outfile) {
|
||||
OPM_THROW(std::ofstream::failure, "Could not write weights to file " << filename << ".");
|
||||
OPM_THROW(std::ofstream::failure,
|
||||
"Could not write weights to file " + filename + ".");
|
||||
}
|
||||
Dune::writeMatrixMarket(weights_, outfile);
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ struct StandardPreconditioners
|
||||
auto sargs = AMGSmootherArgsHelper<Smoother>::args(prm);
|
||||
return std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(op, crit, sargs, comm);
|
||||
} else {
|
||||
OPM_THROW(std::invalid_argument, "Properties: No smoother with name " << smoother << ".");
|
||||
OPM_THROW(std::invalid_argument, "Properties: No smoother with name " + smoother + ".");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -343,7 +343,8 @@ struct StandardPreconditioners<Operator,Dune::Amg::SequentialInformation>
|
||||
#endif
|
||||
return AMGHelper<O,C,M,V>::template makeAmgPreconditioner<Smoother>(op, prm);
|
||||
} else {
|
||||
OPM_THROW(std::invalid_argument, "Properties: No smoother with name " << smoother << ".");
|
||||
OPM_THROW(std::invalid_argument,
|
||||
"Properties: No smoother with name " + smoother + ".");
|
||||
}
|
||||
});
|
||||
F::addCreator("kamg", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
|
||||
@ -375,7 +376,8 @@ struct StandardPreconditioners<Operator,Dune::Amg::SequentialInformation>
|
||||
#endif
|
||||
return AMGHelper<O,C,M,V>::template makeAmgPreconditioner<Smoother>(op, prm, true);
|
||||
} else {
|
||||
OPM_THROW(std::invalid_argument, "Properties: No smoother with name " << smoother << ".");
|
||||
OPM_THROW(std::invalid_argument,
|
||||
"Properties: No smoother with name " + smoother + ".");
|
||||
}
|
||||
});
|
||||
F::addCreator("famg", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
|
||||
|
@ -96,9 +96,11 @@ void WellContributions::setBlockSize(unsigned int dim_, unsigned int dim_wells_)
|
||||
dim_wells = dim_wells_;
|
||||
|
||||
if(dim != 3 || dim_wells != 4){
|
||||
std::ostringstream oss;
|
||||
oss << "WellContributions::setBlockSize error: dim and dim_wells must be equal to 3 and 4, repectivelly, otherwise the add well contributions kernel won't work.\n";
|
||||
OPM_THROW(std::logic_error, oss.str());
|
||||
OPM_THROW(std::logic_error,
|
||||
"WellContributions::setBlockSize error: "
|
||||
"dim and dim_wells must be equal to 3 and 4, "
|
||||
"respectively, otherwise the add well contributions "
|
||||
"kernel won't work.\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <opm/simulators/linalg/bda/opencl/openclKernels.hpp>
|
||||
#include <opm/simulators/linalg/bda/Reorder.hpp>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include <opm/simulators/linalg/bda/Reorder.hpp>
|
||||
#include <opm/simulators/linalg/bda/opencl/ChowPatelIlu.hpp> // disable BISAI if ChowPatel is selected
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
namespace Accelerator
|
||||
|
@ -47,18 +47,18 @@ setupPropertyTree(FlowLinearSolverParameters p, // Note: copying the parameters
|
||||
if (conf.size() > 5 && conf.substr(conf.size() - 5, 5) == ".json") { // the ends_with() method is not available until C++20
|
||||
#if BOOST_VERSION / 100 % 1000 > 48
|
||||
if ( !std::filesystem::exists(conf) ) {
|
||||
OPM_THROW(std::invalid_argument, "JSON file " << conf << " does not exist.");
|
||||
OPM_THROW(std::invalid_argument, "JSON file " + conf + " does not exist.");
|
||||
}
|
||||
try {
|
||||
return PropertyTree(conf);
|
||||
}
|
||||
catch (...) {
|
||||
OPM_THROW(std::invalid_argument, "Failed reading linear solver configuration from JSON file " << conf);
|
||||
OPM_THROW(std::invalid_argument, "Failed reading linear solver configuration from JSON file " + conf);
|
||||
}
|
||||
#else
|
||||
OPM_THROW(std::invalid_argument,
|
||||
"--linear-solver-configuration=file.json not supported with "
|
||||
<< "boost version. Needs version > 1.48.");
|
||||
"boost version. Needs version > 1.48.");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -110,8 +110,8 @@ setupPropertyTree(FlowLinearSolverParameters p, // Note: copying the parameters
|
||||
|
||||
// No valid configuration option found.
|
||||
OPM_THROW(std::invalid_argument,
|
||||
conf << " is not a valid setting for --linear-solver-configuration."
|
||||
<< " Please use ilu0, cpr, cpr_trueimpes, cpr_quasiimpes or isai");
|
||||
conf + " is not a valid setting for --linear-solver-configuration."
|
||||
" Please use ilu0, cpr, cpr_trueimpes, cpr_quasiimpes or isai");
|
||||
}
|
||||
|
||||
std::string getSolverString(const FlowLinearSolverParameters& p)
|
||||
|
@ -702,7 +702,8 @@ namespace Opm {
|
||||
|
||||
}
|
||||
else
|
||||
OPM_THROW(std::runtime_error,"Unsupported time step control selected "<< control);
|
||||
OPM_THROW(std::runtime_error,
|
||||
"Unsupported time step control selected " + control);
|
||||
|
||||
// make sure growth factor is something reasonable
|
||||
assert(growthFactor_ >= 1.0);
|
||||
|
@ -51,10 +51,14 @@ namespace Opm
|
||||
, verbose_( verbose )
|
||||
{
|
||||
if( decayrate_ > 1.0 ) {
|
||||
OPM_THROW(std::runtime_error,"SimpleIterationCountTimeStepControl: decay should be <= 1 " << decayrate_ );
|
||||
OPM_THROW(std::runtime_error,
|
||||
"SimpleIterationCountTimeStepControl: "
|
||||
"decay should be <= 1 " + std::to_string(decayrate_));
|
||||
}
|
||||
if( growthrate_ < 1.0 ) {
|
||||
OPM_THROW(std::runtime_error,"SimpleIterationCountTimeStepControl: growth should be >= 1 " << growthrate_ );
|
||||
OPM_THROW(std::runtime_error,
|
||||
"SimpleIterationCountTimeStepControl: "
|
||||
"growth should be >= 1 " + std::to_string(growthrate_));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,8 @@ std::map<std::string,std::string> setupZoltanParams(const std::string& conf)
|
||||
} else if (conf.size() > 5 && conf.substr(conf.size() - 5, 5) == ".json") {
|
||||
#if BOOST_VERSION / 100 % 1000 > 48
|
||||
if ( !std::filesystem::exists(conf) ) {
|
||||
OPM_THROW(std::invalid_argument, "JSON file " << conf << " does not exist.");
|
||||
OPM_THROW(std::invalid_argument,
|
||||
"JSON file " + conf + " does not exist.");
|
||||
}
|
||||
boost::property_tree::ptree tree;
|
||||
try {
|
||||
@ -63,13 +64,13 @@ std::map<std::string,std::string> setupZoltanParams(const std::string& conf)
|
||||
#else
|
||||
OPM_THROW(std::invalid_argument,
|
||||
"--zoltan-params=file.json not supported with "
|
||||
<< "boost version. Needs version > 1.48.");
|
||||
"boost version. Needs version > 1.48.");
|
||||
#endif
|
||||
} else {
|
||||
// No valid configuration option found.
|
||||
OPM_THROW(std::invalid_argument,
|
||||
conf << " is not a valid setting for --zoltan-params."
|
||||
<< " Please use graph, hypergraph or scotch");
|
||||
conf + " is not a valid setting for --zoltan-params."
|
||||
" Please use graph, hypergraph or scotch");
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -293,7 +293,9 @@ initializeWellPerfData()
|
||||
checker.connectionFound(connection_index);
|
||||
if (connection.state() != Connection::State::SHUT) {
|
||||
OPM_THROW(std::runtime_error,
|
||||
"Connection state: " << Connection::State2String(connection.state()) << " not handled");
|
||||
"Connection state: " +
|
||||
Connection::State2String(connection.state()) +
|
||||
" not handled");
|
||||
}
|
||||
}
|
||||
// Note: we rely on the connections being filtered! I.e. there are only connections
|
||||
|
@ -83,8 +83,9 @@ namespace Opm
|
||||
}
|
||||
|
||||
if(this->rsRvInj() > 0) {
|
||||
OPM_THROW(std::runtime_error, "dissolved gas/ vapporized oil in injected oil/gas not supported by multisegment well yet."
|
||||
<< " \n See (WCONINJE item 10 / WCONHIST item 8)");
|
||||
OPM_THROW(std::runtime_error,
|
||||
"dissolved gas/ vapporized oil in injected oil/gas not supported by multisegment well yet."
|
||||
" \n See (WCONINJE item 10 / WCONHIST item 8)");
|
||||
}
|
||||
if constexpr (!Indices::oilEnabled && Indices::numPhases > 1) {
|
||||
OPM_THROW(std::runtime_error, "water + gas case not supported by multisegment well yet");
|
||||
|
@ -595,7 +595,9 @@ const T& getTable(const std::map<int, std::reference_wrapper<const T>>& tables,
|
||||
{
|
||||
auto entry = tables.find(table_id);
|
||||
if (entry == tables.end()) {
|
||||
OPM_THROW(std::invalid_argument, "Nonexistent VFP table " << table_id << " referenced.");
|
||||
OPM_THROW(std::invalid_argument,
|
||||
"Nonexistent VFP table " +
|
||||
std::to_string(table_id) + " referenced.");
|
||||
}
|
||||
else {
|
||||
return entry->second.get();
|
||||
|
@ -393,7 +393,8 @@ WellState::currentWellRates(const std::string& wellName) const
|
||||
auto it = well_rates.find(wellName);
|
||||
|
||||
if (it == well_rates.end())
|
||||
OPM_THROW(std::logic_error, "Could not find any rates for well " << wellName);
|
||||
OPM_THROW(std::logic_error,
|
||||
"Could not find any rates for well " + wellName);
|
||||
|
||||
return it->second.second;
|
||||
}
|
||||
@ -918,8 +919,10 @@ bool WellState::wellIsOwned(std::size_t well_index,
|
||||
bool WellState::wellIsOwned(const std::string& wellName) const
|
||||
{
|
||||
const auto& well_index = this->index(wellName);
|
||||
if (!well_index.has_value())
|
||||
OPM_THROW(std::logic_error, "Could not find well " << wellName << " in well map");
|
||||
if (!well_index.has_value()) {
|
||||
OPM_THROW(std::logic_error,
|
||||
fmt::format("Could not find well {} in well map", wellName));
|
||||
}
|
||||
|
||||
return wellIsOwned(well_index.value(), wellName);
|
||||
}
|
||||
@ -949,4 +952,5 @@ WellState::parallelWellInfo(std::size_t well_index) const
|
||||
|
||||
template void WellState::updateGlobalIsGrup<Parallel::Communication>(const Parallel::Communication& comm);
|
||||
template void WellState::communicateGroupRates<Parallel::Communication>(const Parallel::Communication& comm);
|
||||
|
||||
} // namespace Opm
|
||||
|
@ -56,7 +56,8 @@ void test_milu0(M& A)
|
||||
|
||||
if ( col == colend )
|
||||
{
|
||||
OPM_THROW(std::logic_error, "Missing diagonal entry for row " << irow.index());
|
||||
OPM_THROW(std::logic_error,
|
||||
"Missing diagonal entry for row " + std::to_string(irow.index()));
|
||||
}
|
||||
for (++col ;col != colend; ++col)
|
||||
{
|
||||
|
@ -112,7 +112,9 @@ struct Setup
|
||||
} else {
|
||||
if (completion.state() != Opm::Connection::State::SHUT) {
|
||||
OPM_THROW(std::runtime_error,
|
||||
"Completion state: " << Opm::Connection::State2String(completion.state()) << " not handled");
|
||||
"Completion state: " +
|
||||
Opm::Connection::State2String(completion.state()) +
|
||||
" not handled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user