From 58ba8f45ebde0515490f7b444f56ac9738620578 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Mon, 6 Jan 2014 12:22:15 +0100 Subject: [PATCH] Added new function well_controls_iset_distr(). --- opm/core/well_controls.h | 3 +++ opm/core/wells/well_controls.c | 8 ++++++++ tests/test_wellcontrols.cpp | 9 +++++++++ 3 files changed, 20 insertions(+) diff --git a/opm/core/well_controls.h b/opm/core/well_controls.h index a98c4824..9d572af3 100644 --- a/opm/core/well_controls.h +++ b/opm/core/well_controls.h @@ -142,6 +142,9 @@ well_controls_iget_target(const struct WellControls * ctrl, int control_index); 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); + 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 3a858784..80d6b9e4 100644 --- a/opm/core/wells/well_controls.c +++ b/opm/core/wells/well_controls.c @@ -174,6 +174,14 @@ 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) { + int offset = control_index * ctrl->number_of_phases; + for (int p=0; p < ctrl->number_of_phases; p++) + ctrl->distr[offset + p] = distr[p]; +} + + void well_controls_assert_number_of_phases(struct WellControls * ctrl , int number_of_phases) { if (ctrl->num == 0) diff --git a/tests/test_wellcontrols.cpp b/tests/test_wellcontrols.cpp index 47bc97bb..f98b62fe 100644 --- a/tests/test_wellcontrols.cpp +++ b/tests/test_wellcontrols.cpp @@ -87,6 +87,15 @@ BOOST_AUTO_TEST_CASE(Construction) BOOST_CHECK_EQUAL( BHP, well_controls_iget_type( ctrls , 1 )); + { + double newDist[3] = {77,78,79}; + const double * tmp; + well_controls_iset_distr( ctrls , 0 , newDist ); + tmp = well_controls_iget_distr( ctrls , 0); + BOOST_CHECK( memcmp(tmp , newDist , 3 * sizeof * tmp ) == 0); + } + + well_controls_destroy( ctrls ); }