21 #ifndef OPM_SIM_FIBO_DETAILS_HPP
22 #define OPM_SIM_FIBO_DETAILS_HPP
27 #include <opm/parser/eclipse/EclipseState/Schedule/Events.hpp>
28 #include <opm/core/utility/initHydroCarbonState.hpp>
29 #include <opm/core/well_controls.h>
30 #include <opm/core/wells/DynamicListEconLimited.hpp>
34 namespace SimFIBODetails {
35 typedef std::unordered_map<std::string, const Well* > WellMap;
38 mapWells(
const std::vector< const Well* >& wells)
42 for (std::vector< const Well* >::const_iterator
43 w = wells.begin(), e = wells.end();
46 wmap.insert(std::make_pair((*w)->name(), *w));
53 resv_control(
const WellControls* ctrl)
55 int i, n = well_controls_get_num(ctrl);
58 for (i = 0; (! match) && (i < n); ++i) {
59 match = well_controls_iget_type(ctrl, i) == RESERVOIR_RATE;
62 if (! match) { i = 0; }
68 is_resv(
const Wells& wells,
71 return (0 <= resv_control(wells.ctrls[w]));
75 is_resv(
const WellMap& wmap,
76 const std::string& name,
77 const std::size_t step)
81 WellMap::const_iterator i = wmap.find(name);
83 if (i != wmap.end()) {
84 const Well* wp = i->second;
86 match = (wp->isProducer(step) &&
87 wp->getProductionProperties(step)
88 .hasProductionControl(WellProducer::RESV))
89 || (wp->isInjector(step) &&
90 wp->getInjectionProperties(step)
91 .hasInjectionControl(WellInjector::RESV));
97 inline std::vector<int>
98 resvWells(
const Wells* wells,
99 const std::size_t step,
102 std::vector<int> resv_wells;
105 for (
int w = 0, nw = wells->number_of_wells; w < nw; ++w) {
106 if (is_resv(*wells, w) ||
107 ((wells->name[w] != 0) &&
108 is_resv(wmap, wells->name[w], step)))
110 resv_wells.push_back(w);
119 historyRates(
const PhaseUsage& pu,
120 const WellProductionProperties& p,
121 std::vector<double>& rates)
123 assert (! p.predictionMode);
124 assert (rates.size() ==
125 std::vector<double>::size_type(pu.num_phases));
127 if (pu.phase_used[ BlackoilPhases::Aqua ]) {
128 const std::vector<double>::size_type
129 i = pu.phase_pos[ BlackoilPhases::Aqua ];
131 rates[i] = p.WaterRate;
134 if (pu.phase_used[ BlackoilPhases::Liquid ]) {
135 const std::vector<double>::size_type
136 i = pu.phase_pos[ BlackoilPhases::Liquid ];
138 rates[i] = p.OilRate;
141 if (pu.phase_used[ BlackoilPhases::Vapour ]) {
142 const std::vector<double>::size_type
143 i = pu.phase_pos[ BlackoilPhases::Vapour ];
145 rates[i] = p.GasRate;
151 #endif // OPM_SIM_FIBO_DETAILS_HPP