opm-common
Toggle main menu visibility
Loading...
Searching...
No Matches
ParameterRequirement.hpp
1
//===========================================================================
2
//
3
// File: ParameterRequirement.hpp
4
//
5
// Created: Tue Jun 2 19:05:02 2009
6
//
7
// Author(s): Bård Skaflestad <bard.skaflestad@sintef.no>
8
// Atgeirr F Rasmussen <atgeirr@sintef.no>
9
//
10
// $Date$
11
//
12
// $Revision$
13
//
14
//===========================================================================
15
16
/*
17
Copyright 2009, 2010 SINTEF ICT, Applied Mathematics.
18
Copyright 2009, 2010 Statoil ASA.
19
20
This file is part of the Open Porous Media project (OPM).
21
22
OPM is free software: you can redistribute it and/or modify
23
it under the terms of the GNU General Public License as published by
24
the Free Software Foundation, either version 3 of the License, or
25
(at your option) any later version.
26
27
OPM is distributed in the hope that it will be useful,
28
but WITHOUT ANY WARRANTY; without even the implied warranty of
29
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
GNU General Public License for more details.
31
32
You should have received a copy of the GNU General Public License
33
along with OPM. If not, see <http://www.gnu.org/licenses/>.
34
*/
35
36
#ifndef OPM_PARAMETERREQUIREMENT_HEADER
37
#define OPM_PARAMETERREQUIREMENT_HEADER
38
39
#include <string>
40
#include <vector>
41
42
namespace
Opm
{
48
struct
ParameterRequirementNone
{
49
template
<
typename
T>
50
std::string operator()(
const
T&)
const
{
51
return
""
;
52
}
53
};
54
59
struct
ParameterRequirementProbability
{
60
std::string operator()(
double
x)
const
;
61
};
62
68
struct
ParameterRequirementPositive
{
69
template
<
typename
T>
70
std::string operator()(
const
T& x)
const
{
71
if
(x > 0) {
72
return
""
;
73
}
else
{
74
return
"The value '"
+ std::to_string(x) +
75
"' is not positive."
;
76
}
77
}
78
};
79
85
struct
ParameterRequirementNegative
{
86
template
<
typename
T>
87
std::string operator()(
const
T& x)
const
{
88
if
(x < 0) {
89
return
""
;
90
}
else
{
91
return
"The value '"
+ std::to_string(x) +
92
"' is not negative."
;
93
}
94
}
95
};
96
102
struct
ParameterRequirementNonPositive
{
103
template
<
typename
T>
104
std::string operator()(
const
T& x)
const
{
105
if
(x > 0) {
106
return
"The value '"
+ std::to_string(x) +
107
"' is positive."
;
108
}
else
{
109
return
""
;
110
}
111
}
112
};
113
119
struct
ParameterRequirementNonNegative
{
120
template
<
typename
T>
121
std::string operator()(
const
T& x)
const
{
122
if
(x < 0) {
123
return
"The value '"
+ std::to_string(x) +
124
"' is negative."
;
125
}
else
{
126
return
""
;
127
}
128
}
129
};
130
136
struct
ParameterRequirementNonZero
{
137
template
<
typename
T>
138
std::string operator()(
const
T& x)
const
{
139
if
(x != 0) {
140
return
""
;
141
}
else
{
142
return
"The value was zero."
;
143
}
144
}
145
};
146
151
struct
ParameterRequirementNonEmpty
{
152
std::string operator()(
const
std::string& x)
const
{
153
if
(x !=
""
) {
154
return
"The string was empty."
;
155
}
else
{
156
return
""
;
157
}
158
}
159
};
160
166
template
<
class
Requirement1,
class
Requirement2>
167
struct
ParameterRequirementAnd {
168
ParameterRequirementAnd(
const
Requirement1& r1,
const
Requirement2& r2) :
169
r1_(r1), r2_(r2) { }
170
171
template
<
typename
T>
172
std::string operator()(
const
T& t)
const
{
173
std::string e1 = r1_(t);
174
std::string e2 = r2_(t);
175
if
(e1 ==
""
) {
176
return
e2;
177
}
else
if
(e2 ==
""
) {
178
return
e1;
179
}
else
{
180
return
e1 +
" AND "
+ e2;
181
}
182
}
183
private
:
184
const
Requirement1 r1_;
185
const
Requirement2 r2_;
186
};
187
191
struct
ParameterRequirementMemberOf {
192
explicit
ParameterRequirementMemberOf(
const
std::vector<std::string>& elements);
193
198
std::string
operator()
(
const
std::string& x)
const
;
199
200
private
:
201
const
std::vector<std::string> elements_;
202
};
203
}
// namespace Opm
204
205
#endif
// OPM_PARAMETERREQUIREMENT_HEADER
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition
Exceptions.hpp:30
Opm::ParameterRequirementMemberOf::operator()
std::string operator()(const std::string &x) const
Definition
ParameterRequirement.cpp:66
Opm::ParameterRequirementNegative
Definition
ParameterRequirement.hpp:85
Opm::ParameterRequirementNonEmpty
Definition
ParameterRequirement.hpp:151
Opm::ParameterRequirementNonNegative
Definition
ParameterRequirement.hpp:119
Opm::ParameterRequirementNonPositive
Definition
ParameterRequirement.hpp:102
Opm::ParameterRequirementNonZero
Definition
ParameterRequirement.hpp:136
Opm::ParameterRequirementNone
Definition
ParameterRequirement.hpp:48
Opm::ParameterRequirementPositive
Definition
ParameterRequirement.hpp:68
Opm::ParameterRequirementProbability
Definition
ParameterRequirement.hpp:59
opm
common
utility
parameters
ParameterRequirement.hpp
Generated by
1.17.0