12#ifndef DUMUX_TABULATED_2D_FUNCTION_HH 
   13#define DUMUX_TABULATED_2D_FUNCTION_HH 
   49                        Scalar yMin, Scalar yMax, 
int n)
 
   51        resize(xMin, xMax, m, yMin, yMax, n);
 
 
   60    void resize(Scalar xMin, Scalar xMax, 
int m,
 
   61                Scalar yMin, Scalar yMax, 
int n)
 
 
   80        assert(0 <= i && i < m_);
 
   82        return xMin_ + i*(xMax_ - xMin_)/(m_ - 1);
 
 
   90        assert(0 <= j && j < n_);
 
   92        return yMin_ + j*(yMax_ - yMin_)/(n_ - 1);
 
 
  105        return (x - xMin_)/(xMax_ - xMin_)*(m_ - 1);
 
 
  119        return (y - yMin_)/(yMax_ - yMin_)*(n_ - 1);
 
 
  130        assert(0 <= i && i < m_);
 
  131        assert(0 <= j && j < n_);
 
  133        return samples_[j*m_ + i];
 
 
  143        assert(0 <= i && i < m_);
 
  144        assert(0 <= j && j < n_);
 
  146        samples_[j*m_ + i] = value;
 
 
  152    Scalar 
get(Scalar x, Scalar y)
 const 
  154        Scalar alpha = 
xToI(x);
 
  155        Scalar beta = 
yToJ(y);
 
  158        int i = clamp(
static_cast<int>(alpha), 0, m_ - 2);
 
  159        int j = clamp(
static_cast<int>(beta),  0, n_ - 2);
 
  167        return s1*(1.0 - beta) + s2*beta;
 
 
  176    { 
return get(x, y); }
 
 
  182    std::vector<Scalar> samples_;
 
 
Tabulated2DFunction()
Default constructor.
Definition tabulated2dfunction.hh:41
Scalar iToX(int i) const
Return the position on the x-axis of the i-th interval.
Definition tabulated2dfunction.hh:78
Scalar xToI(Scalar x) const
Return the interval index of a given position on the x-axis.
Definition tabulated2dfunction.hh:103
Scalar getSamplePoint(int i, int j) const
Get the value of the sample point which is at the intersection of the -th interval of the x-Axis and ...
Definition tabulated2dfunction.hh:128
Tabulated2DFunction(Scalar xMin, Scalar xMax, int m, Scalar yMin, Scalar yMax, int n)
Constructor where the tabulation parameters are already provided.
Definition tabulated2dfunction.hh:48
Scalar yToJ(Scalar y) const
Return the interval index of a given position on the y-axis.
Definition tabulated2dfunction.hh:117
Scalar jToY(int j) const
Return the position on the y-axis of the j-th interval.
Definition tabulated2dfunction.hh:88
Scalar operator()(Scalar x, Scalar y) const
The () operator.
Definition tabulated2dfunction.hh:175
Scalar get(Scalar x, Scalar y) const
Return an interpolated value.
Definition tabulated2dfunction.hh:152
void setSamplePoint(int i, int j, Scalar value)
Set the value of the sample point which is at the intersection of the -th interval of the x-Axis and ...
Definition tabulated2dfunction.hh:141
void resize(Scalar xMin, Scalar xMax, int m, Scalar yMin, Scalar yMax, int n)
Resize the tabulation to a new range.
Definition tabulated2dfunction.hh:60