opm-common
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 {
49  template<typename T>
50  std::string operator()(const T&) const {
51  return "";
52  }
53  };
54 
60  std::string operator()(double x) const;
61  };
62 
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 
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 
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 
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 
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 
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>
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 
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
Definition: ParameterRequirement.hpp:151
Definition: ParameterRequirement.hpp:136
Definition: ParameterRequirement.hpp:48
Definition: ParameterRequirement.hpp:102
Definition: ParameterRequirement.hpp:191
Definition: ParameterRequirement.hpp:59
std::string operator()(const std::string &x) const
Definition: ParameterRequirement.cpp:66
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: ParameterRequirement.hpp:68
Definition: ParameterRequirement.hpp:85
Definition: ParameterRequirement.hpp:167
Definition: ParameterRequirement.hpp:119