dune-pdelab 2.7-git
Loading...
Searching...
No Matches
seqistlsolverbackend.hh
Go to the documentation of this file.
1// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=8 sw=2 sts=2:
3#ifndef DUNE_PDELAB_BACKEND_ISTL_SEQISTLSOLVERBACKEND_HH
4#define DUNE_PDELAB_BACKEND_ISTL_SEQISTLSOLVERBACKEND_HH
5
6#include <dune/common/deprecated.hh>
7#include <dune/common/parallel/mpihelper.hh>
8
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>
20
26
27namespace Dune {
28 namespace PDELab {
29
33
34
44 template<typename X, typename Y, typename GO>
45 class OnTheFlyOperator : public Dune::LinearOperator<X,Y>
46 {
47 public:
48 typedef X domain_type;
49 typedef Y range_type;
50 typedef typename X::field_type field_type;
51 static constexpr bool isLinear = GO::LocalAssembler::isLinear();
52
53
54 OnTheFlyOperator (const GO& go_)
55 : go(go_)
56 , u_(nullptr)
57 {}
58
61 void setLinearizationPoint(const X& u)
62 {
63 u_ = &u;
64 }
65
66 virtual void apply (const X& x, Y& y) const override
67 {
68 y = 0.0;
69 if (isLinear)
70 go.jacobian_apply(x,y);
71 else {
72 if (u_ == nullptr)
73 DUNE_THROW(Dune::InvalidStateException, "You seem to apply a nonlinear operator without setting the linearization point first!");
74 go.jacobian_apply(*u_, x, y);
75 }
76 }
77
78 virtual void applyscaleadd (field_type alpha, const X& x, Y& y) const override
79 {
80 Y temp(y);
81 temp = 0.0;
82 if (isLinear)
83 go.jacobian_apply(x,temp);
84 else {
85 if (u_ == nullptr)
86 DUNE_THROW(Dune::InvalidStateException, "You seem to apply a nonlinear operator without setting the linearization point first!");
87 go.jacobian_apply(*u_, x, temp);
88 }
89 y.axpy(alpha,temp);
90 }
91
92 SolverCategory::Category category() const override
93 {
94 return SolverCategory::sequential;
95 }
96
97 private:
98 const GO& go;
99 const X* u_;
100 };
101
102 //==============================================================================
103 // Here we add some standard linear solvers conforming to the linear solver
104 // interface required to solve linear and nonlinear problems.
105 //==============================================================================
106
107 //=====================================================================
108 // First we add some base classes where the preconditioner is specified
109 //=====================================================================
110
111 template<template<class> class Solver>
113 : public SequentialNorm, public LinearResultStorage
114 {
115 public:
121 explicit ISTLBackend_SEQ_Richardson(unsigned maxiter_=5000, int verbose_=1)
122 : maxiter(maxiter_), verbose(verbose_)
123 {}
124
132 template<class M, class V, class W>
133 void apply(M& A, V& z, W& r, typename Dune::template FieldTraits<typename W::ElementType >::real_type reduction)
134 {
135 using Backend::Native;
136 using Backend::native;
137
138 Dune::MatrixAdapter<Native<M>,
139 Native<V>,
140 Native<W>> opa(native(A));
141 Dune::Richardson<Native<V>,Native<W> > prec(0.7);
142 Solver<Native<V> > solver(opa, prec, reduction, maxiter, verbose);
143 Dune::InverseOperatorResult stat;
144 solver.apply(native(z), native(r), stat);
145 res.converged = stat.converged;
146 res.iterations = stat.iterations;
147 res.elapsed = stat.elapsed;
148 res.reduction = stat.reduction;
149 res.conv_rate = stat.conv_rate;
150 }
151
152 private:
153 unsigned maxiter;
154 int verbose;
155 };
156
157 template<class GO, template<class> class Solver>
159 : public SequentialNorm, public LinearResultStorage
160 {
161 using V = typename GO::Traits::Domain;
162 using W = typename GO::Traits::Range;
163 public:
169 explicit ISTLBackend_SEQ_MatrixFree_Richardson(const GO& go, unsigned maxiter=5000, int verbose=1)
170 : opa_(go)
171 , maxiter_(maxiter)
172 , verbose_(verbose)
173 {}
174
182 void apply(V& z, W& r, typename Dune::template FieldTraits<typename W::ElementType >::real_type reduction)
183 {
184 Dune::Richardson<V,W> prec(1.0);
185 Solver<V> solver(opa_, prec, reduction, maxiter_, verbose_);
186 Dune::InverseOperatorResult stat;
187 solver.apply(z, r, stat);
188 res.converged = stat.converged;
189 res.iterations = stat.iterations;
190 res.elapsed = stat.elapsed;
191 res.reduction = stat.reduction;
192 res.conv_rate = stat.conv_rate;
193 }
194
196 void setLinearizationPoint(const V& u)
197 {
198 opa_.setLinearizationPoint(u);
199 }
200
201 private:
203 unsigned maxiter_;
204 int verbose_;
205 };
206
207 template<template<class,class,class,int> class Preconditioner,
208 template<class> class Solver>
210 : public SequentialNorm, public LinearResultStorage
211 {
212 public:
218 explicit ISTLBackend_SEQ_Base(unsigned maxiter_=5000, int verbose_=1, unsigned preconditioner_steps_=1)
219 : maxiter(maxiter_), verbose(verbose_), preconditioner_steps(preconditioner_steps_)
220 {}
221
222
223
231 template<class M, class V, class W>
232 void apply(M& A, V& z, W& r, typename Dune::template FieldTraits<typename W::ElementType >::real_type reduction)
233 {
234 using Backend::Native;
235 using Backend::native;
236
237 Dune::MatrixAdapter<Native<M>,
238 Native<V>,
239 Native<W>> opa(native(A));
240 Preconditioner<Native<M>,
241 Native<V>,
242 Native<W>,
243 1> prec(native(A), preconditioner_steps, 1.0);
244 Solver<Native<V>> solver(opa, prec, reduction, maxiter, verbose);
245 Dune::InverseOperatorResult stat;
246 solver.apply(native(z), native(r), stat);
247 res.converged = stat.converged;
248 res.iterations = stat.iterations;
249 res.elapsed = stat.elapsed;
250 res.reduction = stat.reduction;
251 res.conv_rate = stat.conv_rate;
252 }
253
254 private:
255 unsigned maxiter;
256 int verbose;
257 unsigned preconditioner_steps;
258 };
259
260 template<template<typename> class Solver>
262 : public SequentialNorm, public LinearResultStorage
263 {
264 public:
270 explicit ISTLBackend_SEQ_ILU0 (unsigned maxiter_=5000, int verbose_=1)
271 : maxiter(maxiter_), verbose(verbose_)
272 {}
280 template<class M, class V, class W>
281 void apply(M& A, V& z, W& r, typename Dune::template FieldTraits<typename W::ElementType >::real_type reduction)
282 {
283 using Backend::Native;
284 using Backend::native;
285 Dune::MatrixAdapter<Native<M>,
286 Native<V>,
287 Native<W>> opa(native(A));
288 Dune::SeqILU<Native<M>,
289 Native<V>,
290 Native<W>
291 > ilu0(native(A), 1.0);
292 Solver<Native<V>> solver(opa, ilu0, reduction, maxiter, verbose);
293 Dune::InverseOperatorResult stat;
294 solver.apply(native(z), native(r), stat);
295 res.converged = stat.converged;
296 res.iterations = stat.iterations;
297 res.elapsed = stat.elapsed;
298 res.reduction = stat.reduction;
299 res.conv_rate = stat.conv_rate;
300 }
301 private:
302 unsigned maxiter;
303 int verbose;
304 };
305
306 template<template<typename> class Solver>
308 : public SequentialNorm, public LinearResultStorage
309 {
310 public:
317 ISTLBackend_SEQ_ILUn (int n, double w, unsigned maxiter_=5000, int verbose_=1)
318 : n_(n), w_(w), maxiter(maxiter_), verbose(verbose_)
319 {}
327 template<class M, class V, class W>
328 void apply(M& A, V& z, W& r, typename Dune::template FieldTraits<typename W::ElementType >::real_type reduction)
329 {
330 using Backend::Native;
331 using Backend::native;
332 Dune::MatrixAdapter<Native<M>,
333 Native<V>,
334 Native<W>
335 > opa(native(A));
336 Dune::SeqILU<Native<M>,
337 Native<V>,
338 Native<W>
339 > ilun(native(A), n_, w_, false);
340 Solver<Native<V>> solver(opa, ilun, reduction, maxiter, verbose);
341 Dune::InverseOperatorResult stat;
342 solver.apply(native(z), native(r), stat);
343 res.converged = stat.converged;
344 res.iterations = stat.iterations;
345 res.elapsed = stat.elapsed;
346 res.reduction = stat.reduction;
347 res.conv_rate = stat.conv_rate;
348 }
349 private:
350 int n_;
351 double w_;
352
353 unsigned maxiter;
354 int verbose;
355 };
356
357 //========================================
358 // Start with matrix based solver backends
359 //========================================
360
363
368 : public ISTLBackend_SEQ_Base<Dune::SeqJac, Dune::LoopSolver>
369 {
370 public:
375 explicit ISTLBackend_SEQ_LOOP_Jac (unsigned maxiter_=5000, int verbose_=1, unsigned preconditioner_steps_=1)
376 : ISTLBackend_SEQ_Base<Dune::SeqJac, Dune::LoopSolver>(maxiter_, verbose_, preconditioner_steps_)
377 {}
378 };
379
386 : public ISTLBackend_SEQ_Richardson<Dune::BiCGSTABSolver>
387 {
388 public:
393 explicit ISTLBackend_SEQ_BCGS_Richardson (unsigned maxiter_=5000, int verbose_=1)
394 : ISTLBackend_SEQ_Richardson<Dune::BiCGSTABSolver>(maxiter_, verbose_)
395 {}
396 };
397
402 : public ISTLBackend_SEQ_Base<Dune::SeqJac, Dune::BiCGSTABSolver>
403 {
404 public:
409 explicit ISTLBackend_SEQ_BCGS_Jac (unsigned maxiter_=5000, int verbose_=1, unsigned preconditioner_steps_=1)
410 : ISTLBackend_SEQ_Base<Dune::SeqJac, Dune::BiCGSTABSolver>(maxiter_, verbose_, preconditioner_steps_)
411 {}
412 };
413
418 : public ISTLBackend_SEQ_Base<Dune::SeqSSOR, Dune::BiCGSTABSolver>
419 {
420 public:
426 explicit ISTLBackend_SEQ_BCGS_SSOR (unsigned maxiter_=5000, int verbose_=1, unsigned preconditioner_steps_=1)
427 : ISTLBackend_SEQ_Base<Dune::SeqSSOR, Dune::BiCGSTABSolver>(maxiter_, verbose_, preconditioner_steps_)
428 {}
429 };
430
435 : public ISTLBackend_SEQ_ILU0<Dune::BiCGSTABSolver>
436 {
437 public:
443 explicit ISTLBackend_SEQ_BCGS_ILU0 (unsigned maxiter_=5000, int verbose_=1)
444 : ISTLBackend_SEQ_ILU0<Dune::BiCGSTABSolver>(maxiter_, verbose_)
445 {}
446 };
447
452 : public ISTLBackend_SEQ_ILU0<Dune::CGSolver>
453 {
454 public:
460 explicit ISTLBackend_SEQ_CG_ILU0 (unsigned maxiter_=5000, int verbose_=1)
461 : ISTLBackend_SEQ_ILU0<Dune::CGSolver>(maxiter_, verbose_)
462 {}
463 };
464
467 : public ISTLBackend_SEQ_ILUn<Dune::BiCGSTABSolver>
468 {
469 public:
478 explicit ISTLBackend_SEQ_BCGS_ILUn (int n_, double w_=1.0, unsigned maxiter_=5000, int verbose_=1)
479 : ISTLBackend_SEQ_ILUn<Dune::BiCGSTABSolver>(n_, w_, maxiter_, verbose_)
480 {}
481 };
482
485 : public ISTLBackend_SEQ_ILUn<Dune::CGSolver>
486 {
487 public:
496 explicit ISTLBackend_SEQ_CG_ILUn (int n_, double w_=1.0, unsigned maxiter_=5000, int verbose_=1)
497 : ISTLBackend_SEQ_ILUn<Dune::CGSolver>(n_, w_, maxiter_, verbose_)
498 {}
499 };
500
505 : public ISTLBackend_SEQ_Base<Dune::SeqSSOR, Dune::CGSolver>
506 {
507 public:
513 explicit ISTLBackend_SEQ_CG_SSOR (unsigned maxiter_=5000, int verbose_=1, unsigned preconditioner_steps_=1)
514 : ISTLBackend_SEQ_Base<Dune::SeqSSOR, Dune::CGSolver>(maxiter_, verbose_, preconditioner_steps_)
515 {}
516 };
517
522 : public ISTLBackend_SEQ_Base<Dune::SeqSSOR, Dune::MINRESSolver>
523 {
524 public:
530 explicit ISTLBackend_SEQ_MINRES_SSOR (unsigned maxiter_=5000, int verbose_=1, unsigned preconditioner_steps_=1)
531 : ISTLBackend_SEQ_Base<Dune::SeqSSOR, Dune::MINRESSolver>(maxiter_, verbose_, preconditioner_steps_)
532 {}
533 };
534
539 : public ISTLBackend_SEQ_Base<Dune::SeqJac, Dune::CGSolver>
540 {
541 public:
546 explicit ISTLBackend_SEQ_CG_Jac (unsigned maxiter_=5000, int verbose_=1, unsigned preconditioner_steps_=1)
547 : ISTLBackend_SEQ_Base<Dune::SeqJac, Dune::CGSolver>(maxiter_, verbose_, preconditioner_steps_)
548 {}
549 };
550
551#if HAVE_SUPERLU || DOXYGEN
556 : public SequentialNorm, public LinearResultStorage
557 {
558 public:
563 explicit ISTLBackend_SEQ_SuperLU (int verbose_=1)
564 : verbose(verbose_)
565 {}
566
567
573 ISTLBackend_SEQ_SuperLU (int maxiter, int verbose_)
574 : verbose(verbose_)
575 {}
576
584 template<class M, class V, class W>
585 void apply(M& A, V& z, W& r, typename Dune::template FieldTraits<typename W::ElementType >::real_type reduction)
586 {
587 using Backend::Native;
588 using Backend::native;
589 using ISTLM = Native<M>;
590 Dune::SuperLU<ISTLM> solver(native(A), verbose);
591 Dune::InverseOperatorResult stat;
592 solver.apply(native(z), native(r), stat);
593 res.converged = stat.converged;
594 res.iterations = stat.iterations;
595 res.elapsed = stat.elapsed;
596 res.reduction = stat.reduction;
597 res.conv_rate = stat.conv_rate;
598 }
599
600 private:
601 int verbose;
602 };
603#endif // HAVE_SUPERLU || DOXYGEN
604
605#if HAVE_SUITESPARSE_UMFPACK || DOXYGEN
610 : public SequentialNorm, public LinearResultStorage
611 {
612 public:
617 explicit ISTLBackend_SEQ_UMFPack (int verbose_=1)
618 : verbose(verbose_)
619 {}
620
621
627 ISTLBackend_SEQ_UMFPack (int maxiter, int verbose_)
628 : verbose(verbose_)
629 {}
630
638 template<class M, class V, class W>
639 void apply(M& A, V& z, W& r, typename Dune::template FieldTraits<typename W::ElementType >::real_type reduction)
640 {
641 using Backend::native;
642 using ISTLM = Backend::Native<M>;
643 Dune::UMFPack<ISTLM> solver(native(A), verbose);
644 Dune::InverseOperatorResult stat;
645 solver.apply(native(z), native(r), stat);
646 res.converged = stat.converged;
647 res.iterations = stat.iterations;
648 res.elapsed = stat.elapsed;
649 res.reduction = stat.reduction;
650 res.conv_rate = stat.conv_rate;
651 }
652
653 private:
654 int verbose;
655 };
656#endif // HAVE_SUITESPARSE_UMFPACK || DOXYGEN
657
660 : public SequentialNorm, public LinearResultStorage
661 {
662 public:
667
675 template<class M, class V, class W>
676 void apply(M& A, V& z, W& r, typename Dune::template FieldTraits<typename W::ElementType >::real_type reduction)
677 {
678 using Backend::Native;
679 Dune::SeqJac<Native<M>,
680 Native<V>,
681 Native<W>
682 > jac(Backend::native(A),1,1.0);
683 jac.pre(z,r);
684 jac.apply(z,r);
685 jac.post(z);
686 res.converged = true;
687 res.iterations = 1;
688 res.elapsed = 0.0;
689 res.reduction = reduction;
690 res.conv_rate = reduction; // pow(reduction,1.0/1)
691 }
692 };
693
695
718
719 template<class GO, template<class,class,class,int> class Preconditioner, template<class> class Solver,
720 bool skipBlocksizeCheck = false>
722 {
723 typedef typename GO::Traits::TrialGridFunctionSpace GFS;
724 typedef typename GO::Traits::Jacobian M;
725 typedef Backend::Native<M> MatrixType;
726 typedef typename GO::Traits::Domain V;
727 typedef Backend::Native<V> VectorType;
728 typedef Preconditioner<MatrixType,VectorType,VectorType,1> Smoother;
729 typedef Dune::MatrixAdapter<MatrixType,VectorType,VectorType> Operator;
730 typedef typename Dune::Amg::SmootherTraits<Smoother>::Arguments SmootherArgs;
731 typedef Dune::Amg::AMG<Operator,VectorType,Smoother> AMG;
732 typedef Dune::Amg::Parameters Parameters;
733
734 public:
735 ISTLBackend_SEQ_AMG(unsigned maxiter_=5000, int verbose_=1,
736 bool reuse_=false, bool usesuperlu_=true)
737 : maxiter(maxiter_), params(15,2000), verbose(verbose_),
738 reuse(reuse_), firstapply(true), usesuperlu(usesuperlu_)
739 {
740 params.setDefaultValuesIsotropic(GFS::Traits::GridViewType::Traits::Grid::dimension);
741 params.setDebugLevel(verbose_);
742#if !HAVE_SUPERLU
743 if (usesuperlu == true)
744 {
745 std::cout << "WARNING: You are using AMG without SuperLU!"
746 << " Please consider installing SuperLU,"
747 << " or set the usesuperlu flag to false"
748 << " to suppress this warning." << std::endl;
749 }
750#endif
751 }
752
757 void setparams(Parameters params_)
758 {
759 params = params_;
760 }
761
763 void setReuse(bool reuse_)
764 {
765 reuse = reuse_;
766 }
767
769 bool getReuse() const
770 {
771 return reuse;
772 }
773
778 typename V::ElementType norm (const V& v) const
779 {
780 return Backend::native(v).two_norm();
781 }
782
790 void apply(M& A, V& z, V& r, typename Dune::template FieldTraits<typename V::ElementType >::real_type reduction)
791 {
792 Timer watch;
793 MatrixType& mat = Backend::native(A);
794 typedef Dune::Amg::CoarsenCriterion<Dune::Amg::SymmetricCriterion<MatrixType,
795 Dune::Amg::FirstDiagonal> > Criterion;
796 SmootherArgs smootherArgs;
797 smootherArgs.iterations = 1;
798 smootherArgs.relaxationFactor = 1;
799
800 Criterion criterion(params);
801 //only construct a new AMG if the matrix changes
802 if (reuse==false || firstapply==true){
803 oop.reset(new Operator(mat));
804 amg.reset(new AMG(*oop, criterion, smootherArgs));
805 firstapply = false;
806 stats.tsetup = watch.elapsed();
807 stats.levels = amg->maxlevels();
808 stats.directCoarseLevelSolver=amg->usesDirectCoarseLevelSolver();
809 }
810 watch.reset();
811 Dune::InverseOperatorResult stat;
812
813 Solver<VectorType> solver(*oop,*amg,reduction,maxiter,verbose);
814 solver.apply(Backend::native(z),Backend::native(r),stat);
815 stats.tsolve= watch.elapsed();
816 res.converged = stat.converged;
817 res.iterations = stat.iterations;
818 res.elapsed = stat.elapsed;
819 res.reduction = stat.reduction;
820 res.conv_rate = stat.conv_rate;
821 }
822
823
829 {
830 return stats;
831 }
832
833 private:
834 unsigned maxiter;
835 Parameters params;
836 int verbose;
837 bool reuse;
838 bool firstapply;
839 bool usesuperlu;
840 std::shared_ptr<Operator> oop;
841 std::shared_ptr<AMG> amg;
842 ISTLAMGStatistics stats;
843 };
844
847
853 template<class GO>
855 : public ISTLBackend_SEQ_AMG<GO, Dune::SeqSSOR, Dune::CGSolver>
856 {
857
858 public:
867 ISTLBackend_SEQ_CG_AMG_SSOR(unsigned maxiter_=5000, int verbose_=1,
868 bool reuse_=false, bool usesuperlu_=true)
869 : ISTLBackend_SEQ_AMG<GO, Dune::SeqSSOR, Dune::CGSolver>
870 (maxiter_, verbose_, reuse_, usesuperlu_)
871 {}
872 };
873
879 template<class GO>
881 : public ISTLBackend_SEQ_AMG<GO, Dune::SeqSSOR, Dune::BiCGSTABSolver>
882 {
883
884 public:
893 ISTLBackend_SEQ_BCGS_AMG_SSOR(unsigned maxiter_=5000, int verbose_=1,
894 bool reuse_=false, bool usesuperlu_=true)
895 : ISTLBackend_SEQ_AMG<GO, Dune::SeqSSOR, Dune::BiCGSTABSolver>
896 (maxiter_, verbose_, reuse_, usesuperlu_)
897 {}
898 };
899
905 template<class GO>
907 : public ISTLBackend_SEQ_AMG<GO, Dune::SeqSOR, Dune::BiCGSTABSolver>
908 {
909
910 public:
919 ISTLBackend_SEQ_BCGS_AMG_SOR(unsigned maxiter_=5000, int verbose_=1,
920 bool reuse_=false, bool usesuperlu_=true)
921 : ISTLBackend_SEQ_AMG<GO, Dune::SeqSOR, Dune::BiCGSTABSolver>
922 (maxiter_, verbose_, reuse_, usesuperlu_)
923 {}
924 };
925
931 template<class GO>
933 : public ISTLBackend_SEQ_AMG<GO, Dune::SeqSSOR, Dune::LoopSolver>
934 {
935
936 public:
945 ISTLBackend_SEQ_LS_AMG_SSOR(unsigned maxiter_=5000, int verbose_=1,
946 bool reuse_=false, bool usesuperlu_=true)
947 : ISTLBackend_SEQ_AMG<GO, Dune::SeqSSOR, Dune::LoopSolver>
948 (maxiter_, verbose_, reuse_, usesuperlu_)
949 {}
950 };
951
957 template<class GO>
959 : public ISTLBackend_SEQ_AMG<GO, Dune::SeqSOR, Dune::LoopSolver>
960 {
961
962 public:
971 ISTLBackend_SEQ_LS_AMG_SOR(unsigned maxiter_=5000, int verbose_=1,
972 bool reuse_=false, bool usesuperlu_=true)
973 : ISTLBackend_SEQ_AMG<GO, Dune::SeqSOR, Dune::LoopSolver>
974 (maxiter_, verbose_, reuse_, usesuperlu_)
975 {}
976 };
977
984 : public SequentialNorm, public LinearResultStorage
985 {
986 public :
987
994 explicit ISTLBackend_SEQ_GMRES_ILU0(int restart_ = 200, int maxiter_ = 5000, int verbose_ = 1)
995 : restart(restart_), maxiter(maxiter_), verbose(verbose_)
996 {}
997
1005 template<class M, class V, class W>
1006 void apply(M& A, V& z, W& r, typename Dune::template FieldTraits<typename W::ElementType>::real_type reduction)
1007 {
1008 using Backend::Native;
1009 using Backend::native;
1010 Dune::MatrixAdapter<
1011 Native<M>,
1012 Native<V>,
1013 Native<W>
1014 > opa(native(A));
1015 Dune::SeqILU<
1016 Native<M>,
1017 Native<V>,
1018 Native<W>
1019 > ilu0(native(A), 1.0);
1020 Dune::RestartedGMResSolver<Native<V>> solver(opa,ilu0,reduction,restart,maxiter,verbose);
1021 Dune::InverseOperatorResult stat;
1022 solver.apply(native(z), native(r), stat);
1023 res.converged = stat.converged;
1024 res.iterations = stat.iterations;
1025 res.elapsed = stat.elapsed;
1026 res.reduction = stat.reduction;
1027 res.conv_rate = stat.conv_rate;
1028 }
1029
1030 private :
1031 int restart, maxiter, verbose;
1032 };
1033
1034 //============================
1035 // Matrix free solver backends
1036 //============================
1037
1038 template <class GO>
1040 : public ISTLBackend_SEQ_MatrixFree_Richardson<GO, Dune::BiCGSTABSolver>
1041 {
1042 public:
1048 explicit ISTLBackend_SEQ_MatrixFree_BCGS_Richardson (const GO& go_, unsigned maxiter_=5000, int verbose_=1)
1049 : ISTLBackend_SEQ_MatrixFree_Richardson<GO, Dune::BiCGSTABSolver>(go_, maxiter_, verbose_)
1050 {}
1051 };
1052
1053
1056
1057 } // namespace PDELab
1058} // namespace Dune
1059
1060#endif // DUNE_PDELAB_BACKEND_ISTL_SEQISTLSOLVERBACKEND_HH
VTKWriter & w
Definition function.hh:842
For backward compatibility – Do not use this!
Definition adaptivity.hh:28
std::enable_if< std::is_base_of< impl::WrapperBase, T >::value, Native< T > & >::type native(T &t)
Definition backend/interface.hh:192
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
Definition seqistlsolverbackend.hh:46
X domain_type
Definition seqistlsolverbackend.hh:48
X::field_type field_type
Definition seqistlsolverbackend.hh:50
virtual void apply(const X &x, Y &y) const override
Definition seqistlsolverbackend.hh:66
static constexpr bool isLinear
Definition seqistlsolverbackend.hh:51
OnTheFlyOperator(const GO &go_)
Definition seqistlsolverbackend.hh:54
virtual void applyscaleadd(field_type alpha, const X &x, Y &y) const override
Definition seqistlsolverbackend.hh:78
Y range_type
Definition seqistlsolverbackend.hh:49
void setLinearizationPoint(const X &u)
Definition seqistlsolverbackend.hh:61
SolverCategory::Category category() const override
Definition seqistlsolverbackend.hh:92
Definition seqistlsolverbackend.hh:114
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:133
ISTLBackend_SEQ_Richardson(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:121
Definition seqistlsolverbackend.hh:160
void setLinearizationPoint(const V &u)
Set position of jacobian, ust be called before apply() for nonlinear problems.
Definition seqistlsolverbackend.hh:196
ISTLBackend_SEQ_MatrixFree_Richardson(const GO &go, unsigned maxiter=5000, int verbose=1)
make a linear solver object
Definition seqistlsolverbackend.hh:169
void apply(V &z, W &r, typename Dune::template FieldTraits< typename W::ElementType >::real_type reduction)
solve the given linear system
Definition seqistlsolverbackend.hh:182
Definition seqistlsolverbackend.hh:211
ISTLBackend_SEQ_Base(unsigned maxiter_=5000, int verbose_=1, unsigned preconditioner_steps_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:218
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:232
Definition seqistlsolverbackend.hh:263
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:281
ISTLBackend_SEQ_ILU0(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:270
Definition seqistlsolverbackend.hh:309
ISTLBackend_SEQ_ILUn(int n, double w, unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:317
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:328
Backend for sequential loop solver with Jacobi preconditioner.
Definition seqistlsolverbackend.hh:369
ISTLBackend_SEQ_LOOP_Jac(unsigned maxiter_=5000, int verbose_=1, unsigned preconditioner_steps_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:375
Backend for sequential BiCGSTAB solver with Richardson precondition (equivalent to no preconditioner ...
Definition seqistlsolverbackend.hh:387
ISTLBackend_SEQ_BCGS_Richardson(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:393
Backend for sequential BiCGSTAB solver with Jacobi preconditioner.
Definition seqistlsolverbackend.hh:403
ISTLBackend_SEQ_BCGS_Jac(unsigned maxiter_=5000, int verbose_=1, unsigned preconditioner_steps_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:409
Backend for sequential BiCGSTAB solver with SSOR preconditioner.
Definition seqistlsolverbackend.hh:419
ISTLBackend_SEQ_BCGS_SSOR(unsigned maxiter_=5000, int verbose_=1, unsigned preconditioner_steps_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:426
Backend for sequential BiCGSTAB solver with ILU0 preconditioner.
Definition seqistlsolverbackend.hh:436
ISTLBackend_SEQ_BCGS_ILU0(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:443
Backend for sequential conjugate gradient solver with ILU0 preconditioner.
Definition seqistlsolverbackend.hh:453
ISTLBackend_SEQ_CG_ILU0(unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:460
Sequential BiCGStab solver with ILU0 preconditioner.
Definition seqistlsolverbackend.hh:468
ISTLBackend_SEQ_BCGS_ILUn(int n_, double w_=1.0, unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:478
Sequential congute gradient solver with ILU0 preconditioner.
Definition seqistlsolverbackend.hh:486
ISTLBackend_SEQ_CG_ILUn(int n_, double w_=1.0, unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:496
Backend for sequential conjugate gradient solver with SSOR preconditioner.
Definition seqistlsolverbackend.hh:506
ISTLBackend_SEQ_CG_SSOR(unsigned maxiter_=5000, int verbose_=1, unsigned preconditioner_steps_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:513
Backend using a MINRes solver preconditioned by SSOR.
Definition seqistlsolverbackend.hh:523
ISTLBackend_SEQ_MINRES_SSOR(unsigned maxiter_=5000, int verbose_=1, unsigned preconditioner_steps_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:530
Backend for conjugate gradient solver with Jacobi preconditioner.
Definition seqistlsolverbackend.hh:540
ISTLBackend_SEQ_CG_Jac(unsigned maxiter_=5000, int verbose_=1, unsigned preconditioner_steps_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:546
Solver backend using SuperLU as a direct solver.
Definition seqistlsolverbackend.hh:557
ISTLBackend_SEQ_SuperLU(int verbose_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:563
ISTLBackend_SEQ_SuperLU(int maxiter, int verbose_)
make a linear solver object
Definition seqistlsolverbackend.hh:573
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:585
Solver backend using UMFPack as a direct solver.
Definition seqistlsolverbackend.hh:611
ISTLBackend_SEQ_UMFPack(int verbose_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:617
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:639
ISTLBackend_SEQ_UMFPack(int maxiter, int verbose_)
make a linear solver object
Definition seqistlsolverbackend.hh:627
Solver to be used for explicit time-steppers with (block-)diagonal mass matrix.
Definition seqistlsolverbackend.hh:661
ISTLBackend_SEQ_ExplicitDiagonal()
make a linear solver object
Definition seqistlsolverbackend.hh:665
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:676
Class providing some statistics of the AMG solver.
Definition seqistlsolverbackend.hh:701
double tprepare
The needed for computing the parallel information and for adapting the linear system.
Definition seqistlsolverbackend.hh:706
double tsetup
The time needed for building the AMG hierarchy (coarsening).
Definition seqistlsolverbackend.hh:712
int iterations
The number of iterations performed until convergence was reached.
Definition seqistlsolverbackend.hh:714
double tsolve
The time spent in solving the system (without building the hierarchy.
Definition seqistlsolverbackend.hh:710
bool directCoarseLevelSolver
True if a direct solver was used on the coarset level.
Definition seqistlsolverbackend.hh:716
int levels
the number of levels in the AMG hierarchy.
Definition seqistlsolverbackend.hh:708
Definition seqistlsolverbackend.hh:722
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:790
const ISTLAMGStatistics & statistics() const
Get statistics of the AMG solver (no of levels, timings).
Definition seqistlsolverbackend.hh:828
V::ElementType norm(const V &v) const
compute global norm of a vector
Definition seqistlsolverbackend.hh:778
void setReuse(bool reuse_)
Set whether the AMG should be reused again during call to apply().
Definition seqistlsolverbackend.hh:763
ISTLBackend_SEQ_AMG(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Definition seqistlsolverbackend.hh:735
bool getReuse() const
Return whether the AMG is reused during call to apply()
Definition seqistlsolverbackend.hh:769
void setparams(Parameters params_)
set AMG parameters
Definition seqistlsolverbackend.hh:757
Sequential conjugate gradient solver preconditioned with AMG smoothed by SSOR.
Definition seqistlsolverbackend.hh:856
ISTLBackend_SEQ_CG_AMG_SSOR(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Constructor.
Definition seqistlsolverbackend.hh:867
Sequential BiCGStab solver preconditioned with AMG smoothed by SSOR.
Definition seqistlsolverbackend.hh:882
ISTLBackend_SEQ_BCGS_AMG_SSOR(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Constructor.
Definition seqistlsolverbackend.hh:893
Sequential BiCGSTAB solver preconditioned with AMG smoothed by SOR.
Definition seqistlsolverbackend.hh:908
ISTLBackend_SEQ_BCGS_AMG_SOR(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Constructor.
Definition seqistlsolverbackend.hh:919
Sequential Loop solver preconditioned with AMG smoothed by SSOR.
Definition seqistlsolverbackend.hh:934
ISTLBackend_SEQ_LS_AMG_SSOR(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Constructor.
Definition seqistlsolverbackend.hh:945
Sequential Loop solver preconditioned with AMG smoothed by SOR.
Definition seqistlsolverbackend.hh:960
ISTLBackend_SEQ_LS_AMG_SOR(unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Constructor.
Definition seqistlsolverbackend.hh:971
Linear solver backend for Restarted GMRes preconditioned with ILU(0)
Definition seqistlsolverbackend.hh:985
ISTLBackend_SEQ_GMRES_ILU0(int restart_=200, int maxiter_=5000, int verbose_=1)
make linear solver object
Definition seqistlsolverbackend.hh:994
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:1006
Definition seqistlsolverbackend.hh:1041
ISTLBackend_SEQ_MatrixFree_BCGS_Richardson(const GO &go_, unsigned maxiter_=5000, int verbose_=1)
make a linear solver object
Definition seqistlsolverbackend.hh:1048
Definition solver.hh:17
RFType conv_rate
Definition solver.hh:36
bool converged
Definition solver.hh:32
RFType reduction
Definition solver.hh:35
unsigned int iterations
Definition solver.hh:33
double elapsed
Definition solver.hh:34
Definition solver.hh:54
Dune::PDELab::LinearSolverResult< double > res
Definition solver.hh:63
Definition recipe-operator-splitting.cc:108