My Project
Condition.hpp
1 /*
2  Copyright 2019 Equinor ASA.
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 ACTIONX_CONDITION_HPP
21 #define ACTIONX_CONDITION_HPP
22 
23 #include <string>
24 #include <vector>
25 
26 #include <opm/common/OpmLog/KeywordLocation.hpp>
27 #include <opm/input/eclipse/Schedule/Action/Enums.hpp>
28 #include <opm/io/eclipse/rst/action.hpp>
29 
30 namespace Opm {
31 
32 namespace Action {
33 
34 
35 class Quantity {
36 public:
37  Quantity() = default;
38  explicit Quantity(const RestartIO::RstAction::Quantity& rst_quantity);
39  explicit Quantity(const std::string& arg);
40 
41  void add_arg(const std::string& arg);
42  std::string quantity;
43  std::vector<std::string> args;
44  bool date() const;
45  int int_type() const;
46 
47 
48  bool operator==(const Quantity& data) const {
49  return quantity == data.quantity &&
50  args == data.args;
51  }
52 
53  template<class Serializer>
54  void serializeOp(Serializer& serializer)
55  {
56  serializer(quantity);
57  serializer(args);
58  }
59 };
60 
61 
62 
63 class Condition {
64 public:
65 
66  Condition() = default;
67  explicit Condition(const RestartIO::RstAction::Condition& rst_condition);
68  Condition(const std::vector<std::string>& tokens, const KeywordLocation& location);
69 
70 
71  Quantity lhs;
72  Quantity rhs;
73  Logical logic = Logical::END;
74  Comparator cmp = Comparator::INVALID;
75  bool left_paren = false;
76  bool right_paren = false;
77 
78  std::string cmp_string;
79 
80  static Logical logic_from_int(int);
81  int logic_as_int() const;
82  int comparator_as_int() const;
83  int paren_as_int() const;
84  bool open_paren() const;
85  bool close_paren() const;
86  bool operator==(const Condition& data) const;
87 
88  template<class Serializer>
89  void serializeOp(Serializer& serializer)
90  {
91  serializer(lhs);
92  serializer(rhs);
93  serializer(logic);
94  serializer(cmp);
95  serializer(cmp_string);
96  serializer(left_paren);
97  serializer(right_paren);
98  }
99 };
100 
101 
102 }
103 }
104 
105 #endif
Definition: Condition.hpp:63
Definition: Condition.hpp:35
Definition: KeywordLocation.hpp:27
Class for (de-)serializing.
Definition: Serializer.hpp:75
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: action.hpp:47
Definition: action.hpp:36