opm-common
Toggle main menu visibility
Loading...
Searching...
No Matches
UDAValue.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 UDA_VALUE_HPP
21
#define UDA_VALUE_HPP
22
23
#include <string>
24
#include <iosfwd>
25
#include <optional>
26
27
#include <opm/input/eclipse/Units/Dimension.hpp>
28
29
namespace
Opm
{
30
31
class
UDAValue {
32
public
:
33
UDAValue();
34
explicit
UDAValue(
double
);
35
explicit
UDAValue(
const
std::string&);
36
explicit
UDAValue(
const
Dimension
& dim);
37
UDAValue(
double
data,
const
Dimension
& dim);
38
UDAValue(
const
std::string& data,
const
Dimension
& dim);
39
40
/*
41
The assignment operators have been explicitly deleted, that is to prevent
42
people from adding them at a later stage. It seems very tempting/natural
43
to implement these assignment operators, but the problem is that the
44
resulting UDA object will typically have the wrong dimension member, and
45
subtle dimension related bugs will arise.
46
*/
47
UDAValue& operator=(
double
value) =
delete
;
48
UDAValue& operator=(
const
std::string& value) =
delete
;
49
void
update(
double
d);
50
void
update(
const
std::string& s);
51
void
update_value(
const
UDAValue& other);
52
53
static
UDAValue serializationTestObject();
54
55
/*
56
* The *_value_or functions will throw an exception in case of non-zero string value
57
*/
58
double
raw_value_or(
const
double
raw_default_value)
const
;
59
double
SI_value_or(
const
double
SI_default_value)
const
;
60
61
/*
62
The get<double>() and get<std::string>() methods will throw an
63
exception if the internal type and the template parameter disagree.
64
*/
65
66
template
<
typename
T>
67
T get()
const
;
68
69
/*
70
The getSI() can only be called for numerical values.
71
*/
72
double
getSI()
const
;
73
bool
zero()
const
;
74
75
//epsilon limit = 1.E-20 (~= 0.)
76
double
epsilonLimit()
const
;
77
78
bool
is_defined()
const
;
79
template
<
typename
T>
80
bool
is()
const
;
81
82
void
assert_numeric()
const
;
83
void
assert_numeric(
const
std::string& error_msg)
const
;
84
void
assert_maybe_numeric()
const
;
85
const
Dimension
& get_dim()
const
;
86
void
set_dim(
const
Dimension
& new_dim);
87
88
bool
operator==(
const
UDAValue& other)
const
;
89
bool
operator!=(
const
UDAValue& other)
const
;
90
91
bool
is_numeric()
const
{
return
double_value.has_value(); }
92
93
template
<
class
Serializer>
94
void
serializeOp(
Serializer
& serializer)
95
{
96
serializer(double_value);
97
serializer(string_value);
98
serializer(dim);
99
}
100
101
void
operator*=(
double
rhs);
102
103
104
private
:
105
std::optional<double> double_value;
106
std::string string_value;
107
108
Dimension
dim;
109
};
110
111
std::ostream& operator<<( std::ostream& stream,
const
UDAValue
& uda_value );
112
}
113
114
115
116
#endif
Opm::Dimension
Definition
Dimension.hpp:27
Opm::Serializer
Class for (de-)serializing.
Definition
Serializer.hpp:94
Opm::UDAValue
Definition
UDAValue.hpp:31
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition
Exceptions.hpp:30
opm
input
eclipse
Deck
UDAValue.hpp
Generated by
1.17.0