My Project
Loading...
Searching...
No Matches
NameOrder.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#ifndef WELL_ORDER_HPP
20#define WELL_ORDER_HPP
21
22#include <cstddef>
23#include <initializer_list>
24#include <optional>
25#include <string>
26#include <unordered_map>
27#include <vector>
28
29namespace Opm {
30
31// The purpose of this small class is to ensure that well and group name
32// always come in the order they are defined in the deck.
33
35{
36public:
37 NameOrder() = default;
38 explicit NameOrder(std::initializer_list<std::string> names);
39 explicit NameOrder(const std::vector<std::string>& names);
40
41 void add(const std::string& name);
42 std::vector<std::string> sort(std::vector<std::string> names) const;
43 const std::vector<std::string>& names() const;
44 bool has(const std::string& wname) const;
45 std::size_t size() const;
46
47 template <class Serializer>
48 void serializeOp(Serializer& serializer)
49 {
50 serializer(m_index_map);
51 serializer(m_name_list);
52 }
53
54 static NameOrder serializationTestObject();
55
56 const std::string& operator[](std::size_t index) const;
57 bool operator==(const NameOrder& other) const;
58 std::vector<std::string>::const_iterator begin() const;
59 std::vector<std::string>::const_iterator end() const;
60
61private:
62 std::unordered_map<std::string, std::size_t> m_index_map;
63 std::vector<std::string> m_name_list;
64};
65
67{
68public:
69 GroupOrder() = default;
70 explicit GroupOrder(std::size_t max_groups);
71
72 void add(const std::string& name);
73 const std::vector<std::string>& names() const;
74 bool has(const std::string& wname) const;
75 std::vector<std::optional<std::string>> restart_groups() const;
76
77 template <class Serializer>
78 void serializeOp(Serializer& serializer)
79 {
80 serializer(m_name_list);
81 serializer(m_max_groups);
82 }
83
84 static GroupOrder serializationTestObject();
85
86 bool operator==(const GroupOrder& other) const;
87 std::vector<std::string>::const_iterator begin() const;
88 std::vector<std::string>::const_iterator end() const;
89
90private:
91 std::vector<std::string> m_name_list;
92 std::size_t m_max_groups;
93};
94
95} // namespace Opm
96
97#endif // WELL_ORDER_HPP
Definition NameOrder.hpp:67
Definition NameOrder.hpp:35
Class for (de-)serializing.
Definition Serializer.hpp:84
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30