From 427f55940e731713fc80a42d681f2f8176601063 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 9 Jan 2014 09:33:21 +0100 Subject: [PATCH] Changed direct access to struct WellControls to use well_controls_get_xxx() api. NB: Do check the calls to well_control_iget_distr(). --- opm/autodiff/FullyImplicitBlackoilSolver.cpp | 20 ++++++++++++++------ opm/autodiff/ImpesTPFAAD.cpp | 19 +++++++++++++------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/opm/autodiff/FullyImplicitBlackoilSolver.cpp b/opm/autodiff/FullyImplicitBlackoilSolver.cpp index 6d53585f2..eed2126e0 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver.cpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -738,14 +739,21 @@ namespace { M rate_distr(nw, np*nw); for (int w = 0; w < nw; ++w) { const WellControls* wc = wells_.ctrls[w]; - if (wc->type[wc->current] == BHP) { - bhp_targets[w] = wc->target[wc->current]; + if (well_controls_get_current_type(wc) == BHP) { + bhp_targets[w] = well_controls_get_current_target(wc); rate_targets[w] = -1e100; - } else if (wc->type[wc->current] == SURFACE_RATE) { + } else if (well_controls_get_current_type( wc ) == SURFACE_RATE) { bhp_targets[w] = -1e100; - rate_targets[w] = wc->target[wc->current]; - for (int phase = 0; phase < np; ++phase) { - rate_distr.insert(w, phase*nw + w) = wc->distr[phase]; + rate_targets[w] = well_controls_get_current_target(wc); + { + /* + Would have guessed that this should use the + well_control_get_current_distr() function instead? + */ + const double * distr = well_controls_iget_distr( wc , 0); + for (int phase = 0; phase < np; ++phase) { + rate_distr.insert(w, phase*nw + w) = distr[phase]; + } } } else { OPM_THROW(std::runtime_error, "Can only handle BHP and SURFACE_RATE type controls."); diff --git a/opm/autodiff/ImpesTPFAAD.cpp b/opm/autodiff/ImpesTPFAAD.cpp index 292031345..b8ce7dffb 100644 --- a/opm/autodiff/ImpesTPFAAD.cpp +++ b/opm/autodiff/ImpesTPFAAD.cpp @@ -377,14 +377,21 @@ namespace { M rate_distr(nw, np*nw); for (int w = 0; w < nw; ++w) { const WellControls* wc = wells_.ctrls[w]; - if (wc->type[wc->current] == BHP) { - bhp_targets[w] = wc->target[wc->current]; + if (well_controls_get_current_type(wc) == BHP) { + bhp_targets[w] = well_controls_get_current_target( wc ); rate_targets[w] = -1e100; - } else if (wc->type[wc->current] == SURFACE_RATE) { + } else if (well_controls_get_current_type(wc) == SURFACE_RATE) { bhp_targets[w] = -1e100; - rate_targets[w] = wc->target[wc->current]; - for (int phase = 0; phase < np; ++phase) { - rate_distr.insert(w, phase*nw + w) = wc->distr[phase]; + rate_targets[w] = well_controls_get_current_target( wc ); + { + /* + Would have guessed that this should use the + well_control_get_current_distr() function instead? + */ + const double * distr = well_controls_iget_distr( wc , 0 ); + for (int phase = 0; phase < np; ++phase) { + rate_distr.insert(w, phase*nw + w) = distr[phase]; + } } } else { OPM_THROW(std::runtime_error, "Can only handle BHP and SURFACE_RATE type controls.");