Skip to content
Snippets Groups Projects
Commit c67e7e18 authored by Timo Koch's avatar Timo Koch
Browse files

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

Tabulated2DFunction::get(): out-of-bounds fix, also preferring interpolation to extrapolation

See merge request !2692

(cherry picked from commit ab9389eb)

fa441e6b Tabulated2DFunction::get(): out-of-bounds fix, also preferring interpolation to extrapolation
parent 20c174b7
No related branches found
No related tags found
1 merge request!2693Merge branch 'dpavlov/dumux-fix/tabulated2dfunction' into 'master'
Pipeline #5610 passed
+1
This commit is part of merge request !2693. Comments created here will be created in the context of that merge request.
......@@ -113,7 +113,7 @@ public:
*/
Scalar xToI(Scalar x) const
{
return (x - xMin_)/(xMax_ - xMin_)*m_;
return (x - xMin_)/(xMax_ - xMin_)*(m_ - 1);
}
......@@ -127,7 +127,7 @@ public:
*/
Scalar yToJ(Scalar y) const
{
return (y - yMin_)/(yMax_ - yMin_)*n_;
return (y - yMin_)/(yMax_ - yMin_)*(n_ - 1);
}
......@@ -165,10 +165,9 @@ public:
Scalar alpha = xToI(x);
Scalar beta = yToJ(y);
using std::max;
using std::min;
int i = max(0, min(m_, static_cast<int>(alpha)));
int j = max(0, min(n_, static_cast<int>(beta)));
using std::clamp;
int i = clamp(static_cast<int>(alpha), 0, m_ - 2);
int j = clamp(static_cast<int>(beta), 0, n_ - 2);
alpha -= i;
beta -= j;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment