Go to the documentation of this file.
3 #ifndef DUNE_PDELAB_BACKEND_ISTL_SEQISTLSOLVERBACKEND_HH
4 #define DUNE_PDELAB_BACKEND_ISTL_SEQISTLSOLVERBACKEND_HH
6 #include <dune/common/deprecated.hh>
7 #include <dune/common/parallel/mpihelper.hh>
9 #include <dune/istl/owneroverlapcopy.hh>
10 #include <dune/istl/solvercategory.hh>
11 #include <dune/istl/operators.hh>
12 #include <dune/istl/solvers.hh>
13 #include <dune/istl/preconditioners.hh>
14 #include <dune/istl/scalarproducts.hh>
15 #include <dune/istl/paamg/amg.hh>
16 #include <dune/istl/paamg/pinfo.hh>
17 #include <dune/istl/io.hh>
18 #include <dune/istl/superlu.hh>
19 #include <dune/istl/umfpack.hh>
34 template<
typename X,
typename Y,
typename GOS>
46 virtual void apply (
const X& x, Y& y)
const override
49 gos.jacobian_apply(x,y);
56 gos.jacobian_apply(x,temp);
60 SolverCategory::Category
category()
const override
62 return SolverCategory::sequential;
74 template<
template<
class,
class,
class,
int>
class Preconditioner,
75 template<
class>
class Solver>
86 : maxiter(maxiter_), verbose(verbose_)
98 template<
class M,
class V,
class W>
99 void apply(M& A, V& z, W& r,
typename Dune::template FieldTraits<typename W::ElementType >::real_type reduction)
104 Dune::MatrixAdapter<Native<M>,
106 Native<W>> opa(
native(A));
107 Preconditioner<Native<M>,
110 1> prec(
native(A), 3, 1.0);
111 Solver<Native<V>> solver(opa, prec, reduction, maxiter, verbose);
112 Dune::InverseOperatorResult stat;
126 template<
template<
typename>
class Solver>
137 : maxiter(maxiter_), verbose(verbose_)
146 template<
class M,
class V,
class W>
147 void apply(M& A, V& z, W& r,
typename Dune::template FieldTraits<typename W::ElementType >::real_type reduction)
151 Dune::MatrixAdapter<Native<M>,
153 Native<W>> opa(
native(A));
154 Dune::SeqILU0<Native<M>,
158 Solver<Native<V>> solver(opa, ilu0, reduction, maxiter, verbose);
159 Dune::InverseOperatorResult stat;
172 template<
template<
typename>
class Solver>
184 : n_(n), w_(
w), maxiter(maxiter_), verbose(verbose_)
193 template<
class M,
class V,
class W>
194 void apply(M& A, V& z, W& r,
typename Dune::template FieldTraits<typename W::ElementType >::real_type reduction)
198 Dune::MatrixAdapter<Native<M>,
202 Dune::SeqILUn<Native<M>,
205 > ilun(
native(A), n_, w_);
206 Solver<Native<V>> solver(opa, ilun, reduction, maxiter, verbose);
207 Dune::InverseOperatorResult stat;
395 #if HAVE_SUPERLU || DOXYGEN
428 template<
class M,
class V,
class W>
429 void apply(M& A, V& z, W& r,
typename Dune::template FieldTraits<typename W::ElementType >::real_type reduction)
433 using ISTLM = Native<M>;
434 Dune::SuperLU<ISTLM> solver(
native(A), verbose);
435 Dune::InverseOperatorResult stat;
447 #endif // HAVE_SUPERLU || DOXYGEN
449 #if HAVE_SUITESPARSE_UMFPACK || DOXYGEN
482 template<
class M,
class V,
class W>
483 void apply(M& A, V& z, W& r,
typename Dune::template FieldTraits<typename W::ElementType >::real_type reduction)
487 Dune::UMFPack<ISTLM> solver(
native(A), verbose);
488 Dune::InverseOperatorResult stat;
500 #endif // HAVE_SUITESPARSE_UMFPACK || DOXYGEN
519 template<
class M,
class V,
class W>
520 void apply(M& A, V& z, W& r,
typename Dune::template FieldTraits<typename W::ElementType >::real_type reduction)
523 Dune::SeqJac<Native<M>,
563 template<
class GO,
template<
class,
class,
class,
int>
class Preconditioner,
template<
class>
class Solver,
564 bool skipBlocksizeCheck =
false>
567 typedef typename GO::Traits::TrialGridFunctionSpace GFS;
568 typedef typename GO::Traits::Jacobian M;
570 typedef typename GO::Traits::Domain V;
572 typedef Preconditioner<MatrixType,VectorType,VectorType,1> Smoother;
573 typedef Dune::MatrixAdapter<MatrixType,VectorType,VectorType> Operator;
574 typedef typename Dune::Amg::SmootherTraits<Smoother>::Arguments SmootherArgs;
575 typedef Dune::Amg::AMG<Operator,VectorType,Smoother> AMG;
576 typedef Dune::Amg::Parameters Parameters;
580 bool reuse_=
false,
bool usesuperlu_=
true)
581 : maxiter(maxiter_), params(15,2000), verbose(verbose_),
582 reuse(reuse_), firstapply(true), usesuperlu(usesuperlu_)
584 params.setDefaultValuesIsotropic(GFS::Traits::GridViewType::Traits::Grid::dimension);
585 params.setDebugLevel(verbose_);
587 if (usesuperlu ==
true)
589 std::cout <<
"WARNING: You are using AMG without SuperLU!"
590 <<
" Please consider installing SuperLU,"
591 <<
" or set the usesuperlu flag to false"
592 <<
" to suppress this warning." << std::endl;
622 typename V::ElementType
norm (
const V& v)
const
634 void apply(M& A, V& z, V& r,
typename Dune::template FieldTraits<typename V::ElementType >::real_type reduction)
638 typedef Dune::Amg::CoarsenCriterion<Dune::Amg::SymmetricCriterion<MatrixType,
639 Dune::Amg::FirstDiagonal> > Criterion;
640 SmootherArgs smootherArgs;
641 smootherArgs.iterations = 1;
642 smootherArgs.relaxationFactor = 1;
644 Criterion criterion(params);
646 if (reuse==
false || firstapply==
true){
647 oop.reset(
new Operator(mat));
648 amg.reset(
new AMG(*oop, criterion, smootherArgs));
650 stats.
tsetup = watch.elapsed();
651 stats.
levels = amg->maxlevels();
655 Dune::InverseOperatorResult stat;
657 Solver<VectorType> solver(*oop,*amg,reduction,maxiter,verbose);
659 stats.
tsolve= watch.elapsed();
684 std::shared_ptr<Operator> oop;
685 std::shared_ptr<AMG> amg;
712 bool reuse_=
false,
bool usesuperlu_=
true)
714 (maxiter_, verbose_, reuse_, usesuperlu_)
738 bool reuse_=
false,
bool usesuperlu_=
true)
740 (maxiter_, verbose_, reuse_, usesuperlu_)
764 bool reuse_=
false,
bool usesuperlu_=
true)
766 (maxiter_, verbose_, reuse_, usesuperlu_)
790 bool reuse_=
false,
bool usesuperlu_=
true)
792 (maxiter_, verbose_, reuse_, usesuperlu_)
816 bool reuse_=
false,
bool usesuperlu_=
true)
818 (maxiter_, verbose_, reuse_, usesuperlu_)
839 : restart(restart_), maxiter(maxiter_), verbose(verbose_)
849 template<
class M,
class V,
class W>
850 void apply(M& A, V& z, W& r,
typename Dune::template FieldTraits<typename W::ElementType>::real_type reduction)
864 Dune::RestartedGMResSolver<Native<V>> solver(opa,ilu0,reduction,restart,maxiter,verbose);
865 Dune::InverseOperatorResult stat;
875 int restart, maxiter, verbose;
884 #endif // DUNE_PDELAB_BACKEND_ISTL_SEQISTLSOLVERBACKEND_HH
ISTLBackend_SEQ_CG_ILU0(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:304
OnTheFlyOperator(GOS &gos_)
Definition: seqistlsolverbackend.hh:42
RFType reduction
Definition: solver.hh:35
Sequential conjugate gradient solver preconditioned with AMG smoothed by SSOR.
Definition: seqistlsolverbackend.hh:698
int iterations
The number of iterations performed until convergence was reached.
Definition: seqistlsolverbackend.hh:558
void setReuse(bool reuse_)
Set whether the AMG should be reused again during call to apply().
Definition: seqistlsolverbackend.hh:607
Solver to be used for explicit time-steppers with (block-)diagonal mass matrix.
Definition: seqistlsolverbackend.hh:503
bool getReuse() const
Return whether the AMG is reused during call to apply()
Definition: seqistlsolverbackend.hh:613
int levels
the number of levels in the AMG hierarchy.
Definition: seqistlsolverbackend.hh:552
void apply(M &A, V &z, W &r, typename Dune::template FieldTraits< typename W::ElementType >::real_type reduction)
solve the given linear system
Definition: seqistlsolverbackend.hh:850
Backend for sequential BiCGSTAB solver with Jacobi preconditioner.
Definition: seqistlsolverbackend.hh:245
Solver backend using SuperLU as a direct solver.
Definition: seqistlsolverbackend.hh:399
ISTLBackend_SEQ_GMRES_ILU0(int restart_=200, int maxiter_=5000, int verbose_=1)
make linear solver object
Definition: seqistlsolverbackend.hh:838
Backend for sequential conjugate gradient solver with SSOR preconditioner.
Definition: seqistlsolverbackend.hh:348
Definition: seqistlsolverbackend.hh:565
double tsolve
The time spent in solving the system (without building the hierarchy.
Definition: seqistlsolverbackend.hh:554
std::enable_if< std::is_base_of< impl::WrapperBase, T >::value, Native< T > & >::type native(T &t)
Definition: backend/interface.hh:192
ISTLBackend_SEQ_LS_AMG_SOR(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Constructor.
Definition: seqistlsolverbackend.hh:815
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
ISTLBackend_SEQ_BCGS_ILU0(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:287
ISTLBackend_SEQ_LOOP_Jac(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:237
Definition: seqistlsolverbackend.hh:35
ISTLBackend_SEQ_CG_SSOR(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:357
Sequential BiCGStab solver with ILU0 preconditioner.
Definition: seqistlsolverbackend.hh:310
Y range_type
Definition: seqistlsolverbackend.hh:39
double elapsed
Definition: solver.hh:34
virtual void apply(const X &x, Y &y) const override
Definition: seqistlsolverbackend.hh:46
RFType conv_rate
Definition: solver.hh:36
ISTLBackend_SEQ_ExplicitDiagonal()
make a linear solver object
Definition: seqistlsolverbackend.hh:509
Backend for conjugate gradient solver with Jacobi preconditioner.
Definition: seqistlsolverbackend.hh:382
Sequential BiCGStab solver preconditioned with AMG smoothed by SSOR.
Definition: seqistlsolverbackend.hh:724
Definition: seqistlsolverbackend.hh:127
ISTLBackend_SEQ_BCGS_ILUn(int n_, double w_=1.0, unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:322
Backend for sequential conjugate gradient solver with ILU0 preconditioner.
Definition: seqistlsolverbackend.hh:295
void apply(M &A, V &z, V &r, typename Dune::template FieldTraits< typename V::ElementType >::real_type reduction)
solve the given linear system
Definition: seqistlsolverbackend.hh:634
void apply(M &A, V &z, W &r, typename Dune::template FieldTraits< typename W::ElementType >::real_type reduction)
solve the given linear system
Definition: seqistlsolverbackend.hh:483
ISTLBackend_SEQ_LS_AMG_SSOR(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Constructor.
Definition: seqistlsolverbackend.hh:789
Sequential Loop solver preconditioned with AMG smoothed by SSOR.
Definition: seqistlsolverbackend.hh:776
void apply(M &A, V &z, W &r, typename Dune::template FieldTraits< typename W::ElementType >::real_type reduction)
solve the given linear system
Definition: seqistlsolverbackend.hh:429
ISTLBackend_SEQ_BCGS_AMG_SSOR(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Constructor.
Definition: seqistlsolverbackend.hh:737
void apply(M &A, V &z, W &r, typename Dune::template FieldTraits< typename W::ElementType >::real_type reduction)
solve the given linear system
Definition: seqistlsolverbackend.hh:194
X domain_type
Definition: seqistlsolverbackend.hh:38
Dune::PDELab::LinearSolverResult< double > res
Definition: solver.hh:52
Backend for sequential BiCGSTAB solver with SSOR preconditioner.
Definition: seqistlsolverbackend.hh:261
ISTLBackend_SEQ_ILU0(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:136
unsigned int iterations
Definition: solver.hh:33
ISTLBackend_SEQ_MINRES_SSOR(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:374
virtual void applyscaleadd(field_type alpha, const X &x, Y &y) const override
Definition: seqistlsolverbackend.hh:52
bool directCoarseLevelSolver
True if a direct solver was used on the coarset level.
Definition: seqistlsolverbackend.hh:560
Backend for sequential loop solver with Jacobi preconditioner.
Definition: seqistlsolverbackend.hh:229
ISTLBackend_SEQ_SuperLU(int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:407
V::ElementType norm(const V &v) const
compute global norm of a vector
Definition: seqistlsolverbackend.hh:622
Definition: seqistlsolverbackend.hh:76
Solver backend using UMFPack as a direct solver.
Definition: seqistlsolverbackend.hh:453
ISTLBackend_SEQ_UMFPack(int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:461
X::field_type field_type
Definition: seqistlsolverbackend.hh:40
ISTLBackend_SEQ_Base(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:85
ISTLBackend_SEQ_BCGS_SSOR(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:270
ISTLBackend_SEQ_CG_AMG_SSOR(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Constructor.
Definition: seqistlsolverbackend.hh:711
void setparams(Parameters params_)
set AMG parameters
Definition: seqistlsolverbackend.hh:601
Linear solver backend for Restarted GMRes preconditioned with ILU(0)
Definition: seqistlsolverbackend.hh:827
ISTLBackend_SEQ_BCGS_Jac(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:253
Sequential BiCGSTAB solver preconditioned with AMG smoothed by SOR.
Definition: seqistlsolverbackend.hh:750
Sequential congute gradient solver with ILU0 preconditioner.
Definition: seqistlsolverbackend.hh:328
Definition: seqistlsolverbackend.hh:173
ISTLBackend_SEQ_UMFPack(int maxiter, int verbose_)
make a linear solver object
Definition: seqistlsolverbackend.hh:471
void apply(M &A, V &z, W &r, typename Dune::template FieldTraits< typename W::ElementType >::real_type reduction)
solve the given linear system
Definition: seqistlsolverbackend.hh:520
Class providing some statistics of the AMG solver.
Definition: seqistlsolverbackend.hh:544
double tprepare
The needed for computing the parallel information and for adapting the linear system.
Definition: seqistlsolverbackend.hh:550
ISTLBackend_SEQ_ILUn(int n, double w, unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:183
Sequential Loop solver preconditioned with AMG smoothed by SOR.
Definition: seqistlsolverbackend.hh:802
Backend using a MINRes solver preconditioned by SSOR.
Definition: seqistlsolverbackend.hh:365
void apply(M &A, V &z, W &r, typename Dune::template FieldTraits< typename W::ElementType >::real_type reduction)
solve the given linear system
Definition: seqistlsolverbackend.hh:99
ISTLBackend_SEQ_CG_ILUn(int n_, double w_=1.0, unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:340
ISTLBackend_SEQ_SuperLU(int maxiter, int verbose_)
make a linear solver object
Definition: seqistlsolverbackend.hh:417
ISTLBackend_SEQ_CG_Jac(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:390
double tsetup
The time needed for building the AMG hierarchy (coarsening).
Definition: seqistlsolverbackend.hh:556
const ISTLAMGStatistics & statistics() const
Get statistics of the AMG solver (no of levels, timings).
Definition: seqistlsolverbackend.hh:672
bool converged
Definition: solver.hh:32
ISTLBackend_SEQ_AMG(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Definition: seqistlsolverbackend.hh:579
VTKWriter & w
Definition: function.hh:829
void apply(M &A, V &z, W &r, typename Dune::template FieldTraits< typename W::ElementType >::real_type reduction)
solve the given linear system
Definition: seqistlsolverbackend.hh:147
Backend for sequential BiCGSTAB solver with ILU0 preconditioner.
Definition: seqistlsolverbackend.hh:278
ISTLBackend_SEQ_BCGS_AMG_SOR(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Constructor.
Definition: seqistlsolverbackend.hh:763
typename native_type< T >::type Native
Alias of the native container type associated with T or T itself if it is not a backend wrapper.
Definition: backend/interface.hh:176
SolverCategory::Category category() const override
Definition: seqistlsolverbackend.hh:60