Improve severity feature, add severityOfWorstFailure().

This commit is contained in:
Atgeirr Flø Rasmussen
2018-10-23 11:28:32 +02:00
parent 34afb0b254
commit 42cb36ab9f
2 changed files with 29 additions and 2 deletions

View File

@@ -22,6 +22,7 @@
#define OPM_CONVERGENCESTATUS_HEADER_INCLUDED
#include <cassert>
#include <numeric>
#include <string>
#include <vector>
@@ -40,7 +41,10 @@ namespace Opm
enum Status { AllGood = 0,
ReservoirFailed = 1 << 0,
WellFailed = 1 << 1 };
enum struct Severity { Normal, TooLarge, NotANumber };
enum struct Severity { None = 0,
Normal = 1,
TooLarge = 2,
NotANumber = 3 };
struct ReservoirFailure
{
enum struct Type { Mb, Cnv };
@@ -123,6 +127,22 @@ namespace Opm
return well_failures_;
}
Severity severityOfWorstFailure() const
{
// A function to get the worst of two severities.
auto smax = [](Severity s1, Severity s2) {
return s1 < s2 ? s2 : s1;
};
auto s = Severity::None;
for (const auto f : res_failures_) {
s = smax(s, f.severity);
}
for (const auto f : well_failures_) {
s = smax(s, f.severity);
}
return s;
}
private:
// ----------- Member variables -----------