opm-common
AquiferFlux.hpp
1 /*
2  Copyright (C) 2023 Equinor
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 
20 #ifndef OPM_AQUIFERFLUX_HPP
21 #define OPM_AQUIFERFLUX_HPP
22 
23 #include <cstddef>
24 #include <optional>
25 #include <unordered_map>
26 #include <unordered_set>
27 #include <vector>
28 
29 namespace Opm {
30  class DeckKeyword;
31  class DeckRecord;
32 }
33 
34 namespace Opm { namespace RestartIO {
35  class RstAquifer;
36 }} // Opm::RestartIO
37 
38 namespace Opm {
40  {
41  SingleAquiferFlux() = default;
42  explicit SingleAquiferFlux(const DeckRecord& record);
43 
44  // using id to create an inactive dummy aquifer
45  explicit SingleAquiferFlux(int id);
46  SingleAquiferFlux(int id, double flux, double sal, bool active_, double temp, double pres);
47 
48  int id {0};
49  double flux {0.};
50  double salt_concentration {0.};
51  bool active {false};
52  std::optional<double> temperature;
53  std::optional<double> datum_pressure;
54 
55  bool operator==(const SingleAquiferFlux& other) const;
56 
57  template <class Serializer>
58  void serializeOp(Serializer& serializer)
59  {
60  serializer(this->id);
61  serializer(this->flux);
62  serializer(this->salt_concentration);
63  serializer(this->active);
64  serializer(this->temperature);
65  serializer(this->datum_pressure);
66  }
67 
68  static SingleAquiferFlux serializationTestObject();
69  };
70 
72  {
73  public:
74  using AquFluxs = std::unordered_map<int, SingleAquiferFlux>;
75 
76  AquiferFlux() = default;
77  explicit AquiferFlux(const std::vector<const DeckKeyword*>& keywords);
78 
79  // Primarily for unit testing purposes.
80  explicit AquiferFlux(const std::vector<SingleAquiferFlux>& aquifers);
81 
82  void appendAqufluxSchedule(const std::unordered_set<int>& ids);
83 
84  bool hasAquifer(int id) const;
85 
86  bool operator==(const AquiferFlux& other) const;
87 
88  std::size_t size() const;
89 
90  AquFluxs::const_iterator begin() const;
91  AquFluxs::const_iterator end() const;
92 
93  void loadFromRestart(const RestartIO::RstAquifer& rst);
94 
95  template <class Serializer>
96  void serializeOp(Serializer& serializer)
97  {
98  serializer(this->m_aquifers);
99  }
100 
101  static AquiferFlux serializationTestObject();
102 
103  private:
104  AquFluxs m_aquifers{};
105  };
106 } // end of namespace Opm
107 
108 #endif //OPM_AQUIFERFLUX_HPP
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: AquiferFlux.hpp:39
Definition: aquifer.hpp:44
Definition: AquiferFlux.hpp:71
Definition: DeckRecord.hpp:33
Class for (de-)serializing.
Definition: Serializer.hpp:95