UDQAssign.hpp
Go to the documentation of this file.
1/*
2 Copyright 2018 Statoil 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
21#ifndef UDQASSIGN_HPP_
22#define UDQASSIGN_HPP_
23
24#include <string>
25#include <vector>
26
29
30namespace Opm {
31
32
34public:
35
36 /*
37 If the same keyword is assigned several times the different assignment
38 records are assembled in one UDQAssign instance. This is an attempt to
39 support restart in a situation where a full UDQ ASSIGN statement can be
40 swapped with a UDQ DEFINE statement.
41 */
42 struct AssignRecord {
43 std::vector<std::string> selector;
44 double value;
45
46 bool operator==(const AssignRecord& data) const {
47 return selector == data.selector &&
48 value == data.value;
49 }
50
51 template<class Serializer>
52 void serializeOp(Serializer& serializer)
53 {
54 serializer(selector);
55 serializer(value);
56 }
57 };
58
60 UDQAssign(const std::string& keyword, const std::vector<std::string>& selector, double value);
61
63
64 const std::string& keyword() const;
66 void add_record(const std::vector<std::string>& selector, double value);
67 UDQSet eval(const std::vector<std::string>& wells) const;
68
69 bool operator==(const UDQAssign& data) const;
70
71 template<class Serializer>
72 void serializeOp(Serializer& serializer)
73 {
74 serializer(m_keyword);
75 serializer(m_var_type);
76 serializer.vector(records);
77 }
78
79private:
80 std::string m_keyword;
81 UDQVarType m_var_type;
82 std::vector<AssignRecord> records;
83};
84}
85
86
87
88#endif
const char *const string
Definition: cJSON.h:170
Definition: Serializer.hpp:38
Definition: UDQAssign.hpp:33
UDQAssign(const std::string &keyword, const std::vector< std::string > &selector, double value)
static UDQAssign serializeObject()
const std::string & keyword() const
UDQSet eval(const std::vector< std::string > &wells) const
void add_record(const std::vector< std::string > &selector, double value)
void serializeOp(Serializer &serializer)
Definition: UDQAssign.hpp:72
UDQVarType var_type() const
bool operator==(const UDQAssign &data) const
Definition: UDQSet.hpp:60
Definition: A.hpp:4
UDQVarType
Definition: UDQEnums.hpp:59
T value(details::expression_node< T > *n)
Definition: exprtk.hpp:12955
static std::string data()
Definition: exprtk.hpp:40022
Definition: UDQAssign.hpp:42
double value
Definition: UDQAssign.hpp:44
bool operator==(const AssignRecord &data) const
Definition: UDQAssign.hpp:46
void serializeOp(Serializer &serializer)
Definition: UDQAssign.hpp:52
std::vector< std::string > selector
Definition: UDQAssign.hpp:43