3 #ifndef DUNE_SEQISTLSOLVERBACKEND_HH
4 #define DUNE_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>
33 template<
typename X,
typename Y,
typename GOS>
41 enum {
category=Dune::SolverCategory::sequential};
47 virtual void apply (
const X& x, Y& y)
const
50 gos.jacobian_apply(x,y);
57 gos.jacobian_apply(x,temp);
70 template<
template<
class,
class,
class,
int>
class Preconditioner,
71 template<
class>
class Solver>
82 : maxiter(maxiter_), verbose(verbose_)
94 template<
class M,
class V,
class W>
95 void apply(M& A, V& z, W& r,
typename W::ElementType reduction)
97 Dune::MatrixAdapter<
typename M::BaseT,
100 Preconditioner<
typename M::BaseT,
102 typename W::BaseT,1> prec(
istl::raw(A), 3, 1.0);
103 Solver<typename V::BaseT> solver(opa, prec, reduction, maxiter, verbose);
104 Dune::InverseOperatorResult stat;
118 template<
template<
typename>
class Solver>
129 : maxiter(maxiter_), verbose(verbose_)
138 template<
class M,
class V,
class W>
139 void apply(M& A, V& z, W& r,
typename Dune::template FieldTraits<typename W::ElementType >::real_type reduction)
141 Dune::MatrixAdapter<
typename M::BaseT,
144 Dune::SeqILU0<
typename M::BaseT,
146 typename W::BaseT> ilu0(
istl::raw(A), 1.0);
147 Solver<typename V::BaseT> solver(opa, ilu0, reduction, maxiter, verbose);
148 Dune::InverseOperatorResult stat;
161 template<
template<
typename>
class Solver>
173 : n_(n), w_(w), maxiter(maxiter_), verbose(verbose_)
182 template<
class M,
class V,
class W>
183 void apply(M& A, V& z, W& r,
typename W::ElementType reduction)
185 Dune::MatrixAdapter<
typename M::BaseT,
188 Dune::SeqILUn<
typename M::BaseT,
190 typename W::BaseT> ilun(
istl::raw(A), n_, w_);
191 Solver<typename V::BaseT> solver(opa, ilun, reduction, maxiter, verbose);
192 Dune::InverseOperatorResult stat;
384 class ISTLBackend_SEQ_SuperLU
385 :
public SequentialNorm,
public LinearResultStorage
392 explicit ISTLBackend_SEQ_SuperLU (
int verbose_=1)
402 ISTLBackend_SEQ_SuperLU (
int maxiter,
int verbose_)
413 template<
class M,
class V,
class W>
414 void apply(M& A, V& z, W& r,
typename W::ElementType reduction)
416 typedef typename M::Container ISTLM;
417 Dune::SuperLU<ISTLM> solver(
istl::raw(A), verbose);
418 Dune::InverseOperatorResult stat;
420 res.converged = stat.converged;
421 res.iterations = stat.iterations;
422 res.elapsed = stat.elapsed;
423 res.reduction = stat.reduction;
424 res.conv_rate = stat.conv_rate;
430 #endif // HAVE_SUPERLU
449 template<
class M,
class V,
class W>
450 void apply(M& A, V& z, W& r,
typename W::ElementType reduction)
452 Dune::SeqJac<
typename M::BaseT,
454 typename W::BaseT> jac(
istl::raw(A),1,1.0);
491 template<
class GO,
template<
class,
class,
class,
int>
class Preconditioner,
template<
class>
class Solver,
492 bool skipBlocksizeCheck =
false>
495 typedef typename GO::Traits::TrialGridFunctionSpace GFS;
496 typedef typename GO::Traits::Jacobian M;
497 typedef typename M::BaseT MatrixType;
498 typedef typename GO::Traits::Domain V;
499 typedef typename V::BaseT VectorType;
500 typedef Preconditioner<MatrixType,VectorType,VectorType,1> Smoother;
501 typedef Dune::MatrixAdapter<MatrixType,VectorType,VectorType> Operator;
502 typedef typename Dune::Amg::SmootherTraits<Smoother>::Arguments SmootherArgs;
503 typedef Dune::Amg::AMG<Operator,VectorType,Smoother> AMG;
504 typedef Dune::Amg::Parameters Parameters;
508 bool reuse_=
false,
bool usesuperlu_=
true)
509 : maxiter(maxiter_), params(15,2000), verbose(verbose_),
510 reuse(reuse_), firstapply(true), usesuperlu(usesuperlu_)
512 params.setDefaultValuesIsotropic(GFS::Traits::GridViewType::Traits::Grid::dimension);
513 params.setDebugLevel(verbose_);
515 if (usesuperlu ==
true)
517 std::cout <<
"WARNING: You are using AMG without SuperLU!"
518 <<
" Please consider installing SuperLU,"
519 <<
" or set the usesuperlu flag to false"
520 <<
" to suppress this warning." << std::endl;
538 typename V::ElementType
norm (
const V& v)
const
550 void apply(M& A, V& z, V& r,
typename V::ElementType reduction)
554 typedef Dune::Amg::CoarsenCriterion<Dune::Amg::SymmetricCriterion<MatrixType,
555 Dune::Amg::FirstDiagonal> > Criterion;
556 SmootherArgs smootherArgs;
557 smootherArgs.iterations = 1;
558 smootherArgs.relaxationFactor = 1;
560 Criterion criterion(params);
563 if (reuse==
false || firstapply==
true){
564 amg.reset(
new AMG(oop, criterion, smootherArgs));
566 stats.
tsetup = watch.elapsed();
567 stats.
levels = amg->maxlevels();
571 Dune::InverseOperatorResult stat;
573 Solver<VectorType> solver(oop,*amg,reduction,maxiter,verbose);
575 stats.
tsolve= watch.elapsed();
600 Dune::shared_ptr<AMG> amg;
627 bool reuse_=
false,
bool usesuperlu_=
true)
629 (maxiter_, verbose_, reuse_, usesuperlu_)
653 bool reuse_=
false,
bool usesuperlu_=
true)
655 (maxiter_, verbose_, reuse_, usesuperlu_)
679 bool reuse_=
false,
bool usesuperlu_=
true)
681 (maxiter_, verbose_, reuse_, usesuperlu_)
705 bool reuse_=
false,
bool usesuperlu_=
true)
707 (maxiter_, verbose_, reuse_, usesuperlu_)
731 bool reuse_=
false,
bool usesuperlu_=
true)
733 (maxiter_, verbose_, reuse_, usesuperlu_)
ISTLBackend_SEQ_BCGS_AMG_SSOR(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Constructor.
Definition: seqistlsolverbackend.hh:652
X domain_type
Definition: seqistlsolverbackend.hh:37
Sequential congute gradient solver with ILU0 preconditioner.
Definition: seqistlsolverbackend.hh:313
ISTLBackend_SEQ_MINRES_SSOR(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:359
Class providing some statistics of the AMG solver.
Definition: seqistlsolverbackend.hh:472
double tsetup
The time needed for building the AMG hierarchy (coarsening).
Definition: seqistlsolverbackend.hh:484
void apply(M &A, V &z, W &r, typename W::ElementType reduction)
solve the given linear system
Definition: seqistlsolverbackend.hh:183
bool converged
Definition: solver.hh:32
double tsolve
The time spent in solving the system (without building the hierarchy.
Definition: seqistlsolverbackend.hh:482
Definition: seqistlsolverbackend.hh:72
ISTLBackend_SEQ_BCGS_AMG_SOR(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Constructor.
Definition: seqistlsolverbackend.hh:678
Sequential Loop solver preconditioned with AMG smoothed by SSOR.
Definition: seqistlsolverbackend.hh:691
ISTLBackend_SEQ_ILUn(int n, double w, unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:172
Definition: seqistlsolverbackend.hh:34
Backend for sequential BiCGSTAB solver with Jacobi preconditioner.
Definition: seqistlsolverbackend.hh:230
double elapsed
Definition: solver.hh:34
Backend for sequential BiCGSTAB solver with ILU0 preconditioner.
Definition: seqistlsolverbackend.hh:263
VTKWriter & w
Definition: function.hh:1102
ISTLBackend_SEQ_LOOP_Jac(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:222
void apply(M &A, V &z, W &r, typename W::ElementType reduction)
solve the given linear system
Definition: seqistlsolverbackend.hh:450
int levels
the number of levels in the AMG hierarchy.
Definition: seqistlsolverbackend.hh:480
ISTLBackend_SEQ_AMG(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Definition: seqistlsolverbackend.hh:507
Backend for sequential conjugate gradient solver with ILU0 preconditioner.
Definition: seqistlsolverbackend.hh:280
ISTLBackend_SEQ_LS_AMG_SOR(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Constructor.
Definition: seqistlsolverbackend.hh:730
Backend for sequential conjugate gradient solver with SSOR preconditioner.
Definition: seqistlsolverbackend.hh:333
OnTheFlyOperator(GOS &gos_)
Definition: seqistlsolverbackend.hh:43
ISTLBackend_SEQ_BCGS_ILU0(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:272
ISTLBackend_SEQ_CG_AMG_SSOR(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Constructor.
Definition: seqistlsolverbackend.hh:626
Sequential Loop solver preconditioned with AMG smoothed by SOR.
Definition: seqistlsolverbackend.hh:717
X::field_type field_type
Definition: seqistlsolverbackend.hh:39
Sequential BiCGStab solver with ILU0 preconditioner.
Definition: seqistlsolverbackend.hh:295
V & raw(V &v)
Returns the raw ISTL object associated with v, or v itself it is already an ISTL object.
Definition: backend/istl/utility.hh:26
void setparams(Parameters params_)
set AMG parameters
Definition: seqistlsolverbackend.hh:529
Sequential BiCGStab solver preconditioned with AMG smoothed by SSOR.
Definition: seqistlsolverbackend.hh:639
Dune::PDELab::LinearSolverResult< double > res
Definition: solver.hh:52
void apply(M &A, V &z, W &r, typename W::ElementType reduction)
solve the given linear system
Definition: seqistlsolverbackend.hh:95
ISTLBackend_SEQ_BCGS_Jac(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:238
ISTLBackend_SEQ_CG_Jac(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:375
ISTLBackend_SEQ_ExplicitDiagonal()
make a linear solver object
Definition: seqistlsolverbackend.hh:439
virtual void applyscaleadd(field_type alpha, const X &x, Y &y) const
Definition: seqistlsolverbackend.hh:53
RFType reduction
Definition: solver.hh:35
Sequential conjugate gradient solver preconditioned with AMG smoothed by SSOR.
Definition: seqistlsolverbackend.hh:613
ISTLBackend_SEQ_Base(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:81
const ISTLAMGStatistics & statistics() const
Get statistics of the AMG solver (no of levels, timings).
Definition: seqistlsolverbackend.hh:588
ISTLBackend_SEQ_BCGS_SSOR(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:255
Backend for conjugate gradient solver with Jacobi preconditioner.
Definition: seqistlsolverbackend.hh:367
Definition: seqistlsolverbackend.hh:493
bool directCoarseLevelSolver
True if a direct solver was used on the coarset level.
Definition: seqistlsolverbackend.hh:488
ISTLBackend_SEQ_CG_ILUn(int n_, double w_=1.0, unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:325
Backend for sequential loop solver with Jacobi preconditioner.
Definition: seqistlsolverbackend.hh:214
Definition: seqistlsolverbackend.hh:119
Sequential BiCGSTAB solver preconditioned with AMG smoothed by SOR.
Definition: seqistlsolverbackend.hh:665
ISTLBackend_SEQ_BCGS_ILUn(int n_, double w_=1.0, unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:307
Backend using a MINRes solver preconditioned by SSOR.
Definition: seqistlsolverbackend.hh:350
Backend for sequential BiCGSTAB solver with SSOR preconditioner.
Definition: seqistlsolverbackend.hh:246
Y range_type
Definition: seqistlsolverbackend.hh:38
double tprepare
The needed for computing the parallel information and for adapting the linear system.
Definition: seqistlsolverbackend.hh:478
ISTLBackend_SEQ_LS_AMG_SSOR(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Constructor.
Definition: seqistlsolverbackend.hh:704
int iterations
The number of iterations performed until convergence was reached.
Definition: seqistlsolverbackend.hh:486
V::ElementType norm(const V &v) const
compute global norm of a vector
Definition: seqistlsolverbackend.hh:538
ISTLBackend_SEQ_CG_SSOR(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:342
RFType conv_rate
Definition: solver.hh:36
ISTLBackend_SEQ_CG_ILU0(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:289
void apply(M &A, V &z, V &r, typename V::ElementType reduction)
solve the given linear system
Definition: seqistlsolverbackend.hh:550
virtual void apply(const X &x, Y &y) const
Definition: seqistlsolverbackend.hh:47
ISTLBackend_SEQ_ILU0(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition: seqistlsolverbackend.hh:128
Definition: seqistlsolverbackend.hh:41
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:139
Definition: seqistlsolverbackend.hh:162
unsigned int iterations
Definition: solver.hh:33
Solver to be used for explicit time-steppers with (block-)diagonal mass matrix.
Definition: seqistlsolverbackend.hh:433