From b3468459038c1787498cd78725833387f6f7cf9b Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Mon, 6 Jan 2014 14:40:03 +0100 Subject: [PATCH] Added functions to get type, target and distr of *current* control. --- opm/core/well_controls.h | 9 +++++++++ opm/core/wells/well_controls.c | 20 +++++++++++++++++++- tests/test_wellcontrols.cpp | 7 +++++-- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/opm/core/well_controls.h b/opm/core/well_controls.h index 9d572af3..8e59e240 100644 --- a/opm/core/well_controls.h +++ b/opm/core/well_controls.h @@ -130,6 +130,9 @@ well_controls_add_new(enum WellControlType type , double target , const double * enum WellControlType well_controls_iget_type(const struct WellControls * ctrl, int control_index); +enum WellControlType +well_controls_get_current_type(const struct WellControls * ctrl); + void well_controls_iset_type( struct WellControls * ctrls , int control_index , enum WellControlType type); @@ -139,12 +142,18 @@ well_controls_iset_target(struct WellControls * ctrl, int control_index , double double well_controls_iget_target(const struct WellControls * ctrl, int control_index); +double +well_controls_get_current_target(const struct WellControls * ctrl); + const double * well_controls_iget_distr(const struct WellControls * ctrl, int control_index); void well_controls_iset_distr(const struct WellControls * ctrl, int control_index, const double * distr); +const double * +well_controls_get_current_distr(const struct WellControls * ctrl); + void well_controls_assert_number_of_phases(struct WellControls * ctrl , int number_of_phases); diff --git a/opm/core/wells/well_controls.c b/opm/core/wells/well_controls.c index cc2b685d..900da3f9 100644 --- a/opm/core/wells/well_controls.c +++ b/opm/core/wells/well_controls.c @@ -38,7 +38,6 @@ #define HAVE_WELLCONTROLS #include - #include #include #include @@ -150,6 +149,13 @@ well_controls_iget_type(const struct WellControls * ctrl, int control_index) { return ctrl->type[control_index]; } + +enum WellControlType +well_controls_get_current_type(const struct WellControls * ctrl) { + return well_controls_iget_type( ctrl , ctrl->current); +} + + void well_controls_iset_type( struct WellControls * ctrls , int control_index , enum WellControlType type) { ctrls->type[control_index] = type; @@ -161,6 +167,11 @@ well_controls_iget_target(const struct WellControls * ctrl, int control_index) { return ctrl->target[control_index]; } +double +well_controls_get_current_target(const struct WellControls * ctrl) { + return ctrl->target[ctrl->current]; +} + void well_controls_iset_target(struct WellControls * ctrl, int control_index , double target) { ctrl->target[control_index] = target; @@ -174,6 +185,13 @@ well_controls_iget_distr(const struct WellControls * ctrl, int control_index) { } +const double * +well_controls_get_current_distr(const struct WellControls * ctrl) { + return well_controls_iget_distr( ctrl , ctrl->current ); +} + + + void well_controls_iset_distr(const struct WellControls * ctrl, int control_index, const double * distr) { int offset = control_index * ctrl->number_of_phases; diff --git a/tests/test_wellcontrols.cpp b/tests/test_wellcontrols.cpp index f98b62fe..096b9c6a 100644 --- a/tests/test_wellcontrols.cpp +++ b/tests/test_wellcontrols.cpp @@ -29,7 +29,6 @@ #include #include -#define HAVE_WELLCONTROLS #include #include @@ -68,7 +67,11 @@ BOOST_AUTO_TEST_CASE(Construction) BOOST_CHECK_EQUAL( 2*target , well_controls_iget_target(ctrls , 1 )); BOOST_CHECK_EQUAL( type2 , well_controls_iget_type(ctrls , 1 )); - + well_controls_set_current( ctrls , 1 ); + BOOST_CHECK_EQUAL( type2 , well_controls_get_current_type( ctrls )); + + BOOST_CHECK_EQUAL( well_controls_iget_target( ctrls , 1 ) , well_controls_get_current_target( ctrls )); + { const double * d1 = well_controls_iget_distr( ctrls , 0 ); const double * d2 = well_controls_iget_distr( ctrls , 1 );