My Project
Loading...
Searching...
No Matches
ReservoirCouplingInfo.hpp
1/*
2 Copyright 2024 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 OPM_RESERVOIR_COUPLING_INFO_HPP
20#define OPM_RESERVOIR_COUPLING_INFO_HPP
21
22#include <opm/input/eclipse/Deck/DeckKeyword.hpp>
23#include <opm/input/eclipse/Schedule/ResCoup/Slaves.hpp>
24#include <opm/input/eclipse/Schedule/ResCoup/GrupSlav.hpp>
25#include <opm/input/eclipse/Schedule/ResCoup/MasterGroup.hpp>
26#include <opm/io/eclipse/rst/group.hpp>
27#include <opm/io/eclipse/rst/well.hpp>
28
29#include <map>
30#include <string>
31
32namespace Opm::ReservoirCoupling {
33
35public:
36 enum class CouplingFileFlag {
37 NONE,
38 FORMATTED,
39 UNFORMATTED
40 };
41
42 CouplingInfo() = default;
43
44 static CouplingInfo serializationTestObject();
45 bool operator==(const CouplingInfo& other) const;
46
47
48 const GrupSlav& grupSlav(const std::string& name) const {
49 return m_grup_slavs.at(name);
50 }
51 const std::map<std::string, GrupSlav>& grupSlavs() const {
52 return this->m_grup_slavs;
53 }
54 std::map<std::string, GrupSlav>& grupSlavs() {
55 return this->m_grup_slavs;
56 }
57 int grupSlavCount() const {
58 return this->m_grup_slavs.size();
59 }
60
61 bool hasGrupSlav(const std::string& name) const {
62 return m_grup_slavs.find(name) != m_grup_slavs.end();
63 }
64
65 bool hasMasterGroup(const std::string& name) const {
66 return m_master_groups.find(name) != m_master_groups.end();
67 }
68 bool hasSlave(const std::string& name) const {
69 return m_slaves.find(name) != m_slaves.end();
70 }
71
72 const std::map<std::string, MasterGroup>& masterGroups() const {
73 return this->m_master_groups;
74 }
75 std::map<std::string, MasterGroup>& masterGroups() {
76 return this->m_master_groups;
77 }
78 const MasterGroup& masterGroup(const std::string& name) const {
79 return m_master_groups.at(name);
80 }
81
82 int masterGroupCount() const {
83 return m_master_groups.size();
84 }
85
86 double masterMinTimeStep() const {
87 return m_master_min_time_step;
88 }
89
90 CouplingFileFlag readCouplingFileFlag() const {
91 return m_read_coupling_file_flag;
92 }
93
94 const std::string& readCouplingFileName() const {
95 return m_read_coupling_file_name;
96 }
97
98 void setMasterMinTimeStep(double tstep) {
99 m_master_min_time_step = tstep;
100 }
101
102 void setReadCouplingFileFlag(CouplingFileFlag flag) {
103 m_read_coupling_file_flag = flag;
104 }
105
106 void setReadCouplingFileName(const std::string& file_name) {
107 m_read_coupling_file_name = file_name;
108 }
109
110 void setWriteCouplingFileFlag(CouplingFileFlag flag) {
111 m_write_coupling_file_flag = flag;
112 }
113
114 const std::map<std::string, Slave>& slaves() const {
115 return this->m_slaves;
116 }
117 std::map<std::string, Slave>& slaves() {
118 return this->m_slaves;
119 }
120 const Slave& slave(const std::string& name) const {
121 return m_slaves.at(name);
122 }
123 int slaveCount() const {
124 return m_slaves.size();
125 }
126
127
128
129 template<class Serializer>
130 void serializeOp(Serializer& serializer)
131 {
132 serializer(m_slaves);
133 serializer(m_master_groups);
134 serializer(m_grup_slavs);
135 serializer(m_master_min_time_step);
136 serializer(m_write_coupling_file_flag);
137 serializer(m_read_coupling_file_flag);
138 serializer(m_read_coupling_file_name);
139 }
140
141 CouplingFileFlag writeCouplingFileFlag() const {
142 return m_write_coupling_file_flag;
143 }
144
145
146 // Non-inline methods (defined in CouplingInfo.cpp)
147
148 static CouplingFileFlag couplingFileFlagFromString(
149 const std::string& flag_str, const DeckKeyword& keyword);
150
151private:
152 std::map<std::string, Slave> m_slaves;
153 std::map<std::string, MasterGroup> m_master_groups;
154 std::map<std::string, GrupSlav> m_grup_slavs;
155 double m_master_min_time_step{0.0};
156 CouplingFileFlag m_write_coupling_file_flag{CouplingFileFlag::NONE};
157 CouplingFileFlag m_read_coupling_file_flag{CouplingFileFlag::NONE};
158 std::string m_read_coupling_file_name{};
159};
160
161} // namespace Opm::ReservoirCoupling
162
163#endif // OPM_RESERVOIR_COUPLING_INFO_HPP
Definition DeckKeyword.hpp:36
Definition ReservoirCouplingInfo.hpp:34
Definition GrupSlav.hpp:32
Definition MasterGroup.hpp:32
Definition Slaves.hpp:30
Class for (de-)serializing.
Definition Serializer.hpp:94