opm-common
EzrokhiTable.hpp
1 /*
2  Copyright (C) 2024 Norce
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_PARSER_EZROKHI_TABLE_HPP
20 #define OPM_PARSER_EZROKHI_TABLE_HPP
21 
22 #include <cstddef>
23 #include <unordered_map>
24 #include <string>
25 
26 namespace Opm {
27 class DeckRecord;
28 
29 struct EzrokhiRecord {
30  double c0{};
31  double c1{};
32  double c2{};
33 
34  EzrokhiRecord() = default;
35  EzrokhiRecord(double c0_in, double c1_in, double c2_in) :
36  c0(c0_in),
37  c1(c1_in),
38  c2(c2_in)
39  {};
40 
41  bool operator==(const EzrokhiRecord& other) const {
42  return this->c0 == other.c0 &&
43  this->c1 == other.c1 &&
44  this->c2 == other.c2;
45  }
46 
47  template<class Serializer>
48  void serializeOp(Serializer& serializer)
49  {
50  serializer(c0);
51  serializer(c1);
52  serializer(c2);
53  }
54 
55 };
56 
57 class EzrokhiTable {
58 public:
59  EzrokhiTable() = default;
60  explicit EzrokhiTable(const std::unordered_map<std::string, EzrokhiRecord>& records);
61 
62  static EzrokhiTable serializationTestObject();
63 
64  void init(const DeckRecord& record, const std::string& cname, const int icomp);
65  std::size_t size() const;
66  bool empty() const;
67  std::unordered_map<std::string, EzrokhiRecord>::const_iterator begin() const;
68  std::unordered_map<std::string, EzrokhiRecord>::const_iterator end() const;
69  const EzrokhiRecord& operator[](const std::string& name) const;
70 
71  double getC0(const std::string& name) const;
72  double getC1(const std::string& name) const;
73  double getC2(const std::string& name) const;
74 
75  bool operator==(const EzrokhiTable& other) const {
76  return this->data == other.data;
77  }
78 
79  template<class Serializer>
80  void serializeOp(Serializer& serializer)
81  {
82  serializer(data);
83  }
84 
85 private:
86  std::unordered_map<std::string, EzrokhiRecord> data;
87 };
88 
89 } // namespace Opm
90 
91 #endif
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: EzrokhiTable.hpp:57
Definition: DeckRecord.hpp:32
Definition: EzrokhiTable.hpp:29
Class for (de-)serializing.
Definition: Serializer.hpp:94