Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-fufem
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
fufem
dune-fufem
Commits
0007a32f
Commit
0007a32f
authored
3 months ago
by
Carsten Gräser
Browse files
Options
Downloads
Patches
Plain Diff
[examples] Add convenience functions for creating a Dune::FastAMG preconditioner
parent
c4921b6d
Branches
Branches containing commit
No related tags found
1 merge request
!249
[examples] Add convenience utility for FastAMG preconditioner and use it in Poisson example
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/stokes-taylorhood.cc
+2
-21
2 additions, 21 deletions
examples/stokes-taylorhood.cc
examples/utilities.hh
+49
-0
49 additions, 0 deletions
examples/utilities.hh
with
51 additions
and
21 deletions
examples/stokes-taylorhood.cc
+
2
−
21
View file @
0007a32f
...
...
@@ -67,25 +67,6 @@ using namespace Dune;
#if DUNE_VERSION_GT(DUNE_ISTL, 2, 10)
template
<
class
V
,
class
M
>
auto
makeAMGPreconditioner
(
const
V
&
x
,
const
M
&
m
)
{
using
Operator
=
Dune
::
MatrixAdapter
<
M
,
V
,
V
>
;
using
Criterion
=
Dune
::
Amg
::
SymmetricCriterion
<
M
,
Dune
::
Amg
::
RowSum
>
;
using
AMG
=
Dune
::
Amg
::
FastAMG
<
Operator
,
V
>
;
auto
parameters
=
Dune
::
Amg
::
Parameters
();
parameters
.
setDebugLevel
(
0
);
parameters
.
setNoPreSmoothSteps
(
1
);
parameters
.
setNoPostSmoothSteps
(
1
);
auto
criterion
=
Criterion
();
criterion
.
setDebugLevel
(
0
);
auto
opPtr
=
std
::
make_shared
<
Operator
>
(
m
);
return
AMG
(
opPtr
,
criterion
,
parameters
);
}
template
<
class
V
,
class
...
P
>
class
BlockDiagonalPreconditioner
:
public
Preconditioner
<
V
,
V
>
{
...
...
@@ -355,8 +336,8 @@ int main (int argc, char *argv[]) try
using
namespace
Dune
::
Indices
;
auto
preconditioner
=
BlockDiagonalPreconditioner
(
x
,
makeAMGPreconditioner
(
x
[
_0
],
stiffnessMatrix
[
_0
][
_0
]),
makeAMGPreconditioner
(
x
[
_1
],
pressureMassMatrix
));
makeAMGPreconditioner
(
stiffnessMatrix
[
_0
][
_0
]
,
x
[
_0
]
),
makeAMGPreconditioner
(
pressureMassMatrix
,
x
[
_1
]
));
// Construct the actual iterative solver
MINRESSolver
<
Vector
>
solver
(
...
...
This diff is collapsed.
Click to expand it.
examples/utilities.hh
+
49
−
0
View file @
0007a32f
...
...
@@ -10,6 +10,10 @@
#include
<dune/common/typetraits.hh>
#include
<dune/common/concept.hh>
#if DUNE_VERSION_GT(DUNE_ISTL, 2, 10)
#include
<dune/istl/paamg/fastamg.hh>
#endif
#include
<dune/grid/common/rangegenerators.hh>
#include
<dune/functions/backends/concepts.hh>
...
...
@@ -141,6 +145,51 @@ void incorporateEssentialConstraints(const Basis& basis, Matrix& matrix, Vector&
/**
* \brief Create a FastAMG preconditioner
* \tparam Matrix Type of the matrix the preconditioner should act on.
* \tparam Vector Type of vectors the preconditioner should act on.
* \param matrix The matrix used in the preconditioner
*
* This constructs a Dune::FastAMG preconditioner. With some
* standard arguments that are not defaulted in dune-istl.
*/
template
<
class
Vector
,
class
Matrix
>
auto
makeAMGPreconditioner
(
const
Matrix
&
matrix
)
{
using
Operator
=
Dune
::
MatrixAdapter
<
Matrix
,
Vector
,
Vector
>
;
using
Criterion
=
Dune
::
Amg
::
SymmetricCriterion
<
Matrix
,
Dune
::
Amg
::
RowSum
>
;
using
AMG
=
Dune
::
Amg
::
FastAMG
<
Operator
,
Vector
>
;
auto
parameters
=
Dune
::
Amg
::
Parameters
();
parameters
.
setDebugLevel
(
0
);
parameters
.
setNoPreSmoothSteps
(
1
);
parameters
.
setNoPostSmoothSteps
(
1
);
auto
criterion
=
Criterion
();
criterion
.
setDebugLevel
(
0
);
auto
opPtr
=
std
::
make_shared
<
Operator
>
(
matrix
);
return
AMG
(
opPtr
,
criterion
,
parameters
);
}
/**
* \brief Create a FastAMG preconditioner
* \tparam Matrix Type of the matrix the preconditioner should act on.
* \tparam Vector Type of vectors the preconditioner should act on.
* \param matrix The matrix used in the preconditioner
* \param dummy A dummy vector argument to enable type deduction for the Vector type.
*
* This constructs a Dune::FastAMG preconditioner.
*/
template
<
class
Vector
,
class
Matrix
>
auto
makeAMGPreconditioner
(
const
Matrix
&
matrix
,
const
Vector
&
dummy
)
{
return
makeAMGPreconditioner
<
Vector
>
(
matrix
);
}
// Compute the (i,j)-th cofactor of F
template
<
class
K
,
int
d
>
constexpr
K
cofactor
(
const
Dune
::
FieldMatrix
<
K
,
d
,
d
>&
F
,
std
::
size_t
i
,
std
::
size_t
j
)
...
...
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