GuideRateHandler.hpp
Go to the documentation of this file.
1/*
2 Copyright 2025 Equinor ASA
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef OPM_GUIDERATE_HANDLER_HPP
21#define OPM_GUIDERATE_HANDLER_HPP
22
24#include <opm/input/eclipse/Schedule/Group/GuideRate.hpp>
25#include <opm/output/data/Groups.hpp>
26#include <opm/output/data/GuideRateValue.hpp>
32namespace Opm {
33
45template<typename Scalar, typename IndexTraits>
47public:
48
49#ifdef RESERVOIR_COUPLING_ENABLED
51#endif
52
60 public:
62 GuideRateHandler<Scalar, IndexTraits> &parent, const int report_step_idx, const double sim_time
63 );
64
65 DeferredLogger &deferredLogger() { return this->parent_.deferredLogger(); }
70 private:
71 void dumpGuideRatesRecursive_(const Group& group, int level);
72 void getGroupGuideRatesInjection_(
73 const Group& group,
74 const data::GroupGuideRates& group_guide_rate,
75 std::vector<std::string>& msg_items
76 ) const;
77 void getGroupGuideRatesProduction_(
78 const Group& group,
79 const data::GroupGuideRates& group_guide_rate,
80 std::vector<std::string>& msg_items
81 ) const;
88 void printGroupGuideRates_(const Group& group, int level);
89 void printHeader_();
90 void printFooter_();
91 void printWellGuideRates_(const Well& well, int level);
92
94 const int report_step_idx_;
95 const double sim_time_;
97 const Schedule& schedule_;
98 const Parallel::Communication& comm_;
99 std::unordered_map<std::string, data::GuideRateValue> well_guide_rates_;
100 std::unordered_map<std::string, data::GroupGuideRates> group_guide_rates_;
101 };
102
111 public:
114 const int report_step_idx,
115 const double sim_time,
116 const WellState<Scalar, IndexTraits> &well_state,
117 GroupState<Scalar> &group_state,
118 const int num_phases
119 );
120
121 bool isReservoirCouplingMaster() const { return this->parent_.isReservoirCouplingMaster(); }
123 return this->parent_.reservoirCouplingMaster();
124 }
125 const Parallel::Communication &comm() const { return this->parent_.comm_; }
126 DeferredLogger &deferredLogger() { return this->parent_.deferredLogger(); }
127 GuideRate &guideRate() { return this->parent_.guide_rate_; }
128 const PhaseUsageInfo<IndexTraits>& phaseUsage() const { return this->parent_.phaseUsage(); }
129 const SummaryState &summaryState() const { return this->parent_.summary_state_; }
130 const Schedule &schedule() const { return this->parent_.schedule_; }
134 void update();
135
136 private:
137#ifdef RESERVOIR_COUPLING_ENABLED
138 bool isMasterGroup_(const Group& group);
139#endif
140 void updateGuideRatesForInjectionGroups_(const Group& group);
147 void updateGuideRatesForProductionGroups_(const Group& group, std::vector<Scalar>& pot);
148 void updateGuideRatesForWells_();
149#ifdef RESERVOIR_COUPLING_ENABLED
150 void updateProductionGroupPotentialFromSlaveGroup_(
151 const Group& group, std::vector<Scalar>& pot);
152#endif
153 void updateProductionGroupPotentialFromSubGroups(
154 const Group& group, std::vector<Scalar>& pot);
155
157 const int report_step_idx_;
158 const double sim_time_;
159 const WellState<Scalar, IndexTraits> &well_state_;
160 GroupState<Scalar> &group_state_;
161 const int num_phases_;
162 const UnitSystem& unit_system_;
163 };
164
167 const Schedule& schedule,
168 const SummaryState& summary_state,
169 const Parallel::Communication& comm
170 );
171
172 // === Reservoir Coupling ===
173
176 const ReservoirCoupling::Proxy<Scalar>& rescoup() const { return rescoup_; }
177
178 bool isReservoirCouplingMaster() const { return rescoup_.isMaster(); }
179 bool isReservoirCouplingSlave() const { return rescoup_.isSlave(); }
180
183
184#ifdef RESERVOIR_COUPLING_ENABLED
185 void sendSlaveGroupPotentialsToMaster(const GroupState<Scalar>& group_state);
186 void setReservoirCouplingMaster(ReservoirCouplingMaster<Scalar>* master) {
187 rescoup_.setMaster(master);
188 }
189 void setReservoirCouplingSlave(ReservoirCouplingSlave<Scalar>* slave) {
190 rescoup_.setSlave(slave);
191 }
192#endif
202 void debugDumpGuideRates(const int report_step_idx, const double sim_time);
203 const Parallel::Communication& getComm() const { return comm_; }
204 void setLogger(DeferredLogger *deferred_logger) { deferred_logger_ = deferred_logger; }
205 const GuideRate& guideRate() { return guide_rate_; }
206 const PhaseUsageInfo<IndexTraits>& phaseUsage() const { return well_model_.phaseUsage(); }
207 const Schedule& schedule() const { return schedule_; }
208 const SummaryState& summaryState() const { return summary_state_; }
217 void updateGuideRates(const int report_step_idx,
218 const double sim_time,
219 const WellState<Scalar, IndexTraits>& well_state,
220 GroupState<Scalar>& group_state);
221
222 const BlackoilWellModelGeneric<Scalar, IndexTraits>& wellModel() const { return well_model_; }
224private:
225 void debugDumpGuideRatesRecursive_(const Group& group) const;
227 const Schedule& schedule_;
228 const SummaryState& summary_state_;
229 const Parallel::Communication& comm_;
230 GuideRate& guide_rate_;
231 DeferredLogger *deferred_logger_ = nullptr;
233};
234
235} // namespace Opm
236
237#endif // OPM_GUIDERATE_HANDLER_HPP
Class for handling the blackoil well model.
Definition: BlackoilWellModelGeneric.hpp:96
Definition: DeferredLogger.hpp:57
Definition: GroupState.hpp:41
Responsible for formatting and printing guide rate information to logs.
Definition: GuideRateHandler.hpp:59
void dumpGuideRates()
Dumps guide rates for all wells and groups in a hierarchical structure.
GuideRateDumper(GuideRateHandler< Scalar, IndexTraits > &parent, const int report_step_idx, const double sim_time)
DeferredLogger & deferredLogger()
Definition: GuideRateHandler.hpp:65
Computes and updates guide rate values for wells and groups.
Definition: GuideRateHandler.hpp:110
const Parallel::Communication & comm() const
Definition: GuideRateHandler.hpp:125
void update()
Triggers the guide rate update process for the current simulation step.
UpdateGuideRates(GuideRateHandler< Scalar, IndexTraits > &parent, const int report_step_idx, const double sim_time, const WellState< Scalar, IndexTraits > &well_state, GroupState< Scalar > &group_state, const int num_phases)
GuideRate & guideRate()
Definition: GuideRateHandler.hpp:127
DeferredLogger & deferredLogger()
Definition: GuideRateHandler.hpp:126
const PhaseUsageInfo< IndexTraits > & phaseUsage() const
Definition: GuideRateHandler.hpp:128
const Schedule & schedule() const
Definition: GuideRateHandler.hpp:130
bool isReservoirCouplingMaster() const
Definition: GuideRateHandler.hpp:121
ReservoirCouplingMaster< Scalar > & reservoirCouplingMaster()
Definition: GuideRateHandler.hpp:122
const SummaryState & summaryState() const
Definition: GuideRateHandler.hpp:129
Handles computation and reporting of guide rates for wells and groups.
Definition: GuideRateHandler.hpp:46
void debugDumpGuideRates(const int report_step_idx, const double sim_time)
Dumps guide rate information to the logger in a readable format.
const BlackoilWellModelGeneric< Scalar, IndexTraits > & wellModel() const
Definition: GuideRateHandler.hpp:222
ReservoirCoupling::Proxy< Scalar > & rescoup()
Get the reservoir coupling proxy.
Definition: GuideRateHandler.hpp:175
const GuideRate & guideRate()
Definition: GuideRateHandler.hpp:205
const ReservoirCoupling::Proxy< Scalar > & rescoup() const
Definition: GuideRateHandler.hpp:176
void setLogger(DeferredLogger *deferred_logger)
Definition: GuideRateHandler.hpp:204
const SummaryState & summaryState() const
Definition: GuideRateHandler.hpp:208
bool isReservoirCouplingSlave() const
Definition: GuideRateHandler.hpp:179
const Schedule & schedule() const
Definition: GuideRateHandler.hpp:207
const Parallel::Communication & getComm() const
Definition: GuideRateHandler.hpp:203
BlackoilWellModelGeneric< Scalar, IndexTraits > & wellModel()
Definition: GuideRateHandler.hpp:223
const PhaseUsageInfo< IndexTraits > & phaseUsage() const
Definition: GuideRateHandler.hpp:206
GuideRateHandler(BlackoilWellModelGeneric< Scalar, IndexTraits > &well_model, const Schedule &schedule, const SummaryState &summary_state, const Parallel::Communication &comm)
bool isReservoirCouplingMaster() const
Definition: GuideRateHandler.hpp:178
ReservoirCouplingMaster< Scalar > & reservoirCouplingMaster()
Definition: GuideRateHandler.hpp:181
ReservoirCouplingSlave< Scalar > & reservoirCouplingSlave()
Definition: GuideRateHandler.hpp:182
void updateGuideRates(const int report_step_idx, const double sim_time, const WellState< Scalar, IndexTraits > &well_state, GroupState< Scalar > &group_state)
Updates guide rates for the current simulation step.
DeferredLogger & deferredLogger()
Definition: GasLiftGroupInfo.hpp:37
Thin proxy for reservoir coupling master/slave pointers.
Definition: RescoupProxy.hpp:54
Definition: ReservoirCouplingMaster.hpp:38
Definition: ReservoirCouplingSlave.hpp:40
Definition: WellState.hpp:66
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
Definition: blackoilbioeffectsmodules.hh:43
Definition: ReservoirCoupling.hpp:166