28#ifndef OPM_UNIFORM_TABULATED_2D_FUNCTION_HPP
29#define OPM_UNIFORM_TABULATED_2D_FUNCTION_HPP
31#include <opm/common/OpmLog/OpmLog.hpp>
50template <
class Scalar>
62 Scalar minY, Scalar maxY,
unsigned n)
64 resize(minX, maxX, m, minY, maxY, n);
68 Scalar minY, Scalar maxY,
unsigned n,
69 const std::vector<std::vector<Scalar>>& vals)
71 resize(minX, maxX, m, minY, maxY, n);
73 for (
unsigned i = 0; i < m; ++i)
74 for (
unsigned j = 0; j < n; ++j)
81 void resize(Scalar minX, Scalar maxX,
unsigned m,
82 Scalar minY, Scalar maxY,
unsigned n)
160 template <
class Evaluation>
161 Evaluation
xToI(
const Evaluation& x)
const
172 template <
class Evaluation>
173 Evaluation
yToJ(
const Evaluation& y)
const
179 template <
class Evaluation>
180 bool applies(
const Evaluation& x,
const Evaluation& y)
const
195 template <
class Evaluation>
196 Evaluation
eval(
const Evaluation& x,
198 [[maybe_unused]]
bool extrapolate)
const
201 if (!extrapolate && !
applies(x,y)) {
202 std::string msg =
"Attempt to get tabulated value for ("
203 +std::to_string(
double(scalarValue(x)))+
", "+std::to_string(
double(scalarValue(y)))
204 +
") on a table of extent "
205 +std::to_string(
xMin())+
" to "+std::to_string(
xMax())+
" times "
206 +std::to_string(
yMin())+
" to "+std::to_string(
yMax());
214 OpmLog::warning(
"PVT Table evaluation:" + msg +
". Will use extrapolation");
220 Evaluation alpha =
xToI(x);
221 Evaluation beta =
yToJ(y);
224 static_cast<unsigned>(
225 std::max(0, std::min(
static_cast<int>(
numX()) - 2,
226 static_cast<int>(scalarValue(alpha)))));
228 static_cast<unsigned>(
229 std::max(0, std::min(
static_cast<int>(
numY()) - 2,
230 static_cast<int>(scalarValue(beta)))));
238 return s1*(1.0 - beta) + s2*beta;
251 return samples_[j*m_ + i];
264 samples_[j*m_ + i] = value;
269 return samples_ == data.samples_ &&
272 xMin_ == data.xMin_ &&
273 xMax_ == data.xMax_ &&
274 yMin_ == data.yMin_ &&
283 std::vector<Scalar> samples_;
Provides the OPM specific exception classes.
Definition Exceptions.hpp:40
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30