28 #ifndef OPM_UNIFORM_TABULATED_2D_FUNCTION_HPP
29 #define OPM_UNIFORM_TABULATED_2D_FUNCTION_HPP
35 #include <opm/common/OpmLog/OpmLog.hpp>
53 template <
class Scalar>
65 Scalar minY, Scalar maxY,
unsigned n)
67 resize(minX, maxX, m, minY, maxY, n);
71 Scalar minY, Scalar maxY,
unsigned n,
72 const std::vector<std::vector<Scalar>>& vals)
74 resize(minX, maxX, m, minY, maxY, n);
76 for (
unsigned i = 0; i < m; ++i)
77 for (
unsigned j = 0; j < n; ++j)
84 void resize(Scalar minX, Scalar maxX,
unsigned m,
85 Scalar minY, Scalar maxY,
unsigned n)
163 template <
class Evaluation>
164 Evaluation
xToI(
const Evaluation& x)
const
175 template <
class Evaluation>
176 Evaluation
yToJ(
const Evaluation& y)
const
182 template <
class Evaluation>
183 bool applies(
const Evaluation& x,
const Evaluation& y)
const
198 template <
class Evaluation>
199 Evaluation
eval(
const Evaluation& x,
const Evaluation& y,
bool extrapolate)
const
203 std::string msg =
"Attempt to get tabulated value for ("
204 +std::to_string(
double(scalarValue(x)))+
", "+std::to_string(
double(scalarValue(y)))
205 +
") on a table of extent "
206 +std::to_string(
xMin())+
" to "+std::to_string(
xMax())+
" times "
207 +std::to_string(
yMin())+
" to "+std::to_string(
yMax());
216 OpmLog::warning(
"PVT Table evaluation:" + msg +
". Will use extrapolation");
218 std::cerr <<
"warning: "<< msg<<std::endl;
224 Evaluation alpha =
xToI(x);
225 Evaluation beta =
yToJ(y);
228 static_cast<unsigned>(
229 std::max(0, std::min(
static_cast<int>(
numX()) - 2,
230 static_cast<int>(scalarValue(alpha)))));
232 static_cast<unsigned>(
233 std::max(0, std::min(
static_cast<int>(
numY()) - 2,
234 static_cast<int>(scalarValue(beta)))));
242 return s1*(1.0 - beta) + s2*beta;
255 return samples_[j*m_ + i];
268 samples_[j*m_ + i] = value;
273 return samples_ == data.samples_ &&
276 xMin_ == data.xMin_ &&
277 xMax_ == data.xMax_ &&
278 yMin_ == data.yMin_ &&
287 std::vector<Scalar> samples_;
Provides the opm-material specific exception classes.
Definition: Exceptions.hpp:46