28#ifndef OPM_UNIFORM_TABULATED_2D_FUNCTION_HPP
29#define OPM_UNIFORM_TABULATED_2D_FUNCTION_HPP
31#include <opm/common/OpmLog/OpmLog.hpp>
35#include <opm/common/utility/gpuDecorators.hpp>
43template <
class Scalar,
class ContainerT = std::vector<Scalar>>
49 template <
class ViewType,
class ScalarT,
class ContainerType>
62template <
class Scalar,
class ContainerT = std::vector<Scalar>>
72 Scalar minY, Scalar maxY,
unsigned n,
74 : samples_(
samples), m_(m), n_(n), xMin_(minX), yMin_(minY), xMax_(maxX), yMax_(maxY){
82 Scalar minY, Scalar maxY,
unsigned n)
84 resize(minX, maxX, m, minY, maxY, n);
88 Scalar minY, Scalar maxY,
unsigned n,
89 const std::vector<std::vector<Scalar>>& vals)
91 resize(minX, maxX, m, minY, maxY, n);
93 for (
unsigned i = 0; i < m; ++i)
94 for (
unsigned j = 0; j < n; ++j)
101 Scalar minY, Scalar maxY,
unsigned n,
102 const double vals[200][500])
104 resize(minX, maxX, m, minY, maxY, n);
106 for (
unsigned i = 0; i < m; ++i)
107 for (
unsigned j = 0; j < n; ++j)
114 void resize(Scalar minX, Scalar maxX,
unsigned m,
115 Scalar minY, Scalar maxY,
unsigned n)
117 samples_.resize(m*n);
132 OPM_HOST_DEVICE Scalar
xMin()
const
138 OPM_HOST_DEVICE Scalar
xMax()
const
144 OPM_HOST_DEVICE Scalar
yMin()
const
150 OPM_HOST_DEVICE Scalar
yMax()
const
156 OPM_HOST_DEVICE
unsigned numX()
const
162 OPM_HOST_DEVICE
unsigned numY()
const
168 OPM_HOST_DEVICE
const ContainerT&
samples()
const
175 OPM_HOST_DEVICE Scalar
iToX(
unsigned i)
const
185 OPM_HOST_DEVICE Scalar
jToY(
unsigned j)
const
200 template <
class Evaluation>
201 OPM_HOST_DEVICE Evaluation
xToI(
const Evaluation& x)
const
212 template <
class Evaluation>
213 OPM_HOST_DEVICE Evaluation
yToJ(
const Evaluation& y)
const
219 template <
class Evaluation>
220 OPM_HOST_DEVICE
bool applies(
const Evaluation& x,
const Evaluation& y)
const
235 template <
class Evaluation>
236 OPM_HOST_DEVICE Evaluation
eval(
const Evaluation& x,
238 [[maybe_unused]]
bool extrapolate)
const
241#if !OPM_IS_INSIDE_DEVICE_FUNCTION
242 if (!extrapolate && !
applies(x,y)) {
243 std::string msg =
"Attempt to get tabulated value for ("
244 +std::to_string(
double(scalarValue(x)))+
", "+std::to_string(
double(scalarValue(y)))
245 +
") on a table of extent "
246 +std::to_string(
xMin())+
" to "+std::to_string(
xMax())+
" times "
247 +std::to_string(
yMin())+
" to "+std::to_string(
yMax());
254 Evaluation alpha =
xToI(x);
255 Evaluation beta =
yToJ(y);
258 static_cast<unsigned>(
259 std::max(0, std::min(
static_cast<int>(
numX()) - 2,
260 static_cast<int>(scalarValue(alpha)))));
262 static_cast<unsigned>(
263 std::max(0, std::min(
static_cast<int>(
numY()) - 2,
264 static_cast<int>(scalarValue(beta)))));
272 return s1*(1.0 - beta) + s2*beta;
285 return samples_[j*m_ + i];
298 samples_[j*m_ + i] = value;
303 return samples_ == data.samples_ &&
306 xMin_ == data.xMin_ &&
307 xMax_ == data.xMax_ &&
308 yMin_ == data.yMin_ &&
313 template <
class ViewType,
class ScalarT,
class Container>
338namespace Opm::gpuistl{
339 template<
class GPUContainer,
class ScalarT>
345 template <
class ViewType,
class ScalarT,
class ContainerType>
349 ViewType newTab = make_view<typename ViewType::value_type>(tab.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