My Project
Loading...
Searching...
No Matches
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
29namespace Opm {
30
31class Deck;
32class DeckRecord;
33
34enum class SourceComponent {
35 OIL,
36 GAS,
37 WATER,
38 SOLVENT,
39 POLYMER,
40 NONE
41};
42
43class Source
44{
45public:
47 {
48 std::array<int, 3> ijk{};
49 SourceComponent component{SourceComponent::NONE};
50 double rate{};
51 std::optional<double> hrate{};
52 std::optional<double> temperature{};
53
54 SourceCell() = default;
55 explicit SourceCell(const DeckRecord& record);
56
57 static SourceCell serializationTestObject();
58
59 bool operator==(const SourceCell& other) const;
60 bool isSame(const SourceCell& other) const;
61 bool isSame(const std::pair<std::array<int, 3>, SourceComponent>& other) const;
62
63 template<class Serializer>
64 void serializeOp(Serializer& serializer)
65 {
66 serializer(ijk);
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 std::size_t size() const;
79 std::vector<SourceCell>::const_iterator begin() const;
80 std::vector<SourceCell>::const_iterator end() const;
81 bool operator==(const Source& other) const;
82
83 double rate(const std::pair<std::array<int, 3>, SourceComponent>& input ) const;
84 double hrate(const std::pair<std::array<int, 3>, SourceComponent>& input ) const;
85 double temperature(const std::pair<std::array<int, 3>, SourceComponent>& input) const;
86 bool hasHrate(const std::pair<std::array<int, 3>, SourceComponent>& input) const;
87 bool hasTemperature(const std::pair<std::array<int, 3>, SourceComponent>& input) const;
88 bool hasSource(const std::array<int, 3>& input) const;
89
90 void updateSource(const DeckRecord& record);
91
93 void addSourceCell(const SourceCell& cell)
94 {
95 m_cells.push_back(cell);
96 }
97
98 template<class Serializer>
99 void serializeOp(Serializer& serializer)
100 {
101 serializer(m_cells);
102 }
103
104private:
105 std::vector<SourceCell> m_cells;
106};
107
108} // namespace Opm
109
110#endif
Definition DeckRecord.hpp:32
Class for (de-)serializing.
Definition Serializer.hpp:94
Definition Source.hpp:44
void addSourceCell(const SourceCell &cell)
Add a source term for a grid cell.
Definition Source.hpp:93
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition Source.hpp:47