opm-common
Source.hpp
1 /*
2  Copyright 2023 Equinor ASA.
3  Copyright 2023 Norce.
4 
5  This file is part of the Open Porous Media project (OPM).
6 
7  OPM is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  OPM is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with OPM. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef OPM_SOURCE_PROP_HPP
22 #define OPM_SOURCE_PROP_HPP
23 
24 #include <array>
25 #include <vector>
26 #include <cstddef>
27 #include <optional>
28 #include <map>
29 
30 namespace Opm {
31 
32 class Deck;
33 class DeckRecord;
34 
35 enum class SourceComponent {
36  OIL,
37  GAS,
38  WATER,
39  SOLVENT,
40  POLYMER,
41  MICR,
42  OXYG,
43  UREA,
44  NONE
45 };
46 
47 class Source
48 {
49 public:
50  struct SourceCell
51  {
52  SourceComponent component{SourceComponent::NONE};
53  double rate{};
54  std::optional<double> hrate{};
55  std::optional<double> temperature{};
56 
57  SourceCell() = default;
58  explicit SourceCell(const DeckRecord& record);
59 
60  static SourceCell serializationTestObject();
61 
62  bool operator==(const SourceCell& other) const;
63 
64  template<class Serializer>
65  void serializeOp(Serializer& serializer)
66  {
67  serializer(component);
68  serializer(rate);
69  serializer(hrate);
70  serializer(temperature);
71  }
72  };
73 
74  Source() = default;
75 
76  static Source serializationTestObject();
77 
78  auto size() const { return this->m_cells.size(); }
79  auto begin() const { return this->m_cells.begin(); }
80  auto end() const { return this->m_cells.end(); }
81  bool operator==(const Source& other) const;
82 
83  double rate(const std::array<int, 3>& ijk, SourceComponent input ) const;
84  std::optional<double> hrate(const std::array<int, 3>& ijk, SourceComponent input ) const;
85  std::optional<double> temperature(const std::array<int, 3>& ijk, SourceComponent input) const;
86  bool hasSource(const std::array<int, 3>& input) const;
87 
88  void updateSource(const DeckRecord& record);
89  void addSourceCell(const std::array<int,3>& ijk, const SourceCell& cell);
90 
91  template<class Serializer>
92  void serializeOp(Serializer& serializer)
93  {
94  serializer(m_cells);
95  }
96 
97 private:
98  std::map<std::array<int, 3>, std::vector<SourceCell>> m_cells;
99 };
100 
101 } // namespace Opm
102 
103 #endif
Definition: Source.hpp:50
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: Source.hpp:47
Definition: DeckRecord.hpp:32
Class for (de-)serializing.
Definition: Serializer.hpp:94