opm-common
Toggle main menu visibility
Loading...
Searching...
No Matches
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 <unordered_map>
24
#include <vector>
25
26
namespace
Opm
27
{
28
29
namespace
Fieldprops
30
{
31
32
namespace
keywords {
template
<
class
T>
struct
keyword_info
; }
33
34
enum class
ScalarOperation {
35
ADD = 1,
36
EQUAL = 2,
37
MUL = 3,
38
MIN = 4,
39
MAX = 5
40
};
41
42
43
class
TranCalculator {
44
public
:
45
46
struct
TranAction
{
47
ScalarOperation op;
48
std::string field;
49
50
bool
operator==(
const
TranAction
& other)
const
{
51
return
this->op == other.op &&
52
this->field == other.field;
53
}
54
55
template
<
class
Serializer>
56
void
serializeOp(
Serializer
& serializer)
57
{
58
serializer(op);
59
serializer(field);
60
}
61
};
62
63
64
explicit
TranCalculator(
const
std::string& name_arg) :
65
m_name(name_arg)
66
{}
67
68
TranCalculator
() =
default
;
69
70
std::string next_name()
const
{
71
return
this->m_name + std::to_string( this->actions.size() );
72
}
73
74
std::vector<TranAction>::const_iterator begin()
const
{
75
return
this->actions.begin();
76
}
77
78
std::vector<TranAction>::const_iterator end()
const
{
79
return
this->actions.end();
80
}
81
82
void
add_action(ScalarOperation op,
const
std::string& field) {
83
this->actions.push_back(
TranAction
{op, field});
84
}
85
86
std::size_t size()
const
{
87
return
this->actions.size();
88
}
89
90
const
std::string& name()
const
{
91
return
this->m_name;
92
}
93
94
keywords::keyword_info<double> make_kw_info(ScalarOperation op,
95
const
std::string& target_kw);
96
97
bool
operator==(
const
TranCalculator& other)
const
{
98
return
this->m_name == other.m_name &&
99
this->actions == other.actions;
100
}
101
102
template
<
class
Serializer>
103
void
serializeOp(Serializer& serializer)
104
{
105
serializer(m_name);
106
serializer(actions);
107
}
108
109
static
TranCalculator serializationTestObject()
110
{
111
TranCalculator tran(
"test"
);
112
tran.add_action(ScalarOperation::MIN,
"FGOP"
);
113
return
tran;
114
}
115
116
private
:
117
std::string m_name;
118
std::vector<TranAction> actions;
119
};
120
121
}
// namespace Fieldprops
122
}
// end namespace Opm
123
#endif
// TRAN_CALCULATOR_HPP
Opm::Fieldprops::TranCalculator
Definition
TranCalculator.hpp:43
Opm::Serializer
Class for (de-)serializing.
Definition
Serializer.hpp:94
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition
Exceptions.hpp:30
Opm::Fieldprops::TranCalculator::TranAction
Definition
TranCalculator.hpp:46
Opm::Fieldprops::keywords::keyword_info
Definition
Keywords.hpp:31
opm
input
eclipse
EclipseState
Grid
TranCalculator.hpp
Generated by
1.17.0