Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dumux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dumux-repositories
dumux
Commits
a6d39192
Commit
a6d39192
authored
7 years ago
by
Timo Koch
Browse files
Options
Downloads
Patches
Plain Diff
[test] Introduce more math tests
parent
fc6e47de
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!807
Feature/improve math functions
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/common/math/CMakeLists.txt
+3
-3
3 additions, 3 deletions
test/common/math/CMakeLists.txt
test/common/math/test_math.cc
+41
-2
41 additions, 2 deletions
test/common/math/test_math.cc
with
44 additions
and
5 deletions
test/common/math/CMakeLists.txt
+
3
−
3
View file @
a6d39192
# build the test for the property system
dune_add_test
(
SOURCES test_
vtmv
.cc
)
dune_add_test
(
SOURCES test_
math
.cc
)
#install sources
install
(
FILES
test_vtmv.cc
DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/dumux/test/common/math
)
\ No newline at end of file
test_math.cc
DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/dumux/test/common/math
)
This diff is collapsed.
Click to expand it.
test/common/math/test_
vtmv
.cc
→
test/common/math/test_
math
.cc
+
41
−
2
View file @
a6d39192
...
...
@@ -19,8 +19,11 @@
/*!
* \file
*
* \brief This file tests the vtmv function with
* vtmv(Vector, FieldScalar, Vector) and vtmv(Vector, Matrix, Vector).
* \brief This file tests several math functions:
* the vtmv function with vtmv(Vector, FieldScalar, Vector) and vtmv(Vector, Matrix, Vector).
* the trace function
* the harmonicMean function
* \todo test more math functions!
*
* We declare some vectors and matrices and test the combinations of them
* against a previously calculated result.
...
...
@@ -55,6 +58,11 @@ int main() try
K
[
2
][
2
]
=
k
;
Dune
::
DynamicMatrix
<
double
>
K_dyn
(
K
);
//////////////////////////////////////////////////////////////////
///// Dumux::vtmv ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//! Set reference result. Should be -15 for all combinations
const
double
reference
=
-
15
;
...
...
@@ -90,6 +98,37 @@ int main() try
//! Test vtmv function with DynamicVector v1_dyn and DynamicMatrix K_dyn and DynamicVector v2_dyn
if
(
!
Dune
::
FloatCmp
::
eq
(
reference
,
Dumux
::
vtmv
(
v1_dyn
,
K_dyn
,
v2_dyn
),
1e-6
))
DUNE_THROW
(
Dune
::
Exception
,
"vtmv-result does not match reference"
);
//////////////////////////////////////////////////////////////////
///// Dumux::trace ///////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
const
auto
t1
=
Dumux
::
trace
(
K
);
const
auto
t2
=
Dumux
::
trace
(
K_dyn
);
if
(
!
Dune
::
FloatCmp
::
eq
(
t1
,
t2
,
1e-30
))
DUNE_THROW
(
Dune
::
Exception
,
"Traces do not match!"
);
//////////////////////////////////////////////////////////////////
///// Dumux::harmonicMean ////////////////////////////////////////
//////////////////////////////////////////////////////////////////
constexpr
auto
mean
=
Dumux
::
harmonicMean
(
4.0
,
5.0
);
static_assert
(
(
mean
-
4.0
*
5.0
*
2.0
/
(
4.0
+
5.0
))
<
1e-30
&&
(
mean
-
4.0
*
5.0
*
2.0
/
(
4.0
+
5.0
))
>
-
1e-30
,
"Wrong harmonic mean!"
);
//////////////////////////////////////////////////////////////////
///// Dumux::sign ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
static_assert
(
Dumux
::
sign
(
0.0
)
==
0
,
"Wrong sign!"
);
static_assert
(
Dumux
::
sign
(
-
0.0
)
==
0
,
"Wrong sign!"
);
static_assert
(
Dumux
::
sign
(
0
)
==
0
,
"Wrong sign!"
);
static_assert
(
Dumux
::
sign
(
-
0
)
==
0
,
"Wrong sign!"
);
static_assert
(
Dumux
::
sign
(
1
)
==
1
,
"Wrong sign!"
);
static_assert
(
Dumux
::
sign
(
2.0
)
==
1
,
"Wrong sign!"
);
static_assert
(
Dumux
::
sign
(
-
2
)
==
-
1
,
"Wrong sign!"
);
static_assert
(
Dumux
::
sign
(
-
3.5
)
==
-
1
,
"Wrong sign!"
);
}
catch
(
Dune
::
Exception
&
e
)
{
std
::
cerr
<<
e
<<
std
::
endl
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment