24#ifndef DUMUX_TABULATED_2D_FUNCTION_HH
25#define DUMUX_TABULATED_2D_FUNCTION_HH
60 Scalar yMin, Scalar yMax,
int n)
62 resize(xMin, xMax, m, yMin, yMax, n);
71 void resize(Scalar xMin, Scalar xMax,
int m,
72 Scalar yMin, Scalar yMax,
int n)
91 assert(0 <= i && i < m_);
93 return xMin_ + i*(xMax_ - xMin_)/(m_ - 1);
101 assert(0 <= j && j < n_);
103 return yMin_ + j*(yMax_ - yMin_)/(n_ - 1);
116 return (x - xMin_)/(xMax_ - xMin_)*m_;
130 return (y - yMin_)/(yMax_ - yMin_)*n_;
141 assert(0 <= i && i < m_);
142 assert(0 <= j && j < n_);
144 return samples_[j*m_ + i];
154 assert(0 <= i && i < m_);
155 assert(0 <= j && j < n_);
157 samples_[j*m_ + i] = value;
163 Scalar
get(Scalar x, Scalar y)
const
165 Scalar alpha =
xToI(x);
166 Scalar beta =
yToJ(y);
170 int i = max(0, min(m_,
static_cast<int>(alpha)));
171 int j = max(0, min(n_,
static_cast<int>(beta)));
179 return s1*(1.0 - beta) + s2*beta;
188 {
return get(x, y); }
194 std::vector<Scalar> samples_;
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Implements tabulation for a two-dimensional function.
Definition: tabulated2dfunction.hh:47
Tabulated2DFunction()
Default constructor.
Definition: tabulated2dfunction.hh:52
Scalar iToX(int i) const
Return the position on the x-axis of the i-th interval.
Definition: tabulated2dfunction.hh:89
Scalar xToI(Scalar x) const
Return the interval index of a given position on the x-axis.
Definition: tabulated2dfunction.hh:114
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:139
Tabulated2DFunction(Scalar xMin, Scalar xMax, int m, Scalar yMin, Scalar yMax, int n)
Constructor where the tabulation parameters are already provided.
Definition: tabulated2dfunction.hh:59
Scalar yToJ(Scalar y) const
Return the interval index of a given position on the y-axis.
Definition: tabulated2dfunction.hh:128
Scalar jToY(int j) const
Return the position on the y-axis of the j-th interval.
Definition: tabulated2dfunction.hh:99
Scalar operator()(Scalar x, Scalar y) const
The () operator.
Definition: tabulated2dfunction.hh:187
Scalar get(Scalar x, Scalar y) const
Return an interpolated value.
Definition: tabulated2dfunction.hh:163
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:152
void resize(Scalar xMin, Scalar xMax, int m, Scalar yMin, Scalar yMax, int n)
Resize the tabulation to a new range.
Definition: tabulated2dfunction.hh:71