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 RESERVOIR_COUPLING_SLAVES_HPP
20#define RESERVOIR_COUPLING_SLAVES_HPP
21
22#include <opm/io/eclipse/rst/group.hpp>
23#include <opm/io/eclipse/rst/well.hpp>
24
25#include <map>
26#include <string>
27
28namespace Opm::ReservoirCoupling {
29
31{
32public:
33 MasterGroup() = default;
34
35 explicit MasterGroup(const std::string& name, const std::string& slave_name, const std::string& slave_group_name, double flow_limit_fraction) :
36 m_name{name},
37 m_slave_name{slave_name},
38 m_slave_group_name{slave_group_name},
39 m_flow_limit_fraction{flow_limit_fraction}
40 {}
41 static MasterGroup serializationTestObject();
42
43 const std::string name() const {
44 return this->m_name;
45 }
46 const std::string slaveName() const {
47 return this->m_slave_name;
48 }
49 const std::string slaveGroupName() const {
50 return this->m_slave_group_name;
51 }
52 double flowLimitFraction() const {
53 return this->m_flow_limit_fraction;
54 }
55 void name(const std::string& value) {
56 this->m_name = value;
57 }
58 void slaveName(const std::string& value) {
59 this->m_slave_name = value;
60 }
61 void slaveGroupName(const std::string& value) {
62 this->m_slave_group_name = value;
63 }
64 void flowLimitFraction(double value) {
65 this->m_flow_limit_fraction = value;
66 }
67 bool operator==(const MasterGroup& other) const;
68
69 template<class Serializer>
70 void serializeOp(Serializer& serializer)
71 {
72 serializer(m_name);
73 serializer(m_slave_name);
74 serializer(m_slave_group_name);
75 serializer(m_flow_limit_fraction);
76 }
77
78private:
79 std::string m_name{};
80 std::string m_slave_name{};
81 std::string m_slave_group_name{};
82 double m_flow_limit_fraction{};
83};
84
85class Slave {
86public:
87 Slave() = default;
88
89 explicit Slave(const std::string& name, const std::string& data_filename, const std::string& directory_path, unsigned int numprocs) :
90 m_name{name},
91 m_data_filename{data_filename},
92 m_directory_path{directory_path},
93 m_numprocs{numprocs}
94 {}
95 static Slave serializationTestObject();
96
97 const std::string& name() const {
98 return this->m_name;
99 }
100 const std::string& dataFilename() const {
101 return this->m_data_filename;
102 }
103 const std::string& directoryPath() const {
104 return this->m_directory_path;
105 }
106 unsigned int numprocs() const {
107 return this->m_numprocs;
108 }
109
110 void name(const std::string& value) {
111 this->m_name = value;
112 }
113 void dataFilename(const std::string& value) {
114 this->m_data_filename = value;
115 }
116 void directoryPath(const std::string& value) {
117 this->m_directory_path = value;
118 }
119 void numprocs(unsigned int value) {
120 this->m_numprocs = value;
121 }
122 bool operator==(const Slave& other) const;
123
124 template<class Serializer>
125 void serializeOp(Serializer& serializer)
126 {
127 serializer(m_name);
128 serializer(m_data_filename);
129 serializer(m_directory_path);
130 serializer(m_numprocs);
131 }
132private:
133 std::string m_name{};
134 std::string m_data_filename{};
135 std::string m_directory_path{};
136 unsigned int m_numprocs{};
137};
138
140public:
141 CouplingInfo() = default;
142
143 static CouplingInfo serializationTestObject();
144 std::map<std::string, Slave>& slaves() {
145 return this->m_slaves;
146 }
147 std::map<std::string, MasterGroup>& masterGroups() {
148 return this->m_master_groups;
149 }
150 bool operator==(const CouplingInfo& other) const;
151 bool hasSlave(const std::string& name) const {
152 return m_slaves.find(name) != m_slaves.end();
153 }
154 const Slave& slave(const std::string& name) const {
155 return m_slaves.at(name);
156 }
157 bool hasMasterGroup(const std::string& name) const {
158 return m_master_groups.find(name) != m_master_groups.end();
159 }
160 const MasterGroup& masterGroup(const std::string& name) const {
161 return m_master_groups.at(name);
162 }
163 template<class Serializer>
164 void serializeOp(Serializer& serializer)
165 {
166 serializer(m_slaves);
167 serializer(m_master_groups);
168 }
169private:
170 std::map<std::string, Slave> m_slaves;
171 std::map<std::string, MasterGroup> m_master_groups;
172};
173
174} // namespace Opm::ReservoirCoupling
175
176#endif
Definition ReservoirCouplingInfo.hpp:139
Definition ReservoirCouplingInfo.hpp:31
Definition ReservoirCouplingInfo.hpp:85
Class for (de-)serializing.
Definition Serializer.hpp:91