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
d40d8011
Commit
d40d8011
authored
1 year ago
by
Patrick Jaap
Committed by
Patrick Jaap
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
umfpacktest: Use Dune::TestSuite and add result check
parent
d92235e0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!530
UMFPACK: Use generic flatMatrixForEach routines for arbitrary blocked matrices
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/istl/test/umfpacktest.cc
+35
-7
35 additions, 7 deletions
dune/istl/test/umfpacktest.cc
with
35 additions
and
7 deletions
dune/istl/test/umfpacktest.cc
+
35
−
7
View file @
d40d8011
...
...
@@ -9,19 +9,20 @@
#include
<dune/common/fmatrix.hh>
#include
<dune/common/fvector.hh>
#include
<dune/common/timer.hh>
#include
<dune/common/test/testsuite.hh>
#include
<dune/istl/bvector.hh>
#include
<dune/istl/umfpack.hh>
#include
"laplacian.hh"
using
namespace
Dune
;
template
<
typename
Matrix
,
typename
Vector
>
void
runUMFPack
(
std
::
size_t
N
)
TestSuite
runUMFPack
(
std
::
size_t
N
)
{
typedef
Dune
::
MatrixAdapter
<
Matrix
,
Vector
,
Vector
>
Operator
;
TestSuite
t
;
Matrix
mat
;
Operator
fop
(
mat
);
Vector
b
(
N
*
N
),
x
(
N
*
N
),
b1
(
N
/
2
),
x1
(
N
/
2
);
setupLaplacian
(
mat
,
N
);
...
...
@@ -41,6 +42,10 @@ void runUMFPack(std::size_t N)
solver
.
apply
(
x
,
b
,
res
);
solver
.
free
();
// test
mat
.
mmv
(
x
,
b
);
t
.
check
(
b
.
two_norm
()
<
1e-9
)
<<
" Error in UMFPACK, residual is too large: "
<<
b
.
two_norm
();
Dune
::
UMFPack
<
Matrix
>
solver1
;
std
::
set
<
std
::
size_t
>
mrs
;
...
...
@@ -51,16 +56,39 @@ void runUMFPack(std::size_t N)
solver1
.
setVerbosity
(
true
);
solver1
.
apply
(
x1
,
b1
,
res
);
// test
x
=
0
;
b
=
0
;
for
(
std
::
size_t
i
=
0
;
i
<
N
/
2
;
i
++
)
{
// set subindices
x
[
i
]
=
x1
[
i
];
b
[
i
]
=
b1
[
i
];
}
mat
.
mmv
(
x
,
b
);
// truncate deactivated indices
for
(
std
::
size_t
i
=
N
/
2
;
i
<
N
*
N
;
i
++
)
b
[
i
]
=
0
;
t
.
check
(
b
.
two_norm
()
<
1e-9
)
<<
" Error in UMFPACK, residual is too large: "
<<
b
.
two_norm
();
solver1
.
apply
(
reinterpret_cast
<
typename
Matrix
::
field_type
*>
(
&
x1
[
0
]),
reinterpret_cast
<
typename
Matrix
::
field_type
*>
(
&
b1
[
0
]));
Dune
::
UMFPack
<
Matrix
>
save_solver
(
mat
,
"umfpack_decomp"
,
0
);
Dune
::
UMFPack
<
Matrix
>
load_solver
(
mat
,
"umfpack_decomp"
,
0
);
return
t
;
}
int
main
(
int
argc
,
char
**
argv
)
try
{
#if HAVE_SUITESPARSE_UMFPACK
TestSuite
t
;
std
::
size_t
N
=
100
;
if
(
argc
>
1
)
...
...
@@ -71,7 +99,7 @@ int main(int argc, char** argv) try
{
using
Matrix
=
Dune
::
BCRSMatrix
<
double
>
;
using
Vector
=
Dune
::
BlockVector
<
double
>
;
runUMFPack
<
Matrix
,
Vector
>
(
N
);
t
.
subTest
(
runUMFPack
<
Matrix
,
Vector
>
(
N
)
)
;
}
// ------------------------------------------------------------------------------
...
...
@@ -79,7 +107,7 @@ int main(int argc, char** argv) try
{
using
Matrix
=
Dune
::
BCRSMatrix
<
Dune
::
FieldMatrix
<
double
,
1
,
1
>
>
;
using
Vector
=
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
1
>
>
;
runUMFPack
<
Matrix
,
Vector
>
(
N
);
t
.
subTest
(
runUMFPack
<
Matrix
,
Vector
>
(
N
)
)
;
}
// ------------------------------------------------------------------------------
...
...
@@ -87,10 +115,10 @@ int main(int argc, char** argv) try
{
using
Matrix
=
Dune
::
BCRSMatrix
<
Dune
::
FieldMatrix
<
double
,
2
,
2
>
>
;
using
Vector
=
Dune
::
BlockVector
<
Dune
::
FieldVector
<
double
,
2
>
>
;
runUMFPack
<
Matrix
,
Vector
>
(
N
);
t
.
subTest
(
runUMFPack
<
Matrix
,
Vector
>
(
N
)
)
;
}
return
0
;
return
t
.
exit
()
;
#else // HAVE_SUITESPARSE_UMFPACK
std
::
cerr
<<
"You need SuiteSparse's UMFPack to run this test."
<<
std
::
endl
;
return
77
;
...
...
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