Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-istl
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
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Core Modules
dune-istl
Commits
e7a13bd9
Commit
e7a13bd9
authored
6 years ago
by
Oliver Sander
Browse files
Options
Downloads
Patches
Plain Diff
Refactor the test for MultiTypeBlockMatrix a bit
In preparation of testing more matrix types
parent
2b376b38
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!282
Improve matrix testing
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/istl/test/multitypeblockmatrixtest.cc
+42
-44
42 additions, 44 deletions
dune/istl/test/multitypeblockmatrixtest.cc
with
42 additions
and
44 deletions
dune/istl/test/multitypeblockmatrixtest.cc
+
42
−
44
View file @
e7a13bd9
...
...
@@ -28,63 +28,61 @@
using
namespace
Dune
;
int
main
(
int
argc
,
char
**
argv
)
try
{
// Import the static constants _0, _1, etc
using
namespace
Indices
;
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// First, we test a MultiTypeBlockMatrix consisting of an array of 2x2 dense matrices.
// The upper left dense matrix has dense 3x3 blocks, the lower right matrix has 1x1 blocks,
// the off-set diagonal matrix block sizes are set accordingly.
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// Import the static constants _0, _1, etc
using
namespace
Indices
;
// set up the test matrix
typedef
MultiTypeBlockVector
<
Matrix
<
FieldMatrix
<
double
,
3
,
3
>
>
,
Matrix
<
FieldMatrix
<
double
,
3
,
1
>
>
>
RowType0
;
typedef
MultiTypeBlockVector
<
Matrix
<
FieldMatrix
<
double
,
1
,
3
>
>
,
Matrix
<
FieldMatrix
<
double
,
1
,
1
>
>
>
RowType1
;
void
testInterfaceMethods
()
{
{
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// First, we test a MultiTypeBlockMatrix consisting of an array of 2x2 dense matrices.
// The upper left dense matrix has dense 3x3 blocks, the lower right matrix has 1x1 blocks,
// the off-set diagonal matrix block sizes are set accordingly.
///////////////////////////////////////////////////////////////////////////////////////////////////////////
MultiTypeBlockMatrix
<
RowType0
,
RowType1
>
multiMatrix
;
// set up the test matrix
typedef
MultiTypeBlockVector
<
Matrix
<
FieldMatrix
<
double
,
3
,
3
>
>
,
Matrix
<
FieldMatrix
<
double
,
3
,
1
>
>
>
RowType0
;
typedef
MultiTypeBlockVector
<
Matrix
<
FieldMatrix
<
double
,
1
,
3
>
>
,
Matrix
<
FieldMatrix
<
double
,
1
,
1
>
>
>
RowType1
;
multiMatrix
[
_0
][
_0
].
setSize
(
3
,
3
);
multiMatrix
[
_0
][
_1
].
setSize
(
3
,
2
);
multiMatrix
[
_1
][
_0
].
setSize
(
2
,
3
);
multiMatrix
[
_1
][
_1
].
setSize
(
2
,
2
);
MultiTypeBlockMatrix
<
RowType0
,
RowType1
>
multiMatrix
;
// lazy solution: initialize the entire matrix with zeros
multiMatrix
=
0
;
multiMatrix
[
_0
][
_0
].
setSize
(
3
,
3
);
multiMatrix
[
_0
][
_1
].
setSize
(
3
,
2
);
multiMatrix
[
_1
][
_0
].
setSize
(
2
,
3
);
multiMatrix
[
_1
][
_1
].
setSize
(
2
,
2
);
printmatrix
(
std
::
cout
,
multiMatrix
[
_0
][
_0
],
"(0,0)"
,
"--"
);
printmatrix
(
std
::
cout
,
multiMatrix
[
_0
][
_1
],
"(0,1)"
,
"--"
);
printmatrix
(
std
::
cout
,
multiMatrix
[
_1
][
_0
],
"(1,0)"
,
"--"
);
printmatrix
(
std
::
cout
,
multiMatrix
[
_1
][
_1
],
"(1,1)"
,
"--"
);
// Init with scalar values
multiMatrix
[
_0
][
_0
]
=
4200
;
multiMatrix
[
_0
][
_1
]
=
4201
;
multiMatrix
[
_1
][
_0
]
=
4210
;
multiMatrix
[
_1
][
_1
]
=
4211
;
//
Test vector space operations
testVectorSpaceOperations
(
multiMatrix
)
;
//
Set up a test vector
MultiTypeBlockVector
<
BlockVector
<
FieldVector
<
double
,
3
>
>
,
BlockVector
<
FieldVector
<
double
,
1
>
>
>
domainVector
;
// Test whether matrix class has the required constructors
testMatrixConstructibility
<
decltype
(
multiMatrix
)
>
();
domainVector
[
_0
]
=
{{
1
,
0
,
0
},
{
0
,
1
,
0
},
{
0
,
0
,
1
}};
// set up a test vector
MultiTypeBlockVector
<
BlockVector
<
FieldVector
<
double
,
3
>
>
,
BlockVector
<
FieldVector
<
double
,
1
>
>
>
multiVector
;
domainVector
[
_1
]
=
{
3.14
,
42
};
multiVector
[
_0
]
=
{{
1
,
0
,
0
},
{
0
,
1
,
0
},
{
0
,
0
,
1
}};
auto
rangeVector
=
domainVector
;
// Range == Domain, because the matrix nesting pattern is symmetric
multiVector
[
_1
]
=
{
3.14
,
42
};
// Test vector space operations
testVectorSpaceOperations
(
multiMatrix
);
// Test matrix-vector products
MultiTypeBlockVector
<
BlockVector
<
FieldVector
<
double
,
3
>
>
,
BlockVector
<
FieldVector
<
double
,
1
>
>
>
result
;
result
[
_0
].
resize
(
3
);
result
[
_1
].
resize
(
2
);
// Test whether matrix class has the required constructors
testMatrixConstructibility
<
decltype
(
multiMatrix
)
>
();
multiMatrix
[
_0
][
_0
]
=
4200
;
multiMatrix
[
_0
][
_1
]
=
4201
;
multiMatrix
[
_1
][
_0
]
=
4210
;
multiMatrix
[
_1
][
_1
]
=
4211
;
// Test matrix-vector products
testMatrixVectorProducts
(
multiMatrix
,
domainVector
,
rangeVector
)
;
}
}
auto
rangeVector
=
result
;
// Range == Domain, because the matrix nesting pattern is symmetric
testMatrixVectorProducts
(
multiMatrix
,
result
,
rangeVector
);
int
main
(
int
argc
,
char
**
argv
)
try
{
// Run the standard tests for the dune-istl matrix interface
testInterfaceMethods
();
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// Next test: Set up a linear system with a matrix consisting of 2x2 sparse scalar matrices.
...
...
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