5 #ifndef DUNE_ISTL_PRECONDITIONERS_HH 6 #define DUNE_ISTL_PRECONDITIONERS_HH 15 #include <dune/common/simd/simd.hh> 16 #include <dune/common/parametertree.hh> 73 template<
class O,
int c = -1>
75 public Preconditioner<typename O::domain_type, typename O::range_type>
96 : inverse_operator_(inverse_operator)
99 DUNE_THROW(InvalidStateException,
"User-supplied solver category does not match that of the given inverse operator");
109 inverse_operator_.apply(v, copy, res);
141 template<
class M,
class X,
class Y,
int l=1>
165 : _A_(A), _n(n), _w(w)
184 :
SeqSSOR(A->getmat(), configuration)
200 SeqSSOR (
const M& A,
const ParameterTree& configuration)
209 void pre ([[maybe_unused]] X& x, [[maybe_unused]] Y& b)
override 217 void apply (X& v,
const Y& d)
override 219 for (
int i=0; i<_n; i++) {
230 void post ([[maybe_unused]] X& x)
override 261 template<
class M,
class X,
class Y,
int l=1>
285 : _A_(A), _n(n), _w(w)
304 :
SeqSOR(A->getmat(), configuration)
320 SeqSOR (
const M& A,
const ParameterTree& configuration)
329 void pre ([[maybe_unused]] X& x, [[maybe_unused]] Y& b)
override 337 void apply (X& v,
const Y& d)
override 339 this->
template apply<true>(v,d);
350 template<
bool forward>
354 for (
int i=0; i<_n; i++) {
358 for (
int i=0; i<_n; i++) {
368 void post ([[maybe_unused]] X& x)
override 398 template<
class M,
class X,
class Y,
int l=1>
412 template<
class M,
class X,
class Y,
int l=1>
436 : _A_(A), _n(n), _w(w)
455 :
SeqJac(A->getmat(), configuration)
471 SeqJac (
const M& A,
const ParameterTree& configuration)
480 void pre ([[maybe_unused]] X& x, [[maybe_unused]] Y& b)
override 488 void apply (X& v,
const Y& d)
override 490 for (
int i=0; i<_n; i++) {
500 void post ([[maybe_unused]] X& x)
override 562 template <
class M,
class X,
class Y,
int l = 1>
595 Dinv_.resize(_A_.N());
613 :
SeqDILU(A->getmat(), configuration)
629 SeqDILU(
const M &A,
const ParameterTree &config)
639 void pre([[maybe_unused]] X &x, [[maybe_unused]] Y &b)
override 648 void apply(X &v,
const Y &d)
override 664 void post([[maybe_unused]] X &x)
override 696 template<
class M,
class X,
class Y,
int l=1>
727 :
SeqILU( A, 0, w, resort )
746 :
SeqILU(A->getmat(), configuration)
763 SeqILU(
const M& A,
const ParameterTree& config)
766 config.
get(
"resort", false))
813 void pre ([[maybe_unused]] X& x, [[maybe_unused]] Y& b)
override 821 void apply (X& v,
const Y& d)
override 843 void post ([[maybe_unused]] X& x)
override 854 std::unique_ptr< matrix_type >
ILU_;
859 std::vector< block_type, typename matrix_type::allocator_type >
inv_;
877 template<
class X,
class Y>
920 void pre ([[maybe_unused]] X& x, [[maybe_unused]] Y& b)
override 928 void apply (X& v,
const Y& d)
override 939 void post ([[maybe_unused]] X& x)
override 953 using OpTraits = std::decay_t<decltype(opTraits)>;
954 using D =
typename OpTraits::domain_type;
955 using R =
typename OpTraits::range_type;
956 return std::make_shared<Richardson<D,R>>(config);
970 template<
class M,
class X,
class Y >
1004 :
SeqILDL(A->getmat(), configuration)
1032 : decomposition_( A.N(), A.M(),
matrix_type::random ),
1036 for(
auto i = A.begin(), iend = A.end(); i != iend; ++i )
1038 const auto &A_i = *i;
1039 const auto ij = A_i.find( i.index() );
1040 if( ij != A_i.end() )
1041 decomposition_.setrowsize( i.index(), ij.offset()+1 );
1043 DUNE_THROW(
ISTLError,
"diagonal entry missing" );
1045 decomposition_.endrowsizes();
1048 for(
auto i = A.begin(), iend = A.end(); i != iend; ++i )
1050 const auto &A_i = *i;
1051 for(
auto ij = A_i.begin(); ij.index() < i.index() ; ++ij )
1052 decomposition_.addindex( i.index(), ij.index() );
1053 decomposition_.addindex( i.index(), i.index() );
1055 decomposition_.endindices();
1059 for(
auto row = decomposition_.begin(), rowend = decomposition_.end(); row != rowend; ++row, ++i )
1061 auto ij = i->begin();
1062 for(
auto col = row->begin(), colend = row->end();
col != colend; ++
col, ++ij )
1071 void pre ([[maybe_unused]] X &x, [[maybe_unused]] Y &b)
override 1075 void apply ( X &v,
const Y &d )
override 1082 void post ([[maybe_unused]] X &x)
override SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:669
Sequential ILU preconditioner.
Definition: preconditioners.hh:697
void bildl_backsolve(const Matrix &A, X &v, const Y &d, bool isLowerTriangular=false)
Definition: ildl.hh:158
Sequential SOR preconditioner.
Definition: preconditioners.hh:262
Simple iterative methods like Jacobi, Gauss-Seidel, SOR, SSOR, etc. in a generic way.
SeqILDL(const std::shared_ptr< const AssembledLinearOperator< M, X, Y >> &A, const ParameterTree &configuration)
Constructor.
Definition: preconditioners.hh:1003
X::field_type field_type
The field type of the preconditioner.
Definition: preconditioners.hh:885
The diagonal incomplete LU factorization kernels.
derive error class from the base class in common
Definition: istlexception.hh:19
Simd::Scalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:712
SeqILU(const M &A, real_field_type w, const bool resort=false)
Constructor.
Definition: preconditioners.hh:726
void apply(X &v, const Y &d) override
Apply the preconditioner.
Definition: preconditioners.hh:488
std::remove_const< M >::type matrix_type
The matrix type the preconditioner is for.
Definition: preconditioners.hh:700
CRS upper_
Definition: preconditioners.hh:858
void convertToCRS(const M &A, CRS &lower, CRS &upper, InvVector &inv)
convert ILU decomposition into CRS format for lower and upper triangular and inverse.
Definition: ilu.hh:316
void post([[maybe_unused]] X &x) override
Clean up.
Definition: preconditioners.hh:368
X domain_type
The domain type of the preconditioner.
Definition: preconditioners.hh:267
X domain_type
The domain type of the preconditioner.
Definition: preconditioners.hh:147
SeqILU(const std::shared_ptr< const AssembledLinearOperator< M, X, Y >> &A, const ParameterTree &configuration)
Constructor.
Definition: preconditioners.hh:745
std::vector< block_type > Dinv_
Definition: preconditioners.hh:675
Y range_type
The range type of the preconditioner.
Definition: preconditioners.hh:420
X::field_type field_type
The field type of the preconditioner.
Definition: preconditioner.hh:40
Incomplete LDL decomposition.
void pre([[maybe_unused]] X &x, [[maybe_unused]] Y &b) override
Prepare the preconditioner.
Definition: preconditioners.hh:639
O::range_type range_type
The range type of the preconditioner.
Definition: preconditioners.hh:81
SeqILDL(const matrix_type &A, const ParameterTree &config)
Constructor.
Definition: preconditioners.hh:1019
M matrix_type
The matrix type the preconditioner is for.
Definition: preconditioners.hh:265
compile-time parameter for block recursion depth
Definition: gsetc.hh:45
SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:116
The incomplete LU factorization kernels.
Statistics about the application of an inverse operator.
Definition: solver.hh:49
Y range_type
range type of the preconditioner
Definition: preconditioners.hh:983
Base class for matrix free definition of preconditioners.
Definition: preconditioner.hh:33
SeqJac(const M &A, int n, real_field_type w)
Constructor.
Definition: preconditioners.hh:435
static Category category(const OP &op, decltype(op.category()) *=nullptr)
Helperfunction to extract the solver category either from an enum, or from the newly introduced virtu...
Definition: solvercategory.hh:34
X::field_type field_type
The field type of the preconditioner.
Definition: preconditioners.hh:422
O InverseOperator
type of the wrapped inverse operator
Definition: preconditioners.hh:89
void apply(domain_type &v, const range_type &d) override
Apply one step of the preconditioner to the system A(v)=d.
Definition: preconditioners.hh:105
Col col
Definition: matrixmatrix.hh:351
Category for sequential solvers.
Definition: solvercategory.hh:25
FieldTraits< scalar_field_type >::real_type real_field_type
real scalar type underlying the field_type
Definition: preconditioners.hh:87
SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:504
FieldTraits< scalar_field_type >::real_type real_field_type
real scalar type underlying the field_type
Definition: preconditioners.hh:426
X::field_type field_type
The field type of the preconditioner.
Definition: preconditioners.hh:709
void post([[maybe_unused]] X &x) override
Clean up.
Definition: preconditioners.hh:1082
const real_field_type w_
The relaxation factor to use.
Definition: preconditioners.hh:862
void dbjac(const M &A, X &x, const Y &b, const K &w)
Jacobi step.
Definition: gsetc.hh:658
Y range_type
The range type of the preconditioner.
Definition: preconditioner.hh:38
SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:1086
void pre([[maybe_unused]] X &x, [[maybe_unused]] Y &b) override
Prepare the preconditioner.
Definition: preconditioners.hh:480
Simd::Scalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:153
X::field_type field_type
field type of the preconditioner
Definition: preconditioners.hh:985
Sequential DILU preconditioner.
Definition: preconditioners.hh:563
const M & _A_
The matrix we operate on.
Definition: preconditioners.hh:677
void post([[maybe_unused]] X &x) override
Clean up.
Definition: preconditioners.hh:500
void pre([[maybe_unused]] X &x, [[maybe_unused]] Y &b) override
Prepare the preconditioner.
Definition: preconditioners.hh:920
Sequential SSOR preconditioner.
Definition: preconditioners.hh:142
SeqILU(const M &A, int n, real_field_type w, const bool resort=false)
Constructor.
Definition: preconditioners.hh:777
FieldTraits< scalar_field_type >::real_type real_field_type
real scalar type underlying the field_type
Definition: preconditioners.hh:889
FieldTraits< scalar_field_type >::real_type real_field_type
real scalar type underlying the field_type
Definition: preconditioners.hh:155
SeqSOR(const M &A, const ParameterTree &configuration)
Constructor.
Definition: preconditioners.hh:320
Simd::Scalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:424
Simd::Scalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:887
Simd::Scalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:579
Y range_type
The range type of the preconditioner.
Definition: preconditioners.hh:706
Richardson preconditioner.
Definition: preconditioners.hh:878
void bsorb(const M &A, X &x, const Y &b, const K &w)
SSOR step.
Definition: gsetc.hh:646
CRS lower_
The ILU(n) decomposition of the matrix. As storage a CRS structure is used.
Definition: preconditioners.hh:857
SeqSSOR(const std::shared_ptr< const AssembledLinearOperator< M, X, Y >> &A, const ParameterTree &configuration)
Constructor.
Definition: preconditioners.hh:183
void blockILU0Decomposition(M &A)
compute ILU decomposition of A. A is overwritten by its decomposition
Definition: ilu.hh:35
Simd::Scalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:273
Y range_type
The range type of the preconditioner.
Definition: preconditioners.hh:269
FieldTraits< scalar_field_type >::real_type real_field_type
real scalar type underlying the field_type
Definition: preconditioners.hh:989
const real_field_type _w
The relaxation factor to use.
Definition: preconditioners.hh:679
The sequential jacobian preconditioner.
Definition: preconditioners.hh:413
static void check([[maybe_unused]] const Matrix &mat)
Check whether the a matrix has diagonal values on blocklevel recursion levels.
Definition: matrixutils.hh:53
void blockDILUBacksolve(const M &A, const std::vector< typename M::block_type > Dinv_, X &v, const Y &d)
Definition: dilu.hh:112
void blockDILUDecomposition(M &A, std::vector< typename M::block_type > &Dinv_)
Definition: dilu.hh:52
std::unique_ptr< matrix_type > ILU_
The ILU(n) decomposition of the matrix. As storage a BCRSMatrix is used.
Definition: preconditioners.hh:854
SeqDILU(const std::shared_ptr< const AssembledLinearOperator< M, X, Y >> &A, const ParameterTree &configuration)
Constructor.
Definition: preconditioners.hh:612
const bool wNotIdentity_
true if w != 1.0
Definition: preconditioners.hh:864
X domain_type
The domain type of the preconditioner.
Definition: preconditioners.hh:881
void apply(X &v, const Y &d) override
Apply the preconditioner.
Definition: preconditioners.hh:648
void apply(X &v, const Y &d) override
Apply the precondioner.
Definition: preconditioners.hh:928
void post([[maybe_unused]] X &x) override
Clean up.
Definition: preconditioners.hh:843
SeqSOR(const std::shared_ptr< const AssembledLinearOperator< M, X, Y >> &A, const ParameterTree &configuration)
Constructor.
Definition: preconditioners.hh:303
Y range_type
The range type of the preconditioner.
Definition: preconditioners.hh:883
M matrix_type
The matrix type the preconditioner is for.
Definition: preconditioners.hh:416
const bool wNotIdentity_
true if w != 1.0
Definition: preconditioners.hh:681
SeqSOR(const M &A, int n, real_field_type w)
Constructor.
Definition: preconditioners.hh:284
SeqSSOR(const M &A, int n, real_field_type w)
Constructor.
Definition: preconditioners.hh:164
typename FieldTraits< scalar_field_type >::real_type real_field_type
real scalar type underlying the field_type
Definition: preconditioners.hh:581
DUNE_REGISTER_PRECONDITIONER("amg", AMGCreator())
void apply(X &v, const Y &d) override
Apply one step of the preconditioner to the system A(v)=d.
Definition: preconditioners.hh:1075
Y range_type
The range type of the preconditioner.
Definition: preconditioners.hh:149
SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:943
sequential ILDL preconditioner
Definition: preconditioners.hh:971
ILU::CRS< block_type, typename M::allocator_type > CRS
type of ILU storage
Definition: preconditioners.hh:717
X::field_type field_type
The field type of the preconditioner.
Definition: preconditioners.hh:151
void post([[maybe_unused]] X &x) override
Clean up.
Definition: preconditioners.hh:664
SeqJac(const M &A, const ParameterTree &configuration)
Constructor.
Definition: preconditioners.hh:471
FieldTraits< scalar_field_type >::real_type real_field_type
real scalar type underlying the field_type
Definition: preconditioners.hh:275
void pre([[maybe_unused]] X &x, [[maybe_unused]] Y &b) override
Prepare the preconditioner.
Definition: preconditioners.hh:209
M matrix_type
The matrix type the preconditioner is for.
Definition: preconditioners.hh:145
SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:847
M matrix_type
The matrix type the preconditioner is for.
Definition: preconditioners.hh:567
void pre([[maybe_unused]] X &x, [[maybe_unused]] Y &b) override
Prepare the preconditioner.
Definition: preconditioners.hh:813
void apply(X &v, const Y &d)
Apply the preconditioner in a special direction.
Definition: preconditioners.hh:351
void post([[maybe_unused]] X &x) override
Clean up.
Definition: preconditioners.hh:939
void pre([[maybe_unused]] domain_type &, [[maybe_unused]] range_type &) override
Definition: preconditioners.hh:102
void post([[maybe_unused]] domain_type &) override
Definition: preconditioners.hh:112
void pre([[maybe_unused]] X &x, [[maybe_unused]] Y &b) override
Prepare the preconditioner.
Definition: preconditioners.hh:1071
X domain_type
The domain type of the preconditioner.
Definition: preconditioner.hh:36
SeqDILU(const M &A, real_field_type w)
Constructor.
Definition: preconditioners.hh:589
SeqILDL(const matrix_type &A, real_field_type relax=real_field_type(1))
constructor
Definition: preconditioners.hh:1031
std::vector< block_type, typename matrix_type::allocator_type > inv_
Definition: preconditioners.hh:859
X domain_type
The domain type of the preconditioner.
Definition: preconditioners.hh:704
typename matrix_type::block_type block_type
block type of matrix
Definition: preconditioners.hh:569
void apply(X &v, const Y &d) override
Apply the preconditioner.
Definition: preconditioners.hh:217
Category
Definition: solvercategory.hh:23
SeqSSOR(const M &A, const ParameterTree &configuration)
Constructor.
Definition: preconditioners.hh:200
Some handy generic functions for ISTL matrices.
void apply(X &v, const Y &d) override
Apply the preconditioner.
Definition: preconditioners.hh:337
O::domain_type domain_type
The domain type of the preconditioner.
Definition: preconditioners.hh:79
void bildl_decompose(Matrix &A)
compute ILDL decomposition of a symmetric matrix A
Definition: ildl.hh:90
Richardson(const ParameterTree &configuration)
Constructor.
Definition: preconditioners.hh:911
SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:234
Definition: allocator.hh:11
InverseOperator2Preconditioner(InverseOperator &inverse_operator)
Construct the preconditioner from the solver.
Definition: preconditioners.hh:95
void post([[maybe_unused]] X &x) override
Clean up.
Definition: preconditioners.hh:230
Simd::Scalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:85
void blockILUDecomposition(const M &A, int n, M &ILU)
Definition: ilu.hh:176
SeqILU(const M &A, const ParameterTree &config)
Constructor.
Definition: preconditioners.hh:763
A linear operator exporting itself in matrix form.
Definition: operators.hh:110
std::remove_const_t< M > matrix_type
type of matrix the preconditioner is for
Definition: preconditioners.hh:979
Abstract base class for all solvers.
Definition: solver.hh:101
Turns an InverseOperator into a Preconditioner.
Definition: preconditioners.hh:74
FieldTraits< scalar_field_type >::real_type real_field_type
real scalar type underlying the field_type
Definition: preconditioners.hh:714
Define general, extensible interface for inverse operators.
SeqDILU(const M &A, const ParameterTree &config)
Constructor.
Definition: preconditioners.hh:629
void pre([[maybe_unused]] X &x, [[maybe_unused]] Y &b) override
Prepare the preconditioner.
Definition: preconditioners.hh:329
Richardson(real_field_type w=1.0)
Constructor.
Definition: preconditioners.hh:896
Simd::Scalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:987
PropertyMapTypeSelector< Amg::VertexVisitedTag, Amg::PropertiesGraph< G, Amg::VertexProperties, EP, VM, EM > >::Type get([[maybe_unused]] const Amg::VertexVisitedTag &tag, Amg::PropertiesGraph< G, Amg::VertexProperties, EP, VM, EM > &graph)
Definition: dependency.hh:293
range_type::field_type field_type
The field type of the preconditioner.
Definition: preconditioners.hh:83
matrix_type ::block_type block_type
block type of matrix
Definition: preconditioners.hh:702
void bsorf(const M &A, X &x, const Y &b, const K &w)
SOR step.
Definition: gsetc.hh:634
X domain_type
The domain type of the preconditioner.
Definition: preconditioners.hh:418
SeqJac(const std::shared_ptr< const AssembledLinearOperator< M, X, Y >> &A, const ParameterTree &configuration)
Constructor.
Definition: preconditioners.hh:454
SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:372
void blockILUBacksolve(const M &A, X &v, const Y &d)
LU backsolve with stored inverse.
Definition: ilu.hh:103
void apply(X &v, const Y &d) override
Apply the preconditioner.
Definition: preconditioners.hh:821
X::field_type field_type
The field type of the preconditioner.
Definition: preconditioners.hh:271
X domain_type
domain type of the preconditioner
Definition: preconditioners.hh:981