opm-common
WListManager.hpp
1 /*
2  Copyright 2019 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 #ifndef WLISTMANAGER_HPP
20 #define WLISTMANAGER_HPP
21 
22 #include <opm/input/eclipse/Schedule/Well/WList.hpp>
23 
24 #include <cstddef>
25 #include <map>
26 #include <string>
27 #include <vector>
28 
29 namespace Opm::RestartIO {
30  struct RstState;
31 } // namespace Opm::RestartIO
32 
33 namespace Opm {
34 
41 {
42 public:
44  WListManager() = default;
45 
51  explicit WListManager(const RestartIO::RstState& rst_state);
52 
55 
57  std::size_t WListSize() const;
58 
69  bool hasWell(const std::string& pattern) const;
70 
77  bool hasList(const std::string& wlistName) const;
78 
90  WList& getList(const std::string& name);
91 
103  const WList& getList(const std::string& name) const;
104 
114  WList& newList(const std::string& name,
115  const std::vector<std::string>& wname);
116 
120  auto begin() const { return this->wlists.begin(); }
121 
123  auto end() const { return this->wlists.end(); }
124 
130  const std::vector<std::string>&
131  getWListNames(const std::string& wname) const;
132 
138  std::size_t getNoWListsWell(const std::string& wname) const;
139 
145  bool hasWList(const std::string& wname) const;
146 
154  void addWListWell(const std::string& wname, const std::string& wlname);
155 
165  void addOrCreateWellList(const std::string& wlname,
166  const std::vector<std::string>& wnames);
167 
177  bool delWell(const std::string& wname);
178 
186  bool delWListWell(const std::string& wname, const std::string& wlname);
187 
194  bool operator==(const WListManager& data) const;
195 
206  std::vector<std::string> wells(const std::string& wlist_pattern) const;
207 
213  template<class Serializer>
214  void serializeOp(Serializer& serializer)
215  {
216  serializer(wlists);
217  serializer(well_wlist_names);
218  serializer(no_wlists_well);
219  }
220 
221 private:
225  std::map<std::string, WList> wlists;
226 
230  std::map<std::string, std::vector<std::string>> well_wlist_names;
231 
235  std::map<std::string, std::size_t> no_wlists_well;
236 
248  void resetExistingWList(const std::string& wlistName,
249  const std::vector<std::string>& newWells);
250 
257  void clearExistingWList(const std::string& wlistName);
258 
268  void createNewWList(const std::string& wlistName,
269  const std::vector<std::string>& newWells);
270 };
271 
272 } // namespace Opm
273 
274 #endif // WLISTMANAGER_HPP
Definition: state.hpp:56
std::vector< std::string > wells(const std::string &wlist_pattern) const
All wells on all well lists matching a name pattern.
Definition: WListManager.cpp:207
Collection of run&#39;s known well lists.
Definition: WListManager.hpp:40
auto end() const
End of sequence of run&#39;s current well lists.
Definition: WListManager.hpp:123
bool hasList(const std::string &wlistName) const
Predicate for existence of particular well lists.
Definition: WListManager.cpp:67
Named sequence of wells.
Definition: WList.hpp:31
bool delWell(const std::string &wname)
Remove named well from all existing well lists.
Definition: WListManager.cpp:151
std::size_t getNoWListsWell(const std::string &wname) const
Number of well lists containing named well.
Definition: WListManager.cpp:112
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
static WListManager serializationTestObject()
Create a serialisation test object.
Definition: WListManager.cpp:38
WList & newList(const std::string &name, const std::vector< std::string > &wname)
Create a new well list with initial sequence of wells.
Definition: WListManager.cpp:72
bool operator==(const WListManager &data) const
Equality predicate.
Definition: WListManager.cpp:201
auto begin() const
Start of sequence of run&#39;s current well lists.
Definition: WListManager.hpp:120
bool delWListWell(const std::string &wname, const std::string &wlname)
Remove named well from specific, named well list.
Definition: WListManager.cpp:177
WList & getList(const std::string &name)
Access individual well list by name.
Definition: WListManager.cpp:90
WListManager()=default
Default constructor.
const std::vector< std::string > & getWListNames(const std::string &wname) const
Sequence of well lists containing named well.
Definition: WListManager.cpp:101
void addWListWell(const std::string &wname, const std::string &wlname)
Add named well to named well list.
Definition: WListManager.cpp:117
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition: WListManager.hpp:214
void addOrCreateWellList(const std::string &wlname, const std::vector< std::string > &wnames)
Add sequence of wells to a named well list.
Definition: WListManager.cpp:140
bool hasWell(const std::string &pattern) const
Whether or not one or more wells matching a well list name or well list template exists.
Definition: WListManager.cpp:57
std::size_t WListSize() const
Number of well lists in current collection.
Definition: WListManager.cpp:52
bool hasWList(const std::string &wname) const
Whether or not named well is on any current well list.
Definition: WListManager.cpp:106
Definition: Aquancon.hpp:40
Class for (de-)serializing.
Definition: Serializer.hpp:94