21 #ifndef OPM_CONVERGENCEREPORT_HEADER_INCLUDED 22 #define OPM_CONVERGENCEREPORT_HEADER_INCLUDED 45 ReservoirFailed = 1 << 0,
49 enum struct Severity {
52 ConvergenceMonitorFailure = 2,
60 int largeWellResiduals{0};
63 return nonConverged + distanceDecay + largeWellResiduals;
70 largeWellResiduals = 0;
74 nonConverged += other.nonConverged;
75 distanceDecay += other.distanceDecay;
76 largeWellResiduals += other.largeWellResiduals;
80 template <
typename Serializer>
81 void serializeOp(Serializer& serializer)
83 serializer(nonConverged);
84 serializer(distanceDecay);
85 serializer(largeWellResiduals);
89 using CnvPvSplit = std::pair<
96 enum struct Type { Invalid, MassBalance, Cnv, ConvergenceMonitorFailure };
103 : type_(t), severity_(s), phase_(phase)
106 Type type()
const {
return type_; }
107 Severity severity()
const {
return severity_; }
108 int phase()
const {
return phase_; }
110 template <
typename Serializer>
111 void serializeOp(Serializer& serializer)
113 serializer(this->type_);
114 serializer(this->severity_);
115 serializer(this->phase_);
121 Type type_ { Type::Invalid };
122 Severity severity_ { Severity::None };
134 : type_(t), phase_(phase), value_(value), tolerance_(tolerance)
137 ReservoirFailure::Type type()
const {
return type_; }
138 int phase()
const {
return phase_; }
139 double value()
const {
return value_; }
140 double tolerance()
const {
return tolerance_; }
142 template <
typename Serializer>
143 void serializeOp(Serializer& serializer)
145 serializer(this->type_);
146 serializer(this->phase_);
147 serializer(this->value_);
148 serializer(this->tolerance_);
154 ReservoirFailure::Type type_ { ReservoirFailure::Type::Invalid };
156 double value_ { 0.0 };
157 double tolerance_ { 0.0 };
179 WellFailure(Type t, Severity s,
int phase,
const std::string& well_name)
180 : type_(t), severity_(s), phase_(phase), well_name_(well_name)
183 Type type()
const {
return type_; }
184 Severity severity()
const {
return severity_; }
185 int phase()
const {
return phase_; }
186 const std::string& wellName()
const {
return well_name_; }
188 template <
typename Serializer>
189 void serializeOp(Serializer& serializer)
191 serializer(this->type_);
192 serializer(this->severity_);
193 serializer(this->phase_);
194 serializer(this->well_name_);
200 Type type_ { Type::Invalid };
201 Severity severity_ { Severity::None };
203 std::string well_name_ {};
213 WellConvergenceMetric(WellFailure::Type t, Severity s,
int phase,
double value,
const std::string& well_name)
214 : type_(t), severity_(s), phase_(phase), value_(value), well_name_(well_name)
217 WellFailure::Type type()
const {
return type_; }
218 Severity severity()
const {
return severity_; }
219 int phase()
const {
return phase_; }
220 double value()
const {
return value_; }
221 const std::string& wellName()
const {
return well_name_; }
223 template <
typename Serializer>
224 void serializeOp(Serializer& serializer)
226 serializer(this->type_);
227 serializer(this->severity_);
228 serializer(this->phase_);
229 serializer(this->value_);
230 serializer(this->well_name_);
236 WellFailure::Type type_ { WellFailure::Type::Invalid };
237 Severity severity_ { Severity::None };
239 double value_ { 0.0 };
240 std::string well_name_ {};
249 explicit ConvergenceReport(
const double reportTime)
250 : reportTime_{reportTime}
254 , wellGroupTargetsViolated_(
false)
255 , network_needs_more_balancing_force_another_newton_iteration_(
false)
261 res_failures_.clear();
262 well_failures_.clear();
263 wellGroupTargetsViolated_ =
false;
264 network_needs_more_balancing_force_another_newton_iteration_ =
false;
267 void setReservoirFailed(
const ReservoirFailure& rf)
269 status_ =
static_cast<Status
>(status_ | ReservoirFailed);
270 res_failures_.push_back(rf);
273 void setWellFailed(
const WellFailure& wf)
275 status_ =
static_cast<Status
>(status_ | WellFailed);
276 well_failures_.push_back(wf);
279 template <
typename... Args>
280 void setReservoirConvergenceMetric(Args&&... args)
282 this->res_convergence_.emplace_back(std::forward<Args>(args)...);
285 template <
typename... Args>
286 void setWellConvergenceMetric(Args&&... args)
288 this->well_convergence_.emplace_back(std::forward<Args>(args)...);
291 void setWellGroupTargetsViolated(
const bool wellGroupTargetsViolated)
293 wellGroupTargetsViolated_ = wellGroupTargetsViolated;
296 void setNetworkNotYetBalancedForceAnotherNewtonIteration(
const bool network_needs_more_balancing_force_another_newton_iteration)
298 network_needs_more_balancing_force_another_newton_iteration_ = network_needs_more_balancing_force_another_newton_iteration;
301 void setCnvPoreVolSplit(
const CnvPvSplit& cnvPvSplit,
302 const double eligiblePoreVolume)
304 this->cnvPvSplit_ = cnvPvSplit;
305 this->eligiblePoreVolume_ = eligiblePoreVolume;
308 ConvergenceReport& operator+=(
const ConvergenceReport& other)
310 reportTime_ = std::max(reportTime_, other.reportTime_);
311 status_ =
static_cast<Status
>(status_ | other.status_);
312 res_failures_.insert(res_failures_.end(), other.res_failures_.begin(), other.res_failures_.end());
313 well_failures_.insert(well_failures_.end(), other.well_failures_.begin(), other.well_failures_.end());
314 res_convergence_.insert(res_convergence_.end(), other.res_convergence_.begin(), other.res_convergence_.end());
315 well_convergence_.insert(well_convergence_.end(), other.well_convergence_.begin(), other.well_convergence_.end());
316 assert(reservoirFailed() != res_failures_.empty());
317 assert(wellFailed() != well_failures_.empty());
318 wellGroupTargetsViolated_ = (wellGroupTargetsViolated_ || other.wellGroupTargetsViolated_);
319 network_needs_more_balancing_force_another_newton_iteration_ = (network_needs_more_balancing_force_another_newton_iteration_
320 || other.network_needs_more_balancing_force_another_newton_iteration_);
329 if (! other.cnvPvSplit_.first.empty()) {
330 this->cnvPvSplit_ = other.cnvPvSplit_;
331 this->eligiblePoreVolume_ = other.eligiblePoreVolume_;
339 double reportTime()
const 344 double eligiblePoreVolume()
const 346 return this->eligiblePoreVolume_;
349 const CnvPvSplit& cnvPvSplit()
const 351 return this->cnvPvSplit_;
354 bool converged()
const 356 return (status_ == AllGood)
357 && !wellGroupTargetsViolated_
358 && !network_needs_more_balancing_force_another_newton_iteration_;
361 bool reservoirFailed()
const 363 return status_ & ReservoirFailed;
366 bool wellFailed()
const 368 return status_ & WellFailed;
371 const std::vector<ReservoirFailure>& reservoirFailures()
const 373 return res_failures_;
376 const std::vector<ReservoirConvergenceMetric>& reservoirConvergence()
const 378 return res_convergence_;
381 const std::vector<WellFailure>& wellFailures()
const 383 return well_failures_;
386 const std::vector<WellConvergenceMetric>& wellConvergence()
const 388 return well_convergence_;
391 const PenaltyCard& getPenaltyCard()
const 396 void addNonConvergedPenalty()
398 penaltyCard_.nonConverged++;
401 void addDistanceDecayPenalty()
403 penaltyCard_.distanceDecay++;
406 void addLargeWellResidualsPenalty()
408 penaltyCard_.largeWellResiduals++;
411 Severity severityOfWorstFailure()
const 414 auto smax = [](Severity s1, Severity s2) {
415 return s1 < s2 ? s2 : s1;
417 auto s = Severity::None;
418 for (
const auto& f : res_failures_) {
419 s = smax(s, f.severity());
421 for (
const auto& f : well_failures_) {
422 s = smax(s, f.severity());
427 template <
typename Serializer>
428 void serializeOp(Serializer& serializer)
430 serializer(this->reportTime_);
431 serializer(this->status_);
432 serializer(this->res_failures_);
433 serializer(this->well_failures_);
434 serializer(this->res_convergence_);
435 serializer(this->well_convergence_);
436 serializer(this->wellGroupTargetsViolated_);
437 serializer(this->network_needs_more_balancing_force_another_newton_iteration_);
438 serializer(this->cnvPvSplit_);
439 serializer(this->eligiblePoreVolume_);
440 serializer(this->penaltyCard_);
449 std::vector<ReservoirFailure> res_failures_;
450 std::vector<WellFailure> well_failures_;
451 std::vector<ReservoirConvergenceMetric> res_convergence_;
452 std::vector<WellConvergenceMetric> well_convergence_;
453 bool wellGroupTargetsViolated_;
454 bool network_needs_more_balancing_force_another_newton_iteration_;
455 CnvPvSplit cnvPvSplit_{};
456 double eligiblePoreVolume_{};
457 PenaltyCard penaltyCard_;
464 std::vector<ConvergenceReport> report;
467 std::string to_string(
const ConvergenceReport::ReservoirFailure::Type t);
469 std::string to_string(
const ConvergenceReport::Severity s);
471 std::string to_string(
const ConvergenceReport::WellFailure::Type t);
481 #endif // OPM_CONVERGENCEREPORT_HEADER_INCLUDED Definition: ConvergenceReport.hpp:460
Structs needed for tpfalinearizer and its gpuparams struct extracted to be defined in one place that ...
Definition: blackoilbioeffectsmodules.hh:45
Definition: ConvergenceReport.hpp:160
Definition: ConvergenceReport.hpp:93
Definition: ConvergenceReport.hpp:206
Definition: ConvergenceReport.hpp:126
Represents the convergence status of the whole simulator, to make it possible to query and store the ...
Definition: ConvergenceReport.hpp:37
Definition: ConvergenceReport.hpp:57