From 9f1e3465db5e18cf88485997ca6184e27327a527 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Mon, 1 Jul 2019 18:17:27 +0200 Subject: [PATCH] Throw std::logic_error if trying to access invalid current control --- opm/core/wells/well_controls.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/opm/core/wells/well_controls.cpp b/opm/core/wells/well_controls.cpp index 00f7fd745..541dbb8e4 100644 --- a/opm/core/wells/well_controls.cpp +++ b/opm/core/wells/well_controls.cpp @@ -42,6 +42,8 @@ #include #include +#include + /** * Controls for a single well. * Each control specifies a well rate or bottom-hole pressure. Only @@ -295,6 +297,8 @@ well_controls_iget_type(const struct WellControls * ctrl, int control_index) { enum WellControlType well_controls_get_current_type(const struct WellControls * ctrl) { + if (ctrl->current < 0) + throw std::logic_error("Tried to use invalid current control < 0"); return well_controls_iget_type( ctrl , ctrl->current); } @@ -312,6 +316,8 @@ well_controls_iget_target(const struct WellControls * ctrl, int control_index) { double well_controls_get_current_target(const struct WellControls * ctrl) { + if (ctrl->current < 0) + throw std::logic_error("Tried to use invalid current control < 0"); return ctrl->target[ctrl->current]; }