opm-simulators
BlackoilWellModelConstraints.hpp
1 /*
2  Copyright 2016 SINTEF ICT, Applied Mathematics.
3  Copyright 2016 - 2017 Statoil ASA.
4  Copyright 2017 Dr. Blatt - HPC-Simulation-Software & Services
5  Copyright 2016 - 2018 IRIS AS
6 
7  This file is part of the Open Porous Media project (OPM).
8 
9  OPM is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OPM is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OPM. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #ifndef OPM_BLACKOILWELLMODEL_CONSTRAINTS_HEADER_INCLUDED
24 #define OPM_BLACKOILWELLMODEL_CONSTRAINTS_HEADER_INCLUDED
25 
26 #include <opm/input/eclipse/Schedule/Group/Group.hpp>
27 #include <optional>
28 #include <utility>
29 
30 namespace Opm {
31 
32 template<typename Scalar, typename IndexTraits> class BlackoilWellModelGeneric;
33 class DeferredLogger;
34 template<class Scalar> class GroupState;
35 class SummaryState;
36 template<typename Scalar, typename IndexTraits> class WellState;
37 template<typename Scalar, typename IndexTraits> class GroupStateHelper;
38 
40 template<typename Scalar, typename IndexTraits>
42 {
43 public:
44  constexpr static int waterPhaseIdx = IndexTraits::waterPhaseIdx;
45  constexpr static int oilPhaseIdx = IndexTraits::oilPhaseIdx;
46  constexpr static int gasPhaseIdx = IndexTraits::gasPhaseIdx;
47 
49 
52  : wellModel_(wellModel)
53  {}
54 
56  void actionOnBrokenConstraints(const Group& group,
57  const Group::InjectionCMode& newControl,
58  const Phase& controlPhase,
59  GroupState<Scalar>& group_state,
60  DeferredLogger& deferred_logger) const;
61 
63  bool actionOnBrokenConstraints(const Group& group,
64  const Group::GroupLimitAction group_limit_action,
65  const Group::ProductionCMode& newControl,
66  std::optional<std::string>& worst_offending_well,
67  GroupState<Scalar>& group_state,
68  DeferredLogger& deferred_logger) const;
69 
71  bool updateGroupIndividualControl(const Group& group,
72  const int reportStepIdx,
73  const int max_number_of_group_switch,
74  const bool update_group_switching_log,
75  std::map<std::string, std::array<std::vector<Group::InjectionCMode>, 3>>& switched_inj,
76  std::map<std::string, std::vector<Group::ProductionCMode>>& switched_prod,
77  std::map<std::string, std::pair<std::string, std::string>>& closed_offending_wells,
78  GroupState<Scalar>& group_state,
80  DeferredLogger& deferred_logger) const;
81 
82 private:
84  std::pair<Group::InjectionCMode, Scalar>
85  checkGroupInjectionConstraints(const Group& group,
86  const int reportStepIdx,
87  const Phase& phase) const;
88 
90  std::pair<Group::ProductionCMode, Scalar>
91  checkGroupProductionConstraints(const Group& group) const;
92 
94  bool updateInjectionGroupControl(const Group& group,
95  const int reportStepIdx,
96  const int max_number_of_group_switch,
97  const bool update_group_switching_log,
98  std::map<std::string, std::array<std::vector<Group::InjectionCMode>, 3>>& switched_inj,
99  GroupState<Scalar>& group_state,
100  WellState<Scalar, IndexTraits>& well_state,
101  DeferredLogger& deferred_logger) const;
102 
104  bool updateProductionGroupControl(const Group& group,
105  const int max_number_of_group_switch,
106  const bool update_group_switching_log,
107  std::map<std::string, std::vector<Group::ProductionCMode>>& switched_prod,
108  std::map<std::string, std::pair<std::string, std::string>>& closed_offending_wells,
109  GroupState<Scalar>& group_state,
110  WellState<Scalar, IndexTraits>& well_state,
111  DeferredLogger& deferred_logger) const;
112 
113  const GroupStateHelperType& groupStateHelper() const { return wellModel_.groupStateHelper(); }
114  const BlackoilWellModelGeneric<Scalar, IndexTraits>& wellModel_;
115 };
116 
117 } // namespace Opm
118 
119 #endif
Definition: BlackoilWellModelConstraints.hpp:34
Class for handling constraints for the blackoil well model.
Definition: BlackoilWellModelConstraints.hpp:41
Structs needed for tpfalinearizer and its gpuparams struct extracted to be defined in one place that ...
Definition: blackoilbioeffectsmodules.hh:45
Definition: BlackoilWellModelConstraints.hpp:37
Definition: DeferredLogger.hpp:56
BlackoilWellModelConstraints(const BlackoilWellModelGeneric< Scalar, IndexTraits > &wellModel)
Constructor initializes reference to the well model.
Definition: BlackoilWellModelConstraints.hpp:51
void actionOnBrokenConstraints(const Group &group, const Group::InjectionCMode &newControl, const Phase &controlPhase, GroupState< Scalar > &group_state, DeferredLogger &deferred_logger) const
Execute action for broken constraint for an injection well group.
Definition: BlackoilWellModelConstraints.cpp:258
bool updateGroupIndividualControl(const Group &group, const int reportStepIdx, const int max_number_of_group_switch, const bool update_group_switching_log, std::map< std::string, std::array< std::vector< Group::InjectionCMode >, 3 >> &switched_inj, std::map< std::string, std::vector< Group::ProductionCMode >> &switched_prod, std::map< std::string, std::pair< std::string, std::string >> &closed_offending_wells, GroupState< Scalar > &group_state, WellState< Scalar, IndexTraits > &well_state, DeferredLogger &deferred_logger) const
Update the individual controls for wells in a group. Return true if a group control is changed...
Definition: BlackoilWellModelConstraints.cpp:514
The state of a set of wells, tailored for use by the fully implicit blackoil simulator.
Definition: TemperatureModel.hpp:65