21#ifndef OPM_CONVERGENCEREPORT_HEADER_INCLUDED
22#define OPM_CONVERGENCEREPORT_HEADER_INCLUDED
41 enum Status { AllGood = 0,
42 ReservoirFailed = 1 << 0,
43 WellFailed = 1 << 1 };
44 enum struct Severity { None = 0,
51 enum struct Type { Invalid, MassBalance, Cnv };
53 : type_(t), severity_(s), phase_(phase)
56 Type type()
const {
return type_; }
57 Severity severity()
const {
return severity_; }
58 int phase()
const {
return phase_; }
67 enum struct Type { Invalid, MassBalance, Pressure, ControlBHP, ControlTHP, ControlRate, Unsolvable };
68 WellFailure(Type t, Severity s,
int phase,
const std::string& well_name)
69 : type_(t), severity_(s), phase_(phase), well_name_(well_name)
72 Type type()
const {
return type_; }
73 Severity severity()
const {
return severity_; }
74 int phase()
const {
return phase_; }
75 const std::string& wellName()
const {
return well_name_; }
80 std::string well_name_;
89 , wellGroupTargetsViolated_(false)
96 res_failures_.clear();
97 well_failures_.clear();
98 wellGroupTargetsViolated_ =
false;
101 void setReservoirFailed(
const ReservoirFailure& rf)
103 status_ =
static_cast<Status
>(status_ | ReservoirFailed);
104 res_failures_.push_back(rf);
107 void setWellFailed(
const WellFailure& wf)
109 status_ =
static_cast<Status
>(status_ | WellFailed);
110 well_failures_.push_back(wf);
113 void setWellGroupTargetsViolated(
const bool wellGroupTargetsViolated)
115 wellGroupTargetsViolated_ = wellGroupTargetsViolated;
118 ConvergenceReport& operator+=(
const ConvergenceReport& other)
120 status_ =
static_cast<Status
>(status_ | other.status_);
121 res_failures_.insert(res_failures_.end(), other.res_failures_.begin(), other.res_failures_.end());
122 well_failures_.insert(well_failures_.end(), other.well_failures_.begin(), other.well_failures_.end());
123 assert(reservoirFailed() != res_failures_.empty());
124 assert(wellFailed() != well_failures_.empty());
125 wellGroupTargetsViolated_ = (wellGroupTargetsViolated_ || other.wellGroupTargetsViolated_);
131 bool converged()
const
133 return (status_ == AllGood) && !wellGroupTargetsViolated_;
136 bool reservoirFailed()
const
138 return status_ & ReservoirFailed;
141 bool wellFailed()
const
143 return status_ & WellFailed;
146 const std::vector<ReservoirFailure>& reservoirFailures()
const
148 return res_failures_;
151 const std::vector<WellFailure>& wellFailures()
const
153 return well_failures_;
156 Severity severityOfWorstFailure()
const
159 auto smax = [](Severity s1, Severity s2) {
160 return s1 < s2 ? s2 : s1;
162 auto s = Severity::None;
163 for (
const auto& f : res_failures_) {
164 s = smax(s, f.severity());
166 for (
const auto& f : well_failures_) {
167 s = smax(s, f.severity());
176 std::vector<ReservoirFailure> res_failures_;
177 std::vector<WellFailure> well_failures_;
178 bool wellGroupTargetsViolated_;
Definition: ConvergenceReport.hpp:49
Definition: ConvergenceReport.hpp:65
Represents the convergence status of the whole simulator, to make it possible to query and store the ...
Definition: ConvergenceReport.hpp:36
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27