opm-common
SimulatorUpdate.hpp
1 /*
2  Copyright 2021 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 SIMULATOR_UPDATE_HPP
21 #define SIMULATOR_UPDATE_HPP
22 
23 #include <string>
24 #include <unordered_set>
25 
26 namespace Opm {
27 
31 
33 {
34  static SimulatorUpdate serializationTestObject()
35  {
36  SimulatorUpdate simulatorUpdate;
37  simulatorUpdate.tran_update = true;
38  simulatorUpdate.well_structure_changed = true;
39  simulatorUpdate.affected_wells = {"test"};
40  simulatorUpdate.welpi_wells.insert("I-45");
41  return simulatorUpdate;
42  }
43 
44  template<class Serializer>
45  void serializeOp(Serializer& serializer)
46  {
47  serializer(affected_wells);
48  serializer(welpi_wells);
49  serializer(tran_update);
50  serializer(well_structure_changed);
51  }
52 
55  std::unordered_set<std::string> affected_wells{};
56 
59  std::unordered_set<std::string> welpi_wells{};
60 
65  bool tran_update{false};
66 
73 
75  enum class DelayedIteration {
76  Off,
77  Possible,
78  On,
79  };
80 
84 
85  void append(const SimulatorUpdate& otherSimUpdate)
86  {
87  this->tran_update = this->tran_update || otherSimUpdate.tran_update;
88 
90  || otherSimUpdate.well_structure_changed;
91 
92  this->affected_wells.insert(otherSimUpdate.affected_wells.begin(),
93  otherSimUpdate.affected_wells.end());
94 
95  this->welpi_wells.insert(otherSimUpdate.welpi_wells.begin(),
96  otherSimUpdate.welpi_wells.end());
97  }
98 
99  void reset()
100  {
102  this->tran_update = false;
103  this->well_structure_changed = false;
104  this->affected_wells.clear();
105  this->welpi_wells.clear();
106  }
107 
108  bool operator==(const SimulatorUpdate& that) const
109  {
110  return (this->tran_update == that.tran_update)
111  && (this->well_structure_changed == that.well_structure_changed)
112  && (this->affected_wells == that.affected_wells)
113  && (this->welpi_wells == that.welpi_wells)
114  ;
115  }
116 };
117 
118 } // namespace Opm
119 
120 #endif // SIMULATOR_UPDATE_HPP
This struct is used to communicate back from the Schedule::applyAction() what needs to be updated in ...
Definition: SimulatorUpdate.hpp:32
Force delayed iteration off.
DelayedIteration
Enumeration of how to handled delayed schedule iteration.
Definition: SimulatorUpdate.hpp:75
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
DelayedIteration delayed_iteration
Whether or not to do schedule iteration after update has been applied.
Definition: SimulatorUpdate.hpp:83
bool tran_update
Whether or not a transmissibility multiplier keyword was invoked in an ACTIONX block.
Definition: SimulatorUpdate.hpp:65
bool well_structure_changed
Whether or not well structure changed in processing an ACTIONX block.
Definition: SimulatorUpdate.hpp:72
std::unordered_set< std::string > welpi_wells
Wells affected only by WELPI for which the simulator needs to update its internal notion of the conne...
Definition: SimulatorUpdate.hpp:59
std::unordered_set< std::string > affected_wells
Wells affected by ACTIONX and for which the simulator needs to reapply rates and state from the newly...
Definition: SimulatorUpdate.hpp:55
Class for (de-)serializing.
Definition: Serializer.hpp:94