Made ReservoirFailure and WellFailure into classes.

This commit is contained in:
Atgeirr Flø Rasmussen 2018-10-25 13:08:16 +02:00
parent 852765a65b
commit 671ed75535
3 changed files with 68 additions and 48 deletions

View File

@ -671,8 +671,8 @@ namespace Opm {
{
// Debug reporting.
for (const auto& f : report.wellFailures()) {
if (f.severity == ConvergenceReport::Severity::NotANumber) {
OpmLog::debug("NaN residual found with phase " + std::to_string(f.phase) + " for well " + f.well_name);
if (f.severity() == ConvergenceReport::Severity::NotANumber) {
OpmLog::debug("NaN residual found with phase " + std::to_string(f.phase()) + " for well " + f.wellName());
}
}
@ -690,8 +690,8 @@ namespace Opm {
{
// Debug reporting.
for (const auto& f : report.wellFailures()) {
if (f.severity == ConvergenceReport::Severity::TooLarge) {
OpmLog::debug("Too large residual found with phase " + std::to_string(f.phase) + " for well " + f.well_name);
if (f.severity() == ConvergenceReport::Severity::TooLarge) {
OpmLog::debug("Too large residual found with phase " + std::to_string(f.phase()) + " for well " + f.wellName());
}
}

View File

@ -45,21 +45,41 @@ namespace Opm
Normal = 1,
TooLarge = 2,
NotANumber = 3 };
struct ReservoirFailure
class ReservoirFailure
{
public:
enum struct Type { Invalid, MassBalance, Cnv };
Type type;
Severity severity;
int phase;
int cell_index;
ReservoirFailure(Type t, Severity s, int phase, int cell_index)
: type_(t), severity_(s), phase_(phase), cell_index_(cell_index)
{
}
Type type() const { return type_; }
Severity severity() const { return severity_; }
int phase() const { return phase_; }
int cellIndex() const { return cell_index_; }
private:
Type type_;
Severity severity_;
int phase_;
int cell_index_;
};
struct WellFailure
class WellFailure
{
public:
enum struct Type { Invalid, MassBalance, Pressure, ControlBHP, ControlTHP, ControlRate };
Type type;
Severity severity;
int phase;
std::string well_name;
WellFailure(Type t, Severity s, int phase, const std::string& well_name)
: type_(t), severity_(s), phase_(phase), well_name_(well_name)
{
}
Type type() const { return type_; }
Severity severity() const { return severity_; }
int phase() const { return phase_; }
const std::string& wellName() const { return well_name_; }
private:
Type type_;
Severity severity_;
int phase_;
std::string well_name_;
};
// ----------- Mutating member functions -----------
@ -135,10 +155,10 @@ namespace Opm
};
auto s = Severity::None;
for (const auto f : res_failures_) {
s = smax(s, f.severity);
s = smax(s, f.severity());
}
for (const auto f : well_failures_) {
s = smax(s, f.severity);
s = smax(s, f.severity());
}
return s;
}

View File

@ -45,10 +45,10 @@ BOOST_AUTO_TEST_CASE(Failures)
BOOST_CHECK(!s1.wellFailed());
BOOST_REQUIRE(s1.reservoirFailures().size() == 1);
const auto f = s1.reservoirFailures()[0];
BOOST_CHECK(f.type == CR::ReservoirFailure::Type::Cnv);
BOOST_CHECK(f.severity == CR::Severity::Normal);
BOOST_CHECK(f.phase == 2);
BOOST_CHECK(f.cell_index == 100);
BOOST_CHECK(f.type() == CR::ReservoirFailure::Type::Cnv);
BOOST_CHECK(f.severity() == CR::Severity::Normal);
BOOST_CHECK(f.phase() == 2);
BOOST_CHECK(f.cellIndex() == 100);
BOOST_CHECK(s1.wellFailures().empty());
BOOST_CHECK(s1.severityOfWorstFailure() == CR::Severity::Normal);
}
@ -63,15 +63,15 @@ BOOST_AUTO_TEST_CASE(Failures)
BOOST_CHECK(s2.reservoirFailures().empty());
BOOST_REQUIRE(s2.wellFailures().size() == 2);
const auto f0 = s2.wellFailures()[0];
BOOST_CHECK(f0.type == CR::WellFailure::Type::ControlTHP);
BOOST_CHECK(f0.severity == CR::Severity::Normal);
BOOST_CHECK(f0.phase == -1);
BOOST_CHECK(f0.well_name == "PRODUCER-123");
BOOST_CHECK(f0.type() == CR::WellFailure::Type::ControlTHP);
BOOST_CHECK(f0.severity() == CR::Severity::Normal);
BOOST_CHECK(f0.phase() == -1);
BOOST_CHECK(f0.wellName() == "PRODUCER-123");
const auto f1 = s2.wellFailures()[1];
BOOST_CHECK(f1.type == CR::WellFailure::Type::MassBalance);
BOOST_CHECK(f1.severity == CR::Severity::TooLarge);
BOOST_CHECK(f1.phase == 2);
BOOST_CHECK(f1.well_name == "INJECTOR-XYZ");
BOOST_CHECK(f1.type() == CR::WellFailure::Type::MassBalance);
BOOST_CHECK(f1.severity() == CR::Severity::TooLarge);
BOOST_CHECK(f1.phase() == 2);
BOOST_CHECK(f1.wellName() == "INJECTOR-XYZ");
BOOST_CHECK(s2.severityOfWorstFailure() == CR::Severity::TooLarge);
}
@ -82,21 +82,21 @@ BOOST_AUTO_TEST_CASE(Failures)
BOOST_CHECK(s1.wellFailed());
BOOST_REQUIRE(s1.reservoirFailures().size() == 1);
const auto f = s1.reservoirFailures()[0];
BOOST_CHECK(f.type == CR::ReservoirFailure::Type::Cnv);
BOOST_CHECK(f.severity == CR::Severity::Normal);
BOOST_CHECK(f.phase == 2);
BOOST_CHECK(f.cell_index == 100);
BOOST_CHECK(f.type() == CR::ReservoirFailure::Type::Cnv);
BOOST_CHECK(f.severity() == CR::Severity::Normal);
BOOST_CHECK(f.phase() == 2);
BOOST_CHECK(f.cellIndex() == 100);
BOOST_REQUIRE(s1.wellFailures().size() == 2);
const auto f0 = s1.wellFailures()[0];
BOOST_CHECK(f0.type == CR::WellFailure::Type::ControlTHP);
BOOST_CHECK(f0.severity == CR::Severity::Normal);
BOOST_CHECK(f0.phase == -1);
BOOST_CHECK(f0.well_name == "PRODUCER-123");
BOOST_CHECK(f0.type() == CR::WellFailure::Type::ControlTHP);
BOOST_CHECK(f0.severity() == CR::Severity::Normal);
BOOST_CHECK(f0.phase() == -1);
BOOST_CHECK(f0.wellName() == "PRODUCER-123");
const auto f1 = s1.wellFailures()[1];
BOOST_CHECK(f1.type == CR::WellFailure::Type::MassBalance);
BOOST_CHECK(f1.severity == CR::Severity::TooLarge);
BOOST_CHECK(f1.phase == 2);
BOOST_CHECK(f1.well_name == "INJECTOR-XYZ");
BOOST_CHECK(f1.type() == CR::WellFailure::Type::MassBalance);
BOOST_CHECK(f1.severity() == CR::Severity::TooLarge);
BOOST_CHECK(f1.phase() == 2);
BOOST_CHECK(f1.wellName() == "INJECTOR-XYZ");
BOOST_CHECK(s1.severityOfWorstFailure() == CR::Severity::TooLarge);
}
@ -116,15 +116,15 @@ BOOST_AUTO_TEST_CASE(Failures)
BOOST_CHECK(s1.reservoirFailures().empty());
BOOST_REQUIRE(s1.wellFailures().size() == 2);
const auto f0 = s1.wellFailures()[0];
BOOST_CHECK(f0.type == CR::WellFailure::Type::ControlTHP);
BOOST_CHECK(f0.severity == CR::Severity::Normal);
BOOST_CHECK(f0.phase == -1);
BOOST_CHECK(f0.well_name == "PRODUCER-123");
BOOST_CHECK(f0.type() == CR::WellFailure::Type::ControlTHP);
BOOST_CHECK(f0.severity() == CR::Severity::Normal);
BOOST_CHECK(f0.phase() == -1);
BOOST_CHECK(f0.wellName() == "PRODUCER-123");
const auto f1 = s1.wellFailures()[1];
BOOST_CHECK(f1.type == CR::WellFailure::Type::MassBalance);
BOOST_CHECK(f1.severity == CR::Severity::TooLarge);
BOOST_CHECK(f1.phase == 2);
BOOST_CHECK(f1.well_name == "INJECTOR-XYZ");
BOOST_CHECK(f1.type() == CR::WellFailure::Type::MassBalance);
BOOST_CHECK(f1.severity() == CR::Severity::TooLarge);
BOOST_CHECK(f1.phase() == 2);
BOOST_CHECK(f1.wellName() == "INJECTOR-XYZ");
BOOST_CHECK(s1.severityOfWorstFailure() == CR::Severity::TooLarge);
}
}