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
dc1eb710
Commit
dc1eb710
authored
7 years ago
by
Simon Emmert
Browse files
Options
Downloads
Patches
Plain Diff
[math]Add test for Vectors and Matrices with vtmv function
parent
e150ae8f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/common/CMakeLists.txt
+3
-2
3 additions, 2 deletions
test/common/CMakeLists.txt
test/common/math/CMakeLists.txt
+7
-0
7 additions, 0 deletions
test/common/math/CMakeLists.txt
test/common/math/test_vtmv.cc
+97
-0
97 additions, 0 deletions
test/common/math/test_vtmv.cc
with
107 additions
and
2 deletions
test/common/CMakeLists.txt
+
3
−
2
View file @
dc1eb710
add_subdirectory
(
propertysystem
)
add_subdirectory
(
spline
)
add_subdirectory
(
boundingboxtree
)
add_subdirectory
(
math
)
add_subdirectory
(
parameters
)
add_subdirectory
(
propertysystem
)
add_subdirectory
(
spline
)
This diff is collapsed.
Click to expand it.
test/common/math/CMakeLists.txt
0 → 100644
+
7
−
0
View file @
dc1eb710
# build the test for the property system
dune_add_test
(
SOURCES test_vtmv.cc
)
#install sources
install
(
FILES
test_vtmv.cc
DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/dumux/test/common/math
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
test/common/math/test_vtmv.cc
0 → 100644
+
97
−
0
View file @
dc1eb710
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
*
* \brief This file tests the vtmv function with
* vtmv(Vector, FieldScalar, Vector) and vtmv(Vector, Matrix, Vector).
*
* We declare some vectors and matrices and test the combinations of them
* against a previously calculated result.
*/
#include
<config.h>
#include
<iostream>
#include
<dune/common/float_cmp.hh>
#include
<dune/common/fmatrix.hh>
#include
<dune/common/dynmatrix.hh>
#include
<dune/common/fvector.hh>
#include
<dune/common/dynvector.hh>
#include
<dumux/common/math.hh>
int
main
()
try
{
//! Declare Vectors (FieldVector and DynamicVector)
Dune
::
FieldVector
<
double
,
3
>
v1
({
1.0
,
2.0
,
3.0
});
Dune
::
FieldVector
<
double
,
3
>
v2
({
1.0
,
0.0
,
-
2.0
});
Dune
::
DynamicVector
<
double
>
v1_dyn
(
v1
);
Dune
::
DynamicVector
<
double
>
v2_dyn
(
v2
);
//! Declare 3x3 Matrices with 3's on the principal diagonal
double
k
=
3.0
;
Dune
::
FieldMatrix
<
double
,
3
,
3
>
K
(
0.0
);
K
[
0
][
0
]
=
k
;
K
[
1
][
1
]
=
k
;
K
[
2
][
2
]
=
k
;
Dune
::
DynamicMatrix
<
double
>
K_dyn
(
K
);
//! Set reference result. Should be -15 for all combinations
const
double
reference
=
-
15
;
//! Test with FieldVector v1
//! Test vtmv function with FieldVector v1 and Scalar k and FieldVector v2
if
(
!
Dune
::
FloatCmp
::
eq
(
reference
,
Dumux
::
vtmv
(
v1
,
k
,
v2
),
1e-6
))
DUNE_THROW
(
Dune
::
Exception
,
"vtmv-result does not match reference"
);
//! Test vtmv function with FieldVector v1 and FieldMatrix K and FieldVector v2
if
(
!
Dune
::
FloatCmp
::
eq
(
reference
,
Dumux
::
vtmv
(
v1
,
K
,
v2
),
1e-6
))
DUNE_THROW
(
Dune
::
Exception
,
"vtmv-result does not match reference"
);
//! Test vtmv function with FieldVector v1 and FieldMatrix K and DynamicVector v2_dyn
if
(
!
Dune
::
FloatCmp
::
eq
(
reference
,
Dumux
::
vtmv
(
v1
,
K
,
v2_dyn
),
1e-6
))
DUNE_THROW
(
Dune
::
Exception
,
"vtmv-result does not match reference"
);
//! Test vtmv function with FieldVector v1 and DynamicMatrix K_dyn and FieldVector v2
if
(
!
Dune
::
FloatCmp
::
eq
(
reference
,
Dumux
::
vtmv
(
v1
,
K_dyn
,
v2
),
1e-6
))
DUNE_THROW
(
Dune
::
Exception
,
"vtmv-result does not match reference"
);
//! Test with DynamicVector v1_dyn
//! Test vtmv function with DynamicVector v1_dyn and Scalar k and FieldVector v2
if
(
!
Dune
::
FloatCmp
::
eq
(
reference
,
Dumux
::
vtmv
(
v1_dyn
,
k
,
v2
),
1e-6
))
DUNE_THROW
(
Dune
::
Exception
,
"vtmv-result does not match reference"
);
//! Test vtmv function with DynamicVector v1_dyn and FieldMatrix K and FieldVector v2
if
(
!
Dune
::
FloatCmp
::
eq
(
reference
,
Dumux
::
vtmv
(
v1_dyn
,
K
,
v2
),
1e-6
))
DUNE_THROW
(
Dune
::
Exception
,
"vtmv-result does not match reference"
);
//! Test vtmv function with DynamicVector v1_dyn and Scalar k and DynamicVector v2_dyn
if
(
!
Dune
::
FloatCmp
::
eq
(
reference
,
Dumux
::
vtmv
(
v1_dyn
,
K
,
v2_dyn
),
1e-6
))
DUNE_THROW
(
Dune
::
Exception
,
"vtmv-result does not match reference"
);
//! Test vtmv function with DynamicVector v1_dyn and DynamicMatrix K_dyn and FieldVector v2
if
(
!
Dune
::
FloatCmp
::
eq
(
reference
,
Dumux
::
vtmv
(
v1_dyn
,
K_dyn
,
v2
),
1e-6
))
DUNE_THROW
(
Dune
::
Exception
,
"vtmv-result does not match reference"
);
//! Test Dynamic Vectors and Dynamic Matrices
//! 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"
);
}
catch
(
Dune
::
Exception
&
e
)
{
std
::
cerr
<<
e
<<
std
::
endl
;
return
1
;
}
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