Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dumux-repositories
dumux
Commits
dfae9ed1
Commit
dfae9ed1
authored
Sep 05, 2020
by
Samuel Scherrer
Committed by
Timo Koch
Sep 05, 2020
Browse files
[common] add tests for spline extrapolation
parent
a25e4e17
Changes
1
Hide whitespace changes
Inline
Side-by-side
test/common/spline/test_spline.cc
View file @
dfae9ed1
...
...
@@ -131,6 +131,39 @@ void testNatural(const Spline &sp,
<<
(
d3
-
d2
)
/
eps
<<
" ought to be 0"
);
}
/*!
* \brief Tests extrapolation, see issue 925
*
* Note: tests only Spline<double, -1> since the implementation is common to
* to all spline classes.
*/
void
testExtrapolation
()
{
std
::
vector
<
double
>
x
=
{
0.0
,
0.25
,
0.5
,
0.75
,
1.0
};
std
::
vector
<
double
>
y
=
{
1.0
,
1.0
,
1.0
,
1.0
,
1.0
};
Dumux
::
Spline
<
double
,
-
1
>
sp
(
x
,
y
);
double
xi
=
sp
.
eval
(
0.6
);
if
(
Dune
::
FloatCmp
::
ne
(
xi
,
1.0
))
DUNE_THROW
(
Dune
::
InvalidStateException
,
"Spline interpolation gives "
<<
xi
<<
" ought to be 1"
);
xi
=
sp
.
eval
(
-
0.1
,
/*interpolate=*/
true
);
if
(
Dune
::
FloatCmp
::
ne
(
xi
,
1.0
))
DUNE_THROW
(
Dune
::
InvalidStateException
,
"Spline extrapolation at -0.1 gives "
<<
xi
<<
" ought to be 1"
);
xi
=
sp
.
eval
(
1.1
,
/*interpolate=*/
true
);
if
(
Dune
::
FloatCmp
::
ne
(
xi
,
1.0
))
DUNE_THROW
(
Dune
::
InvalidStateException
,
"Spline extrapolation at 1.1 gives "
<<
xi
<<
" ought to be 1"
);
}
void
testAll
()
{
double
x
[]
=
{
0
,
5
,
7.5
,
8.75
,
9.375
};
...
...
@@ -238,6 +271,7 @@ void plot()
int
main
(
int
argc
,
char
**
argv
)
{
testAll
();
testExtrapolation
();
plot
();
return
0
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment