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 <cstddef>
24 #include <string>
25 #include <unordered_set>
26 #include <utility>
27 #include <vector>
28 
29 namespace Opm {
30 
34 
36 {
37  static SimulatorUpdate serializationTestObject()
38  {
39  using namespace std::string_literals;
40 
41  SimulatorUpdate simulatorUpdate;
42 
43  simulatorUpdate.tran_update = true;
44  simulatorUpdate.well_structure_changed = true;
45  simulatorUpdate.affected_wells = {"test"};
46  simulatorUpdate.welpi_wells.insert("I-45");
47  simulatorUpdate.new_frac_wconns.assign({
48  std::pair { "I-45"s, std::vector { std::size_t{11}, std::size_t{22}, std::size_t{33} } },
49  std::pair { "RA-MAN"s, std::vector { std::size_t{1}, std::size_t{7}, std::size_t{29} } },
50  });
51 
52  return simulatorUpdate;
53  }
54 
55  template<class Serializer>
56  void serializeOp(Serializer& serializer)
57  {
58  serializer(affected_wells);
59  serializer(welpi_wells);
60  serializer(new_frac_wconns);
61  serializer(tran_update);
62  serializer(well_structure_changed);
63  }
64 
67  std::unordered_set<std::string> affected_wells{};
68 
71  std::unordered_set<std::string> welpi_wells{};
72 
80  std::vector<std::pair<std::string, std::vector<std::size_t>>> new_frac_wconns{};
81 
86  bool tran_update{false};
87 
94 
96  enum class DelayedIteration {
97  Off,
98  Possible,
99  On,
100  };
101 
105 
106  void append(const SimulatorUpdate& otherSimUpdate)
107  {
108  this->tran_update = this->tran_update || otherSimUpdate.tran_update;
109 
111  || otherSimUpdate.well_structure_changed;
112 
113  this->affected_wells.insert(otherSimUpdate.affected_wells.begin(),
114  otherSimUpdate.affected_wells.end());
115 
116  this->welpi_wells.insert(otherSimUpdate.welpi_wells.begin(),
117  otherSimUpdate.welpi_wells.end());
118 
119  this->new_frac_wconns.insert(this->new_frac_wconns.end(),
120  otherSimUpdate.new_frac_wconns.begin(),
121  otherSimUpdate.new_frac_wconns.end());
122  }
123 
124  void reset()
125  {
127  this->tran_update = false;
128  this->well_structure_changed = false;
129  this->affected_wells.clear();
130  this->welpi_wells.clear();
131  this->new_frac_wconns.clear();
132  }
133 
134  bool operator==(const SimulatorUpdate& that) const
135  {
136  return (this->tran_update == that.tran_update)
137  && (this->well_structure_changed == that.well_structure_changed)
138  && (this->affected_wells == that.affected_wells)
139  && (this->welpi_wells == that.welpi_wells)
140  && (this->new_frac_wconns == that.new_frac_wconns)
141  ;
142  }
143 };
144 
145 } // namespace Opm
146 
147 #endif // SIMULATOR_UPDATE_HPP
This struct is used to communicate back from the Schedule::applyAction() what needs to be updated in ...
Definition: SimulatorUpdate.hpp:35
Force delayed iteration off.
DelayedIteration
Enumeration of how to handled delayed schedule iteration.
Definition: SimulatorUpdate.hpp:96
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:104
bool tran_update
Whether or not a transmissibility multiplier keyword was invoked in an ACTIONX block.
Definition: SimulatorUpdate.hpp:86
bool well_structure_changed
Whether or not well structure changed in processing an ACTIONX block.
Definition: SimulatorUpdate.hpp:93
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:71
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:67
std::vector< std::pair< std::string, std::vector< std::size_t > > > new_frac_wconns
New well connections created as a result of a geomechanical fracturing process.
Definition: SimulatorUpdate.hpp:80
Class for (de-)serializing.
Definition: Serializer.hpp:95