opm-common
WList.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 WLIST_HPP
20 #define WLIST_HPP
21 
22 #include <cstddef>
23 #include <string>
24 #include <vector>
25 
27 
28 namespace Opm {
29 
31 class WList
32 {
33 public:
39  WList() = default;
40 
46  WList(const std::vector<std::string>& wlist, const std::string& wlname);
47 
49  std::size_t size() const;
50 
52  bool empty() const { return this->size() == 0; }
53 
55  void clear();
56 
62  void add(const std::string& well);
63 
69  void del(const std::string& well);
70 
76  bool has(const std::string& well) const;
77 
81  const std::string& getName() const { return this->name; }
82 
84  const std::vector<std::string>& wells() const;
85 
92  bool operator==(const WList& data) const;
93 
100  bool operator!=(const WList& that) const
101  {
102  return ! (*this == that);
103  }
104 
110  template<class Serializer>
111  void serializeOp(Serializer& serializer)
112  {
113  serializer(well_list);
114  serializer(name);
115  }
116 
117 private:
119  std::vector<std::string> well_list;
120 
122  std::string name;
123 };
124 
125 } // namespace Opm
126 
127 #endif // WLIST_HPP
bool operator==(const WList &data) const
Equality predicate.
Definition: WList.cpp:64
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition: WList.hpp:111
Named sequence of wells.
Definition: WList.hpp:31
bool empty() const
Predicate for an empty well list.
Definition: WList.hpp:52
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
const std::string & getName() const
Retrieve name of current well list.
Definition: WList.hpp:81
void del(const std::string &well)
Remove named well from this well list.
Definition: WList.cpp:54
bool operator!=(const WList &that) const
Inequality predicate.
Definition: WList.hpp:100
void add(const std::string &well)
Add named well to this well list.
Definition: WList.cpp:46
const std::vector< std::string > & wells() const
Sequence of named wells on current well list.
Definition: WList.cpp:59
WList()=default
Default constructor.
void clear()
Remove all wells from this well list.
Definition: WList.cpp:36
std::size_t size() const
Number of wells in this well list.
Definition: WList.cpp:31
bool has(const std::string &well) const
Whether or not named well is on the current list.
Definition: WList.cpp:41
Class for (de-)serializing.
Definition: Serializer.hpp:94