My Project
TranCalculator.hpp
1 /*
2  Copyright 2020 Equinor AS.
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 TRAN_CALCULATOR_HPP
20 #define TRAN_CALCULATOR_HPP
21 
22 #include <string>
23 #include <vector>
24 
25 namespace Opm
26 {
27 
28 namespace Fieldprops
29 {
30 
31 namespace keywords { template<class T> struct keyword_info; }
32 
33 enum class ScalarOperation {
34  ADD = 1,
35  EQUAL = 2,
36  MUL = 3,
37  MIN = 4,
38  MAX = 5
39 };
40 
41 
43 public:
44 
45  struct TranAction {
46  ScalarOperation op;
47  std::string field;
48 
49  bool operator==(const TranAction& other) const {
50  return this->op == other.op &&
51  this->field == other.field;
52  }
53  };
54 
55 
56  explicit TranCalculator(const std::string& name_arg) :
57  m_name(name_arg)
58  {}
59 
60  std::string next_name() const {
61  return this->m_name + std::to_string( this->actions.size() );
62  }
63 
64  std::vector<TranAction>::const_iterator begin() const {
65  return this->actions.begin();
66  }
67 
68  std::vector<TranAction>::const_iterator end() const {
69  return this->actions.end();
70  }
71 
72  void add_action(ScalarOperation op, const std::string& field) {
73  this->actions.push_back(TranAction{op, field});
74  }
75 
76  std::size_t size() const {
77  return this->actions.size();
78  }
79 
80  const std::string& name() const {
81  return this->m_name;
82  }
83 
84  keywords::keyword_info<double> make_kw_info(ScalarOperation op);
85 
86  bool operator==(const TranCalculator& other) const {
87  return this->m_name == other.m_name &&
88  this->actions == other.actions;
89  }
90 
91 private:
92  std::string m_name;
93  std::vector<TranAction> actions;
94 };
95 
96 } // namespace Fieldprops
97 } // end namespace Opm
98 #endif // TRAN_CALCULATOR_HPP
Definition: TranCalculator.hpp:42
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: TranCalculator.hpp:45