Go to the documentation of this file.
3 #ifndef DUNE_ISTL_PRECONDITIONERS_HH
4 #define DUNE_ISTL_PRECONDITIONERS_HH
13 #include <dune/common/unused.hh>
68 template<
class O,
int c = -1>
70 public Preconditioner<typename O::domain_type, typename O::range_type>
89 : inverse_operator_(inverse_operator)
92 DUNE_THROW(InvalidStateException,
"User supplied solver category does not match that of the supplied iverser operator");
102 inverse_operator_.apply(v, copy, res);
134 template<
class M,
class X,
class Y,
int l=1>
156 : _A_(A), _n(n), _w(w)
166 virtual void pre (X& x, Y& b)
168 DUNE_UNUSED_PARAMETER(x);
169 DUNE_UNUSED_PARAMETER(b);
178 virtual void apply (X& v,
const Y& d)
180 for (
int i=0; i<_n; i++) {
193 DUNE_UNUSED_PARAMETER(x);
224 template<
class M,
class X,
class Y,
int l=1>
246 : _A_(A), _n(n), _w(w)
256 virtual void pre (X& x, Y& b)
258 DUNE_UNUSED_PARAMETER(x);
259 DUNE_UNUSED_PARAMETER(b);
267 virtual void apply (X& v,
const Y& d)
269 this->
template apply<true>(v,d);
280 template<
bool forward>
284 for (
int i=0; i<_n; i++) {
288 for (
int i=0; i<_n; i++) {
300 DUNE_UNUSED_PARAMETER(x);
329 template<
class M,
class X,
class Y,
int l=1>
351 : _A_(A), _n(n), _w(w)
361 virtual void pre (X& x, Y& b)
363 DUNE_UNUSED_PARAMETER(x);
364 DUNE_UNUSED_PARAMETER(b);
372 virtual void apply (X& v,
const Y& d)
374 for (
int i=0; i<_n; i++) {
386 DUNE_UNUSED_PARAMETER(x);
401 scalar_field_type _w;
415 template<
class M,
class X,
class Y,
int l=1>
437 : _A_(A), _n(n), _w(w)
447 virtual void pre (X& x, Y& b)
449 DUNE_UNUSED_PARAMETER(x);
450 DUNE_UNUSED_PARAMETER(b);
458 virtual void apply (X& v,
const Y& d)
460 for (
int i=0; i<_n; i++) {
472 DUNE_UNUSED_PARAMETER(x);
487 scalar_field_type _w;
503 template<
class M,
class X,
class Y,
int l=1>
532 :
SeqILU( A, 0, w, resort )
562 ILU_.reset(
new matrix_type( A.
N(), A.
M(), matrix_type::row_wise) );
580 virtual void pre (X& x, Y& b)
582 DUNE_UNUSED_PARAMETER(x);
583 DUNE_UNUSED_PARAMETER(b);
591 virtual void apply (X& v,
const Y& d)
615 DUNE_UNUSED_PARAMETER(x);
626 std::unique_ptr< matrix_type >
ILU_;
631 std::vector< block_type >
inv_;
651 template<
class M,
class X,
class Y,
int l=1>
684 virtual void pre (X& x, Y& b)
686 DUNE_UNUSED_PARAMETER(x);
687 DUNE_UNUSED_PARAMETER(b);
695 virtual void apply (X& v,
const Y& d)
708 DUNE_UNUSED_PARAMETER(x);
719 scalar_field_type _w;
738 template<
class M,
class X,
class Y,
int l=1>
760 : ILU(A.N(),A.M(),M::row_wise),
772 virtual void pre (X& x, Y& b)
774 DUNE_UNUSED_PARAMETER(x);
775 DUNE_UNUSED_PARAMETER(b);
783 virtual void apply (X& v,
const Y& d)
796 DUNE_UNUSED_PARAMETER(x);
811 scalar_field_type _w;
824 template<
class X,
class Y>
850 virtual void pre (X& x, Y& b)
852 DUNE_UNUSED_PARAMETER(x);
853 DUNE_UNUSED_PARAMETER(b);
861 virtual void apply (X& v,
const Y& d)
874 DUNE_UNUSED_PARAMETER(x);
885 scalar_field_type _w;
899 template<
class M,
class X,
class Y >
927 : decomposition_( A.N(), A.M(),
matrix_type::random ),
931 for(
auto i = A.
begin(), iend = A.
end(); i != iend; ++i )
933 const auto &A_i = *i;
934 const auto ij = A_i.find( i.index() );
935 if( ij != A_i.end() )
936 decomposition_.setrowsize( i.index(), ij.offset()+1 );
938 DUNE_THROW(
ISTLError,
"diagonal entry missing" );
940 decomposition_.endrowsizes();
943 for(
auto i = A.
begin(), iend = A.
end(); i != iend; ++i )
945 const auto &A_i = *i;
946 for(
auto ij = A_i.begin(); ij.index() < i.index() ; ++ij )
947 decomposition_.addindex( i.index(), ij.index() );
948 decomposition_.addindex( i.index(), i.index() );
950 decomposition_.endindices();
954 for(
auto row = decomposition_.begin(), rowend = decomposition_.end(); row != rowend; ++row, ++i )
956 auto ij = i->begin();
957 for(
auto col = row->begin(), colend = row->end();
col != colend; ++
col, ++ij )
966 void pre ( X &x, Y &b )
override
968 DUNE_UNUSED_PARAMETER( x );
969 DUNE_UNUSED_PARAMETER( b );
973 void apply ( X &v,
const Y &d )
override
982 DUNE_UNUSED_PARAMETER( x );
989 matrix_type decomposition_;
990 scalar_field_type relax_;
Turns an InverseOperator into a Preconditioner.
Definition: preconditioners.hh:69
virtual void apply(X &v, const Y &d)
Apply the precondioner.
Definition: preconditioners.hh:861
void bsorf(const M &A, X &x, const Y &b, const K &w)
SOR step.
Definition: gsetc.hh:579
SeqILU0(const M &A, scalar_field_type w)
Constructor.
Definition: preconditioners.hh:671
X::field_type field_type
The field type of the preconditioner.
Definition: preconditioners.hh:339
X domain_type
The domain type of the preconditioner.
Definition: preconditioners.hh:657
matrix_type ::block_type block_type
block type of matrix
Definition: preconditioners.hh:509
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:619
virtual void post(X &x)
Clean up.
Definition: preconditioners.hh:298
Category
Definition: solvercategory.hh:21
virtual void apply(X &v, const Y &d)
Apply the preconditoner.
Definition: preconditioners.hh:591
SeqILDL(const matrix_type &A, scalar_field_type relax=scalar_field_type(1))
constructor
Definition: preconditioners.hh:926
const bool wNotIdentity_
true if w != 1.0
Definition: preconditioners.hh:636
void bildl_decompose(Matrix &A)
compute ILDL decomposition of a symmetric matrix A
Definition: ildl.hh:76
X::field_type field_type
The field type of the preconditioner.
Definition: preconditioners.hh:234
@ sequential
Category for sequential solvers.
Definition: solvercategory.hh:23
void post(X &x) override
Clean up.
Definition: preconditioners.hh:980
SeqSSOR(const M &A, int n, scalar_field_type w)
Constructor.
Definition: preconditioners.hh:155
virtual void pre(X &x, Y &b)
Prepare the preconditioner.
Definition: preconditioners.hh:256
SeqILUn(const M &A, int n, scalar_field_type w)
Constructor.
Definition: preconditioners.hh:759
virtual void post(X &x)
Clean up.
Definition: preconditioners.hh:706
M matrix_type
The matrix type the preconditioner is for.
Definition: preconditioners.hh:419
void pre(X &x, Y &b) override
Prepare the preconditioner.
Definition: preconditioners.hh:966
X::field_type field_type
The field type of the preconditioner.
Definition: preconditioners.hh:661
SimdScalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:663
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:390
virtual void apply(X &v, const Y &d)
Apply the precondioner.
Definition: preconditioners.hh:783
Y range_type
The range type of the preconditioner.
Definition: preconditioners.hh:337
void dbgs(const M &A, X &x, const Y &b, const K &w)
GS step.
Definition: gsetc.hh:567
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:878
Sequential ILU(n) preconditioner.
Definition: preconditioners.hh:739
virtual void post(X &x)
Clean up.
Definition: preconditioners.hh:613
virtual void apply(X &v, const Y &d)
Apply the preconditioner.
Definition: preconditioners.hh:267
SimdScalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:146
void apply(X &v, const Y &d) override
Apply one step of the preconditioner to the system A(v)=d.
Definition: preconditioners.hh:973
RowIterator end()
Get iterator to one beyond last row.
Definition: matrix.hh:615
virtual void apply(X &v, const Y &d)
Apply the preconditioner.
Definition: preconditioners.hh:372
X domain_type
The domain type of the preconditioner.
Definition: preconditioners.hh:140
X domain_type
The domain type of the preconditioner.
Definition: preconditioners.hh:744
X domain_type
The domain type of the preconditioner.
Definition: preconditioners.hh:828
X::field_type field_type
The field type of the preconditioner.
Definition: preconditioners.hh:748
X domain_type
The domain type of the preconditioner.
Definition: preconditioners.hh:511
virtual void apply(X &v, const Y &d)
Apply the preconditioner.
Definition: preconditioners.hh:178
virtual void apply(X &v, const Y &d)
Apply the preconditioner.
Definition: preconditioners.hh:458
virtual void apply(X &v, const Y &d)
Apply the preconditoner.
Definition: preconditioners.hh:695
Abstract base class for all solvers.
Definition: solver.hh:91
Y range_type
The range type of the preconditioner.
Definition: preconditioners.hh:659
virtual void post(X &x)
Clean up.
Definition: preconditioners.hh:384
virtual void post(X &x)
Clean up.
Definition: preconditioners.hh:470
range_type::field_type field_type
The field type of the preconditioner.
Definition: preconditioners.hh:78
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:32
virtual void pre(X &x, Y &b)
Prepare the preconditioner.
Definition: preconditioners.hh:850
SimdScalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:834
virtual void pre(domain_type &, range_type &)
Prepare the preconditioner.
Definition: preconditioners.hh:95
Incomplete LDL decomposition.
void dbjac(const M &A, X &x, const Y &b, const K &w)
Jacobi step.
Definition: gsetc.hh:603
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:307
X::field_type field_type
The field type of the preconditioner.
Definition: preconditioners.hh:516
X::field_type field_type
The field type of the preconditioner.
Definition: preconditioners.hh:832
compile-time parameter for block recursion depth
Definition: gsetc.hh:40
void bilu0_decomposition(M &A)
compute ILU decomposition of A. A is overwritten by its decomposition
Definition: ilu.hh:36
const scalar_field_type w_
The relaxation factor to use.
Definition: preconditioners.hh:634
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:712
Y range_type
The range type of the preconditioner.
Definition: preconditioners.hh:830
std::remove_const_t< M > matrix_type
type of matrix the preconditioner is for
Definition: preconditioners.hh:908
Statistics about the application of an inverse operator.
Definition: solver.hh:40
X::field_type field_type
The field type of the preconditioner.
Definition: preconditioners.hh:425
SimdScalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:236
SimdScalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:427
X domain_type
The domain type of the preconditioner.
Definition: preconditioners.hh:335
sequential ILDL preconditioner
Definition: preconditioners.hh:900
X domain_type
domain type of the preconditioner
Definition: preconditioners.hh:910
SimdScalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:519
virtual void pre(X &x, Y &b)
Prepare the preconditioner.
Definition: preconditioners.hh:684
void bsorb(const M &A, X &x, const Y &b, const K &w)
SSOR step.
Definition: gsetc.hh:591
Define general, extensible interface for inverse operators.
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:476
O::domain_type domain_type
The domain type of the preconditioner.
Definition: preconditioners.hh:74
InverseOperator2Preconditioner(InverseOperator &inverse_operator)
Construct the preconditioner from the solver.
Definition: preconditioners.hh:88
SeqJac(const M &A, int n, scalar_field_type w)
Constructor.
Definition: preconditioners.hh:436
RowIterator begin()
Get iterator to first row.
Definition: matrix.hh:609
std::remove_const< M >::type matrix_type
The matrix type the preconditioner is for.
Definition: preconditioners.hh:655
Sequential SOR preconditioner.
Definition: preconditioners.hh:225
Y range_type
range type of the preconditioner
Definition: preconditioners.hh:912
void bildl_backsolve(const Matrix &A, X &v, const Y &d, bool isLowerTriangular=false)
Definition: ildl.hh:137
size_type M() const
Return the number of columns.
Definition: matrix.hh:695
SeqILU(const M &A, scalar_field_type w, const bool resort=false)
Constructor.
Definition: preconditioners.hh:531
X::field_type field_type
The field type of the preconditioner.
Definition: preconditioners.hh:144
Richardson preconditioner.
Definition: preconditioners.hh:825
X domain_type
The domain type of the preconditioner.
Definition: preconditioners.hh:230
virtual void pre(X &x, Y &b)
Prepare the preconditioner.
Definition: preconditioners.hh:580
SimdScalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:80
static void check(const Matrix &mat)
Check whether the a matrix has diagonal values on blocklevel recursion levels.
Definition: matrixutils.hh:88
void bilu_backsolve(const CRS &lower, const CRS &upper, const std::vector< mblock > &inv, X &v, const Y &d)
LU backsolve with stored inverse in CRS format for lower and upper triangular.
Definition: ilu.hh:374
SimdScalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:916
SeqGS(const M &A, int n, scalar_field_type w)
Constructor.
Definition: preconditioners.hh:350
virtual void post(X &x)
Clean up.
Definition: preconditioners.hh:872
void bilu_decomposition(const M &A, int n, M &ILU)
Definition: ilu.hh:157
Simple iterative methods like Jacobi, Gauss-Seidel, SOR, SSOR, etc. in a generic way.
SimdScalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:750
virtual void post(X &x)
Clean up.
Definition: preconditioners.hh:794
M matrix_type
The matrix type the preconditioner is for.
Definition: preconditioners.hh:228
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:109
SeqSOR(const M &A, int n, scalar_field_type w)
Constructor.
Definition: preconditioners.hh:245
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:800
size_type N() const
Return the number of rows.
Definition: matrix.hh:690
virtual void post(domain_type &)
Clean up.
Definition: preconditioners.hh:105
Sequential ILU0 preconditioner.
Definition: preconditioners.hh:652
virtual void pre(X &x, Y &b)
Prepare the preconditioner.
Definition: preconditioners.hh:166
Definition: allocator.hh:7
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:304
X::field_type field_type
field type of the preconditioner
Definition: preconditioners.hh:914
virtual void post(X &x)
Clean up.
Definition: preconditioners.hh:191
Y range_type
The range type of the preconditioner.
Definition: preconditioners.hh:423
std::remove_const< M >::type matrix_type
The matrix type the preconditioner is for.
Definition: preconditioners.hh:742
void apply(X &v, const Y &d)
Apply the preconditioner in a special direction.
Definition: preconditioners.hh:281
virtual void pre(X &x, Y &b)
Prepare the preconditioner.
Definition: preconditioners.hh:447
The sequential jacobian preconditioner.
Definition: preconditioners.hh:416
SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:986
Some handy generic functions for ISTL matrices.
Sequential SSOR preconditioner.
Definition: preconditioners.hh:135
Col col
Definition: matrixmatrix.hh:349
SimdScalar< field_type > scalar_field_type
scalar type underlying the field_type
Definition: preconditioners.hh:341
CRS lower_
The ILU(n) decomposition of the matrix. As storage a CRS structure is used.
Definition: preconditioners.hh:629
derive error class from the base class in common
Definition: istlexception.hh:16
virtual void pre(X &x, Y &b)
Prepare the preconditioner.
Definition: preconditioners.hh:361
Y range_type
The range type of the preconditioner.
Definition: preconditioners.hh:232
O::range_type range_type
The range type of the preconditioner.
Definition: preconditioners.hh:76
SeqILU(const M &A, int n, scalar_field_type w, const bool resort=false)
Constructor.
Definition: preconditioners.hh:544
ILU::CRS< block_type > CRS
type of ILU storage
Definition: preconditioners.hh:522
Y range_type
The range type of the preconditioner.
Definition: preconditioners.hh:746
Sequential ILU preconditioner.
Definition: preconditioners.hh:504
std::unique_ptr< matrix_type > ILU_
The ILU(n) decomposition of the matrix. As storage a BCRSMatrix is used.
Definition: preconditioners.hh:626
Y range_type
The range type of the preconditioner.
Definition: preconditioners.hh:142
virtual void pre(X &x, Y &b)
Prepare the preconditioner.
Definition: preconditioners.hh:772
void bilu_backsolve(const M &A, X &v, const Y &d)
LU backsolve with stored inverse.
Definition: ilu.hh:97
Base class for matrix free definition of preconditioners.
Definition: preconditioner.hh:30
Richardson(scalar_field_type w=1.0)
Constructor.
Definition: preconditioners.hh:841
std::remove_const< M >::type matrix_type
The matrix type the preconditioner is for.
Definition: preconditioners.hh:507
CRS upper_
Definition: preconditioners.hh:630
X domain_type
The domain type of the preconditioner.
Definition: preconditioners.hh:421
O InverseOperator
type of the wrapped inverse operator
Definition: preconditioners.hh:82
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: preconditioners.hh:197
virtual void apply(domain_type &v, const range_type &d)
Apply one step of the preconditioner to the system A(v)=d.
Definition: preconditioners.hh:98
M matrix_type
The matrix type the preconditioner is for.
Definition: preconditioners.hh:333
Sequential Gauss Seidel preconditioner.
Definition: preconditioners.hh:330
std::vector< block_type > inv_
Definition: preconditioners.hh:631
M matrix_type
The matrix type the preconditioner is for.
Definition: preconditioners.hh:138
Y range_type
The range type of the preconditioner.
Definition: preconditioners.hh:513