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
2e67dc60
Commit
2e67dc60
authored
5 years ago
by
Timo Koch
Browse files
Options
Downloads
Patches
Plain Diff
[test] Add linear solver unit test for istlsolverfactory
parent
59bc45cf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1845
Feature/istl solver factory
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/linear/params.input
+11
-2
11 additions, 2 deletions
test/linear/params.input
test/linear/test_linearsolver.cc
+45
-15
45 additions, 15 deletions
test/linear/test_linearsolver.cc
with
56 additions
and
17 deletions
test/linear/params.input
+
11
−
2
View file @
2e67dc60
TestSolver = CG
ProblemSize = 2
ProblemSize = 2
[CG.LinearSolver]
[LinearSolver]
Verbosity = 1
[AMGCG.LinearSolver]
Type = cgsolver
Type = cgsolver
Preconditioner.Type = amg
Preconditioner.Type = amg
[SSORCG.LinearSolver]
Type = cgsolver
Preconditioner.Type = ssor
[AMGBiCGSTAB.LinearSolver]
Verbosity = 1
This diff is collapsed.
Click to expand it.
test/linear/test_linearsolver.cc
+
45
−
15
View file @
2e67dc60
...
@@ -4,13 +4,8 @@
...
@@ -4,13 +4,8 @@
#include
<iomanip>
#include
<iomanip>
#include
<cmath>
#include
<cmath>
#include
<dumux/common/parameters.hh>
#include
<dumux/discretization/method.hh>
#include
<dumux/linear/linearsolvertraits.hh>
//#include <dumux/linear/istlsolverfactorybackend.hh>
#include
<dumux/linear/amgbackend.hh>
#include
<dune/common/exceptions.hh>
#include
<dune/common/exceptions.hh>
#include
<dune/common/version.hh>
#include
<dune/common/fvector.hh>
#include
<dune/common/fvector.hh>
#include
<dune/common/fmatrix.hh>
#include
<dune/common/fmatrix.hh>
...
@@ -23,6 +18,15 @@
...
@@ -23,6 +18,15 @@
#include
<dune/istl/test/laplacian.hh>
#include
<dune/istl/test/laplacian.hh>
#include
<dune/istl/paamg/test/anisotropic.hh>
#include
<dune/istl/paamg/test/anisotropic.hh>
#include
<dumux/common/parameters.hh>
#include
<dumux/discretization/method.hh>
#include
<dumux/linear/linearsolvertraits.hh>
#if DUNE_VERSION_NEWER_REV(DUNE_ISTL,2,7,1)
#include
<dumux/linear/istlsolverfactorybackend.hh>
#endif
#include
<dumux/linear/amgbackend.hh>
namespace
Dumux
::
Test
{
namespace
Dumux
::
Test
{
struct
MockGridGeometry
struct
MockGridGeometry
...
@@ -33,6 +37,22 @@ struct MockGridGeometry
...
@@ -33,6 +37,22 @@ struct MockGridGeometry
static
constexpr
auto
discMethod
=
DiscretizationMethod
::
box
;
static
constexpr
auto
discMethod
=
DiscretizationMethod
::
box
;
};
};
#if DUNE_VERSION_NEWER_REV(DUNE_ISTL,2,7,1)
template
<
class
M
,
class
X
,
class
V
>
void
solveWithFactory
(
M
&
A
,
X
&
x
,
V
&
b
,
const
std
::
string
&
paramGroup
)
{
std
::
cout
<<
std
::
endl
;
using
LinearSolver
=
IstlSolverFactoryBackend
<
LinearSolverTraits
<
Test
::
MockGridGeometry
>>
;
LinearSolver
solver
(
paramGroup
);
std
::
cout
<<
"Solving Laplace problem with "
<<
solver
.
name
()
<<
"
\n
"
;
solver
.
solve
(
A
,
x
,
b
);
if
(
!
solver
.
result
().
converged
)
DUNE_THROW
(
Dune
::
Exception
,
solver
.
name
()
<<
" did not converge!"
);
}
#endif
}
// end namespace Dumux::Test
}
// end namespace Dumux::Test
int
main
(
int
argc
,
char
*
argv
[])
try
int
main
(
int
argc
,
char
*
argv
[])
try
...
@@ -53,15 +73,25 @@ int main(int argc, char* argv[]) try
...
@@ -53,15 +73,25 @@ int main(int argc, char* argv[]) try
Vector
x
(
A
.
N
());
Vector
b
(
A
.
M
());
Vector
x
(
A
.
N
());
Vector
b
(
A
.
M
());
x
=
0
;
b
=
1
;
x
=
0
;
b
=
1
;
using
LinearSolverTraits
=
Dumux
::
LinearSolverTraits
<
Test
::
MockGridGeometry
>
;
// AMGBiCGSTABBackend
using
LinearSolver
=
AMGBiCGSTABBackend
<
LinearSolverTraits
>
;
{
std
::
cout
<<
std
::
endl
;
const
auto
testSolverName
=
getParam
<
std
::
string
>
(
"TestSolver"
);
LinearSolver
solver
(
testSolverName
);
const
auto
testSolverName
=
"AMGBiCGSTAB"
;
using
LinearSolver
=
AMGBiCGSTABBackend
<
LinearSolverTraits
<
Test
::
MockGridGeometry
>>
;
solver
.
solve
(
A
,
x
,
b
);
LinearSolver
solver
(
testSolverName
);
if
(
!
solver
.
result
().
converged
)
DUNE_THROW
(
Dune
::
Exception
,
testSolverName
<<
" did not converge!"
);
std
::
cout
<<
"Solving Laplace problem with "
<<
solver
.
name
()
<<
"
\n
"
;
solver
.
solve
(
A
,
x
,
b
);
if
(
!
solver
.
result
().
converged
)
DUNE_THROW
(
Dune
::
Exception
,
testSolverName
<<
" did not converge!"
);
}
#if DUNE_VERSION_NEWER_REV(DUNE_ISTL,2,7,1)
// IstlSolverFactoryBackend
Test
::
solveWithFactory
(
A
,
x
,
b
,
"AMGCG"
);
Test
::
solveWithFactory
(
A
,
x
,
b
,
"SSORCG"
);
#endif
return
0
;
return
0
;
}
}
...
...
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