Commit 229acefe authored by Hanchuan Wu's avatar Hanchuan Wu
Browse files

Merge branch 'cherry-pick-ab9389eb' into 'releases/3.4'

Merge branch 'dpavlov/dumux-fix/tabulated2dfunction' into 'master'

See merge request !2693
parents 20c174b7 c67e7e18
Pipeline #5617 passed with stage
in 20 seconds
...@@ -113,7 +113,7 @@ public: ...@@ -113,7 +113,7 @@ public:
*/ */
Scalar xToI(Scalar x) const Scalar xToI(Scalar x) const
{ {
return (x - xMin_)/(xMax_ - xMin_)*m_; return (x - xMin_)/(xMax_ - xMin_)*(m_ - 1);
} }
...@@ -127,7 +127,7 @@ public: ...@@ -127,7 +127,7 @@ public:
*/ */
Scalar yToJ(Scalar y) const Scalar yToJ(Scalar y) const
{ {
return (y - yMin_)/(yMax_ - yMin_)*n_; return (y - yMin_)/(yMax_ - yMin_)*(n_ - 1);
} }
...@@ -165,10 +165,9 @@ public: ...@@ -165,10 +165,9 @@ public:
Scalar alpha = xToI(x); Scalar alpha = xToI(x);
Scalar beta = yToJ(y); Scalar beta = yToJ(y);
using std::max; using std::clamp;
using std::min; int i = clamp(static_cast<int>(alpha), 0, m_ - 2);
int i = max(0, min(m_, static_cast<int>(alpha))); int j = clamp(static_cast<int>(beta), 0, n_ - 2);
int j = max(0, min(n_, static_cast<int>(beta)));
alpha -= i; alpha -= i;
beta -= j; beta -= j;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment