24#ifndef DUMUX_TABULATED_2D_FUNCTION_HH
25#define DUMUX_TABULATED_2D_FUNCTION_HH
61 Scalar yMin, Scalar yMax,
int n)
63 resize(xMin, xMax, m, yMin, yMax, n);
72 void resize(Scalar xMin, Scalar xMax,
int m,
73 Scalar yMin, Scalar yMax,
int n)
92 assert(0 <= i && i < m_);
94 return xMin_ + i*(xMax_ - xMin_)/(m_ - 1);
102 assert(0 <= j && j < n_);
104 return yMin_ + j*(yMax_ - yMin_)/(n_ - 1);
117 return (x - xMin_)/(xMax_ - xMin_)*(m_ - 1);
131 return (y - yMin_)/(yMax_ - yMin_)*(n_ - 1);
142 assert(0 <= i && i < m_);
143 assert(0 <= j && j < n_);
145 return samples_[j*m_ + i];
155 assert(0 <= i && i < m_);
156 assert(0 <= j && j < n_);
158 samples_[j*m_ + i] = value;
164 Scalar
get(Scalar x, Scalar y)
const
166 Scalar alpha =
xToI(x);
167 Scalar beta =
yToJ(y);
170 int i = clamp(
static_cast<int>(alpha), 0, m_ - 2);
171 int j = clamp(
static_cast<int>(beta), 0, n_ - 2);
179 return s1*(1.0 - beta) + s2*beta;
188 {
return get(x, y); }
194 std::vector<Scalar> samples_;
Implements tabulation for a two-dimensional function.
Definition: tabulated2dfunction.hh:48
Tabulated2DFunction()
Default constructor.
Definition: tabulated2dfunction.hh:53
Scalar iToX(int i) const
Return the position on the x-axis of the i-th interval.
Definition: tabulated2dfunction.hh:90
Scalar xToI(Scalar x) const
Return the interval index of a given position on the x-axis.
Definition: tabulated2dfunction.hh:115
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:140
Tabulated2DFunction(Scalar xMin, Scalar xMax, int m, Scalar yMin, Scalar yMax, int n)
Constructor where the tabulation parameters are already provided.
Definition: tabulated2dfunction.hh:60
Scalar yToJ(Scalar y) const
Return the interval index of a given position on the y-axis.
Definition: tabulated2dfunction.hh:129
Scalar jToY(int j) const
Return the position on the y-axis of the j-th interval.
Definition: tabulated2dfunction.hh:100
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:164
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:153
void resize(Scalar xMin, Scalar xMax, int m, Scalar yMin, Scalar yMax, int n)
Resize the tabulation to a new range.
Definition: tabulated2dfunction.hh:72