dune-pdelab 2.10-git
Loading...
Searching...
No Matches
ovlp_amg_dg_backend.hh
Go to the documentation of this file.
1#ifndef DUNE_PDELAB_BACKEND_ISTL_OVLP_AMG_DG_BACKEND_HH
2#define DUNE_PDELAB_BACKEND_ISTL_OVLP_AMG_DG_BACKEND_HH
3
5#include <dune/common/math.hh>
6
8
19
20namespace Dune {
21 namespace PDELab {
22 //***********************************************************
23 // A data handle / function to communicate matrix entries
24 // in the overlap. It turned out that it is actually not
25 // required to do that, but anyway it is there now.
26 //***********************************************************
27
30 template<class GFS>
32 : public Dune::CommDataHandleIF<LocalGlobalMapDataHandle<GFS>,int>
33 {
34 public:
35 // some types from the grid view
36 typedef typename GFS::Traits::GridView GV;
37 typedef typename GV::IndexSet IndexSet;
38 typedef typename IndexSet::IndexType IndexType;
39 typedef typename GV::Grid Grid;
40 typedef typename Grid::Traits::GlobalIdSet GlobalIdSet;
41 typedef typename GlobalIdSet::IdType IdType;
42
44 typedef int DataType;
45
46 // map types
49
51 bool contains (int dim, int codim) const
52 {
53 return (codim==0);
54 }
55
57 bool fixedSize (int dim, int codim) const
58 {
59 return true;
60 }
61
66 template<class EntityType>
67 size_t size (EntityType& e) const
68 {
69 return 1;
70 }
71
73 template<class MessageBuffer, class EntityType>
74 void gather (MessageBuffer& buff, const EntityType& e) const
75 {
76 // fill map
77 IndexType myindex = indexSet.index(e);
78 IdType myid = globalIdSet.id(e);
79 l2g[myindex] = myid;
80 g2l[myid] = myindex;
81 //std::cout << gv.comm().rank() << ": gather local=" << myindex << " global=" << myid << std::endl;
82
83 buff.write(0); // this is a dummy, we are not interested in the data
84 }
85
90 template<class MessageBuffer, class EntityType>
91 void scatter (MessageBuffer& buff, const EntityType& e, size_t n)
92 {
93 DataType x;
94 buff.read(x); // this is a dummy, we are not interested in the data
95
96 IndexType myindex = indexSet.index(e);
97 IdType myid = globalIdSet.id(e);
98 l2g[myindex] = myid;
99 g2l[myid] = myindex;
100 //std::cout << gv.comm().rank() << ": scatter local=" << myindex << " global=" << myid << std::endl;
101 }
102
105 : gfs(gfs_), gv(gfs.gridView()), indexSet(gv.indexSet()),
106 grid(gv.grid()), globalIdSet(grid.globalIdSet()),
107 l2g(l2g_), g2l(g2l_)
108 {
109 }
110
111 private:
112 const GFS& gfs;
113 GV gv;
114 const IndexSet& indexSet;
115 const Grid& grid;
116 const GlobalIdSet& globalIdSet;
117 LocalToGlobalMap& l2g;
118 GlobalToLocalMap& g2l;
119 };
120
121
122 // A DataHandle class to exchange rows of a sparse matrix
123 template<class GFS, class M> // mapper type and vector type
125 : public Dune::CommDataHandleIF<MatrixExchangeDataHandle<GFS,M>,
126 std::pair<typename GFS::Traits::GridView::Grid::Traits::GlobalIdSet::IdType,
127 typename M::block_type> >
128 {
129 public:
130 // some types from the grid view
131 typedef typename GFS::Traits::GridView GV;
132 typedef typename GV::IndexSet IndexSet;
133 typedef typename IndexSet::IndexType IndexType;
134 typedef typename GV::Grid Grid;
135 typedef typename Grid::Traits::GlobalIdSet GlobalIdSet;
136 typedef typename GlobalIdSet::IdType IdType;
137
138 // some types from the matrix
139 typedef typename M::block_type B;
140
143
144 // map types
147
149 bool contains (int dim, int codim) const
150 {
151 return (codim==0);
152 }
153
155 bool fixedSize (int dim, int codim) const
156 {
157 return false;
158 }
159
164 template<class EntityType>
165 size_t size (EntityType& e) const
166 {
167 IndexType myindex = indexSet.index(e);
168 typename M::row_type myrow = m[myindex];
169 typename M::row_type::iterator endit=myrow.end();
170 size_t count=0;
171 for (typename M::row_type::iterator it=myrow.begin(); it!=endit; ++it)
172 {
173 typename LocalToGlobalMap::const_iterator find=l2g.find(it.index());
174 if (find!=l2g.end())
175 {
176 count++;
177 }
178 }
179 //std::cout << gv.comm().rank() << ": row=" << myindex << " size=" << count << std::endl;
180 return count;
181 }
182
184 template<class MessageBuffer, class EntityType>
185 void gather (MessageBuffer& buff, const EntityType& e) const
186 {
187 IndexType myindex = indexSet.index(e);
188 typename M::row_type myrow = m[myindex];
189 typename M::row_type::iterator endit=myrow.end();
190 for (typename M::row_type::iterator it=myrow.begin(); it!=endit; ++it)
191 {
192 typename LocalToGlobalMap::const_iterator find=l2g.find(it.index());
193 if (find!=l2g.end())
194 {
195 buff.write(std::make_pair(find->second,*it));
196 }
197 }
198 }
199
204 template<class MessageBuffer, class EntityType>
205 void scatter (MessageBuffer& buff, const EntityType& e, size_t n)
206 {
207 IndexType myindex = indexSet.index(e);
208 std::cout << gv.comm().rank() << ": begin scatter local=" << myindex << " size=" << n << std::endl;
209 DataType x;
210 for (size_t i=0; i<n; ++i)
211 {
212 buff.read(x);
213 std::cout << gv.comm().rank() << ": --> received global=" << x.first << std::endl;
214 typename GlobalToLocalMap::const_iterator find=g2l.find(x.first);
215 if (find!=g2l.end())
216 {
217 IndexType nbindex=find->second;
218 if (m.exists(myindex,nbindex))
219 {
220 m[myindex][nbindex] = x.second;
221 B block(x.second);
222 block -= m2[myindex][nbindex];
223 std::cout << gv.comm().rank() << ": compare i=" << myindex << " j=" << nbindex
224 << " norm=" << block.infinity_norm() << std::endl;
225
226 }
227 }
228 }
229 }
230
232 MatrixExchangeDataHandle (const GFS& gfs_, M& m_, const LocalToGlobalMap& l2g_, const GlobalToLocalMap& g2l_,M& m2_)
233 : gfs(gfs_), m(m_), gv(gfs.gridView()), indexSet(gv.indexSet()),
234 grid(gv.grid()), globalIdSet(grid.globalIdSet()),
235 l2g(l2g_), g2l(g2l_), m2(m2_)
236 {
237 }
238
239 private:
240 const GFS& gfs;
241 M& m;
242 GV gv;
243 const IndexSet& indexSet;
244 const Grid& grid;
245 const GlobalIdSet& globalIdSet;
246 const LocalToGlobalMap& l2g;
247 const GlobalToLocalMap& g2l;
248 M& m2;
249 };
250
251
254 template<class GFS, class T, class A, int n, int m>
257 {
258 typedef Dune::FieldMatrix<T,n,m> B;
259 typedef Dune::BCRSMatrix<B,A> M; // m is of type M
260 typedef typename LocalGlobalMapDataHandle<GFS>::LocalToGlobalMap LocalToGlobalMap;
261 typedef typename LocalGlobalMapDataHandle<GFS>::GlobalToLocalMap GlobalToLocalMap;
262
263 // build up two maps to associate local indices and global ids
264 LocalToGlobalMap l2g;
265 GlobalToLocalMap g2l;
266 LocalGlobalMapDataHandle<GFS> lgdh(gfs,l2g,g2l);
267 if (gfs.gridView().comm().size()>1)
268 gfs.gridView().communicate(lgdh,Dune::InteriorBorder_All_Interface,Dune::ForwardCommunication);
269
270 // exchange matrix entries
271 MatrixExchangeDataHandle<GFS,M> mexdh(gfs,matrix,l2g,g2l,matrix2);
272 if (gfs.gridView().comm().size()>1)
273 gfs.gridView().communicate(mexdh,Dune::InteriorBorder_All_Interface,Dune::ForwardCommunication);
274 }
275
276 //***********************************************************
277 // The DG/AMG preconditioner in the overlapping case
278 //***********************************************************
279
289 template<class DGGFS, class DGMatrix, class DGPrec, class DGCC,
290 class CGGFS, class CGPrec, class CGCC,
291 class P, class DGHelper, class Comm>
293 : public Dune::Preconditioner<Dune::PDELab::Backend::Vector<DGGFS,typename DGPrec::domain_type::field_type>,
294 Dune::PDELab::Backend::Vector<DGGFS,typename DGPrec::range_type::field_type>>
295 {
296 const DGGFS& dggfs;
297 DGMatrix& dgmatrix;
298 DGPrec& dgprec;
299 const DGCC& dgcc;
300 const CGGFS& cggfs;
301 CGPrec& cgprec;
302 const CGCC& cgcc;
303 P& p;
304 const DGHelper& dghelper;
305 const Comm& comm;
306 int n1,n2;
307
308 public:
315
316 // define the category
318 {
320 }
321
329 OvlpDGAMGPrec (const DGGFS& dggfs_, DGMatrix& dgmatrix_, DGPrec& dgprec_, const DGCC& dgcc_,
330 const CGGFS& cggfs_, CGPrec& cgprec_, const CGCC& cgcc_, P& p_,
331 const DGHelper& dghelper_, const Comm& comm_, int n1_, int n2_)
332 : dggfs(dggfs_), dgmatrix(dgmatrix_), dgprec(dgprec_), dgcc(dgcc_),
333 cggfs(cggfs_), cgprec(cgprec_), cgcc(cgcc_), p(p_), dghelper(dghelper_),
334 comm(comm_), n1(n1_), n2(n2_)
335 {
336 }
337
343 virtual void pre (V& x, W& b) override
344 {
345 using Backend::native;
346 dgprec.pre(native(x),native(b));
347 CGW cgd(cggfs,0.0);
348 CGV cgv(cggfs,0.0);
349 cgprec.pre(native(cgv),native(cgd));
350 }
351
357 virtual void apply (V& x, const W& b) override
358 {
359 using Backend::native;
360 // need local copies to store defect and solution
361 W d(b);
363 V v(x); // only to get correct size
364
365 // pre-smoothing on DG matrix
366 for (int i=0; i<n1; i++)
367 {
368 using Backend::native;
369 v = 0.0;
370 dgprec.apply(native(v),native(d));
372 if (dggfs.gridView().comm().size()>1)
373 dggfs.gridView().communicate(adddh,Dune::All_All_Interface,Dune::ForwardCommunication);
374 dgmatrix.mmv(native(v),native(d));
376 x += v;
377 }
378
379 // restrict defect to CG subspace
380 dghelper.maskForeignDOFs(d); // DG defect is additive for overlap 1, but in case we use more
381 CGW cgd(cggfs,0.0);
382 p.mtv(native(d),native(cgd));
384 if (cggfs.gridView().comm().size()>1)
385 cggfs.gridView().communicate(adddh,Dune::All_All_Interface,Dune::ForwardCommunication); // now we have consistent defect on coarse grid
387 comm.project(native(cgd));
388 CGV cgv(cggfs,0.0);
389
390
391 // call preconditioner
392 cgprec.apply(native(cgv),native(cgd));
393
394 // prolongate correction
395 p.mv(native(cgv),native(v));
396 dgmatrix.mmv(native(v),native(d));
398 x += v;
399
400 // post-smoothing on DG matrix
401 for (int i=0; i<n2; i++)
402 {
403 v = 0.0;
404 dgprec.apply(native(v),native(d));
406 if (dggfs.gridView().comm().size()>1)
407 dggfs.gridView().communicate(adddh,Dune::All_All_Interface,Dune::ForwardCommunication);
408 dgmatrix.mmv(native(v),native(d));
410 x += v;
411 }
412 }
413
419 virtual void post (V& x) override
420 {
421 dgprec.post(Backend::native(x));
422 CGV cgv(cggfs,0.0);
423 cgprec.post(Backend::native(cgv));
424 }
425 };
426
427//***********************************************************
428// The DG/AMG linear solver backend in the overlapping case
429//***********************************************************
430
454template<class DGGO, class DGCC, class CGGFS, class CGCC, class TransferLOP,
455 template<class,class,class,int> class DGPrec, template<class> class Solver, int s=96>
457 public Dune::PDELab::OVLPScalarProductImplementation<typename DGGO::Traits::TrialGridFunctionSpace>,
459{
460public:
461 // DG grid function space
462 typedef typename DGGO::Traits::TrialGridFunctionSpace GFS;
463
464 // vectors and matrices on DG level
465 typedef typename DGGO::Traits::Jacobian M; // wrapped istl DG matrix
466 typedef typename DGGO::Traits::Domain V; // wrapped istl DG vector
467 typedef Backend::Native<M> Matrix; // istl DG matrix
468 typedef Backend::Native<V> Vector; // istl DG vector
469 typedef typename Vector::field_type field_type;
470
471 // vectors and matrices on CG level
472 using CGV = Dune::PDELab::Backend::Vector<CGGFS,field_type>; // wrapped istl CG vector
473 typedef Backend::Native<CGV> CGVector; // istl CG vector
474
475 // prolongation matrix
478 typedef TransferLOP CGTODGLOP; // local operator
480 typedef typename PGO::Jacobian PMatrix; // wrapped ISTL prolongation matrix
481 typedef Backend::Native<PMatrix> P; // ISTL prolongation matrix
482
483 // CG subspace matrix
485 typedef typename Dune::MatMultMatResult<PTADG,P>::type CGMatrix; // istl coarse space matrix
486
487 // AMG in CG-subspace
494
495private:
496
497 const GFS& gfs;
498 DGGO& dggo;
499 const DGCC& dgcc;
500 CGGFS& cggfs;
501 const CGCC& cgcc;
503 Parameters amg_parameters;
504 unsigned maxiter;
505 int verbose;
506 bool reuse;
507 bool firstapply;
508 bool usesuperlu;
509 std::size_t low_order_space_entries_per_row;
510
511 // Parameters for DG smoother
512 double smoother_relaxation = 0.92; // Relaxation parameter of DG smoother
513 int n1=3; // Number of DG pre-smoothing steps
514 int n2=3; // Number of DG post-smoothing steps
515
516 CGTODGLOP cgtodglop; // local operator to assemble prolongation matrix
517 PGO pgo; // grid operator to assemble prolongation matrix
518 PMatrix pmatrix; // wrapped prolongation matrix
519
522 class EmptyLop : public Dune::PDELab::NumericalJacobianApplyVolume<EmptyLop>,
526 {
527 };
528
529 // grid operator with empty local operator for constraints assembly in parallel
531 // CG-subspace matrix
532 typedef typename CGGO::Jacobian CGM;
533 CGM acg;
534
535public:
536
537 // access to prolongation matrix
539 {
540 return pmatrix;
541 }
542
547 void setParameters(const Parameters& amg_parameters_)
548 {
549 amg_parameters = amg_parameters_;
550 }
551
559 const Parameters& parameters() const
560 {
561 return amg_parameters;
562 }
563
565 void setReuse(bool reuse_)
566 {
567 reuse = reuse_;
568 }
569
571 bool getReuse() const
572 {
573 return reuse;
574 }
575
578 ISTLBackend_OVLP_AMG_4_DG(DGGO& dggo_, const DGCC& dgcc_, CGGFS& cggfs_, const CGCC& cgcc_,
579 unsigned maxiter_=5000, int verbose_=1, bool reuse_=false,
580 bool usesuperlu_=true)
581 : Dune::PDELab::OVLPScalarProductImplementation<typename DGGO::Traits::TrialGridFunctionSpace>(dggo_.trialGridFunctionSpace())
582 , gfs(dggo_.trialGridFunctionSpace())
583 , dggo(dggo_)
584 , dgcc(dgcc_)
585 , cggfs(cggfs_)
586 , cgcc(cgcc_)
587 , amg_parameters(15,2000)
588 , maxiter(maxiter_)
589 , verbose(verbose_)
590 , reuse(reuse_)
591 , firstapply(true)
592 , usesuperlu(usesuperlu_)
593 , low_order_space_entries_per_row(Dune::power(3,GFS::Traits::GridView::dimension))
594 , cgtodglop()
595 , pgo(cggfs,dggo.trialGridFunctionSpace(),cgtodglop,MBE(low_order_space_entries_per_row))
596 , pmatrix(pgo)
597 , acg(Backend::attached_container())
598 {
599 amg_parameters.setDefaultValuesIsotropic(GFS::Traits::GridViewType::Traits::Grid::dimension);
600 amg_parameters.setDebugLevel(verbose_);
601#if !HAVE_SUPERLU
602 if (usesuperlu == true)
603 {
604 if (gfs.gridView().comm().rank()==0)
605 std::cout << "WARNING: You are using AMG without SuperLU!"
606 << " Please consider installing SuperLU,"
607 << " or set the usesuperlu flag to false"
608 << " to suppress this warning." << std::endl;
609 }
610#endif
611
612 // assemble prolongation matrix; this will not change from one apply to the next
613 pmatrix = 0.0;
614 if (verbose>0 && gfs.gridView().comm().rank()==0) std::cout << "allocated prolongation matrix of size " << pmatrix.N() << " x " << pmatrix.M() << std::endl;
615 CGV cgx(cggfs,0.0); // need vector to call jacobian
616 pgo.jacobian(cgx,pmatrix);
617 }
618
619
622 ISTLBackend_OVLP_AMG_4_DG(DGGO& dggo_, const DGCC& dgcc_, CGGFS& cggfs_, const CGCC& cgcc_,
623 const ParameterTree& params)
624 : Dune::PDELab::OVLPScalarProductImplementation<typename DGGO::Traits::TrialGridFunctionSpace>(dggo_.trialGridFunctionSpace())
625 , gfs(dggo_.trialGridFunctionSpace())
626 , dggo(dggo_)
627 , dgcc(dgcc_)
628 , cggfs(cggfs_)
629 , cgcc(cgcc_)
630 , maxiter(params.get<int>("max_iterations",5000))
631 , amg_parameters(15,2000)
632 , verbose(params.get<int>("verbose",1))
633 , reuse(params.get<bool>("reuse",false))
634 , firstapply(true)
635 , usesuperlu(params.get<bool>("use_superlu",true))
636 , low_order_space_entries_per_row(params.get<std::size_t>("low_order_space.entries_per_row",Dune::power(3,GFS::Traits::GridView::dimension)))
637 , cgtodglop()
638 , pgo(cggfs,dggo.trialGridFunctionSpace(),cgtodglop,MBE(low_order_space_entries_per_row))
639 , pmatrix(pgo)
640 , acg(Backend::attached_container())
641 {
642 amg_parameters.setDefaultValuesIsotropic(GFS::Traits::GridViewType::Traits::Grid::dimension);
643 amg_parameters.setDebugLevel(params.get<int>("verbose",1));
644#if !HAVE_SUPERLU
645 if (usesuperlu == true)
646 {
647 if (gfs.gridView().comm().rank()==0)
648 std::cout << "WARNING: You are using AMG without SuperLU!"
649 << " Please consider installing SuperLU,"
650 << " or set the usesuperlu flag to false"
651 << " to suppress this warning." << std::endl;
652 }
653#endif
654
655 // assemble prolongation matrix; this will not change from one apply to the next
656 pmatrix = 0.0;
657 if (verbose>0 && gfs.gridView().comm().rank()==0) std::cout << "allocated prolongation matrix of size " << pmatrix.N() << " x " << pmatrix.M() << std::endl;
658 CGV cgx(cggfs,0.0); // need vector to call jacobian
659 pgo.jacobian(cgx,pmatrix);
660 }
661
662
664 void setDGSmootherRelaxation(double relaxation_)
665 {
666 smoother_relaxation = relaxation_;
667 }
668
671 {
672 n1 = n1_;
673 }
674
677 {
678 n2 = n2_;
679 }
680
681
689 void apply (M& A, V& z, V& r, typename Dune::template FieldTraits<typename V::ElementType >::real_type reduction)
690 {
691 using Backend::native;
692 // make operator and scalar product for overlapping solver
694 POP pop(dgcc,A);
696 PSP psp(*this);
697
698 // compute CG matrix
699 // make grid operator with empty local operator => matrix data type and constraints assembly
700 EmptyLop emptylop;
701 CGGO cggo(cggfs,cgcc,cggfs,cgcc,emptylop,MBE(low_order_space_entries_per_row));
702
703 // do triple matrix product ACG = P^T ADG P; this is purely local
704 Dune::Timer watch;
705 watch.reset();
706 // only do triple matrix product if the matrix changes
707 double triple_product_time = 0.0;
708 // no need to set acg here back to zero, this is done in matMultmat
709 if(reuse == false || firstapply == true) {
710 PTADG ptadg;
711 Dune::transposeMatMultMat(ptadg,native(pmatrix),native(A)); // 1a
712 //Dune::transposeMatMultMat(ptadg,native(pmatrix),native(A2)); // 1b
713 Dune::matMultMat(native(acg),ptadg,native(pmatrix));
714 triple_product_time = watch.elapsed();
715 if (verbose>0 && gfs.gridView().comm().rank()==0)
716 std::cout << "=== triple matrix product " << triple_product_time << " s" << std::endl;
717 //Dune::printmatrix(std::cout,native(acg),"triple product matrix","row",10,2);
718 CGV cgx(cggfs,0.0); // need vector to call jacobian
719 cggo.jacobian(cgx,acg); // insert trivial rows at processor boundaries
720 //std::cout << "CG constraints: " << cgcc.size() << " out of " << cggfs.globalSize() << std::endl;
721 }
722 else if(verbose>0 && gfs.gridView().comm().rank()==0)
723 std::cout << "=== reuse CG matrix, SKIPPING triple matrix product " << std::endl;
724
725 // NOW we need to insert the processor boundary conditions in DG matrix
727 DGGOEmpty dggoempty(gfs,dgcc,gfs,dgcc,emptylop,MBE(1 << GFS::Traits::GridView::dimension));
728 dggoempty.jacobian(z,A);
729
730 // and in the residual
732
733 // now set up parallel AMG solver for the CG subspace
734 Comm oocc(gfs.gridView().comm());
736 CGHELPER cghelper(cggfs,2);
737 cghelper.createIndexSetAndProjectForAMG(acg,oocc);
738 ParCGOperator paroop(native(acg),oocc);
740
741 typedef typename Dune::Amg::SmootherTraits<ParSmoother>::Arguments SmootherArgs;
742 SmootherArgs smootherArgs;
743 smootherArgs.iterations = 1;
744 smootherArgs.relaxationFactor = 1.0;
746 Criterion criterion(amg_parameters);
747 watch.reset();
748
749 // only construct a new AMG for the CG-subspace if the matrix changes
750 double amg_setup_time = 0.0;
751 if(reuse == false || firstapply == true) {
752 amg.reset(new AMG(paroop,criterion,smootherArgs,oocc));
753 firstapply = false;
754 amg_setup_time = watch.elapsed();
755 if (verbose>0 && gfs.gridView().comm().rank()==0)
756 std::cout << "=== AMG setup " <<amg_setup_time << " s" << std::endl;
757 }
758 else if (verbose>0 && gfs.gridView().comm().rank()==0)
759 std::cout << "=== reuse CG matrix, SKIPPING AMG setup " << std::endl;
760
761 // set up hybrid DG/CG preconditioner
762 typedef DGPrec<Matrix,Vector,Vector,1> DGPrecType;
763 DGPrecType dgprec(native(A),1,smoother_relaxation);
766 HybridPrec hybridprec(gfs,native(A),dgprec,dgcc,cggfs,*amg,cgcc,native(pmatrix),
767 this->parallelHelper(),oocc,n1,n2);
768
769 // /********/
770 // /* Test */
771 // /********/
772 // Solver<CGVector> testsolver(paroop,sp,amg,1e-8,100,2);
773 // CGV cgxx(cggfs,0.0);
774 // CGV cgdd(cggfs,1.0);
775 // Dune::InverseOperatorResult statstat;
776 // testsolver.apply(native(cgxx),native(cgdd),statstat);
777 // /********/
778
779 // set up solver
780 int verb=verbose;
781 if (gfs.gridView().comm().rank()>0) verb=0;
782 Solver<V> solver(pop,psp,hybridprec,reduction,maxiter,verb);
783
784 // solve
786 watch.reset();
787 solver.apply(z,r,stat);
788 double amg_solve_time = watch.elapsed();
789 if (verbose>0 && gfs.gridView().comm().rank()==0) std::cout << "=== Hybrid total solve time " << amg_solve_time+amg_setup_time+triple_product_time << " s" << std::endl;
790 res.converged = stat.converged;
792 res.elapsed = amg_solve_time+amg_setup_time+triple_product_time;
793 res.reduction = stat.reduction;
794 res.conv_rate = stat.conv_rate;
795 }
796
797};
798}
799}
800#endif // DUNE_PDELAB_BACKEND_ISTL_OVLP_AMG_DG_BACKEND_HH
void matMultMat(BCRSMatrix< FieldMatrix< T, n, m >, A > &res, const BCRSMatrix< FieldMatrix< T, n, k >, A1 > &mat, const BCRSMatrix< FieldMatrix< T, k, m >, A2 > &matt, bool=false)
void transposeMatMultMat(BCRSMatrix< FieldMatrix< T, n, m >, A > &res, const BCRSMatrix< FieldMatrix< T, k, n >, A1 > &mat, const BCRSMatrix< FieldMatrix< T, k, m >, A2 > &matt, bool=false)
void setDebugLevel(int level)
void setDefaultValuesIsotropic(std::size_t dim, std::size_t diameter=2)
const P & p
Definition constraints.hh:148
static const int dim
Definition adaptivity.hh:84
void pop()
static constexpr size_type M()
size_t() const
const_iterator find(int proc) const
constexpr Base power(Base m, Exponent p)
constexpr auto get(std::integer_sequence< T, II... >, std::integral_constant< std::size_t, pos >={})
const std::string s
Definition function.hh:843
void set_constrained_dofs(const CG &cg, typename XG::ElementType x, XG &xg)
construct constraints from given boundary condition function
Definition constraints.hh:796
STL namespace.
void restore_overlap_entries(const GFS &gfs, Dune::BCRSMatrix< Dune::FieldMatrix< T, n, m >, A > &matrix, Dune::BCRSMatrix< Dune::FieldMatrix< T, n, m >, A > &matrix2)
Definition ovlp_amg_dg_backend.hh:255
typename impl::BackendVectorSelector< GridFunctionSpace, FieldType >::Type Vector
alias of the return type of BackendVectorSelector
Definition backend/interface.hh:106
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
For backward compatibility – Do not use this!
ForwardCommunication
InteriorBorder_All_Interface
All_All_Interface
std::string get(const std::string &key, const std::string &defaultValue) const
void reset() noexcept
double elapsed() const noexcept
Backend using (possibly nested) ISTL BCRSMatrices.
Definition bcrsmatrixbackend.hh:188
Definition ovlp_amg_dg_backend.hh:33
GV::IndexSet IndexSet
Definition ovlp_amg_dg_backend.hh:37
std::map< IndexType, IdType > LocalToGlobalMap
Definition ovlp_amg_dg_backend.hh:47
LocalGlobalMapDataHandle(const GFS &gfs_, LocalToGlobalMap &l2g_, GlobalToLocalMap &g2l_)
constructor
Definition ovlp_amg_dg_backend.hh:104
bool fixedSize(int dim, int codim) const
returns true if size per entity of given dim and codim is a constant
Definition ovlp_amg_dg_backend.hh:57
GlobalIdSet::IdType IdType
Definition ovlp_amg_dg_backend.hh:41
GFS::Traits::GridView GV
Definition ovlp_amg_dg_backend.hh:36
int DataType
export type of data for message buffer
Definition ovlp_amg_dg_backend.hh:44
std::map< IdType, IndexType > GlobalToLocalMap
Definition ovlp_amg_dg_backend.hh:48
void gather(MessageBuffer &buff, const EntityType &e) const
pack data from user to message buffer
Definition ovlp_amg_dg_backend.hh:74
size_t size(EntityType &e) const
Definition ovlp_amg_dg_backend.hh:67
bool contains(int dim, int codim) const
returns true if data for this codim should be communicated
Definition ovlp_amg_dg_backend.hh:51
Grid::Traits::GlobalIdSet GlobalIdSet
Definition ovlp_amg_dg_backend.hh:40
GV::Grid Grid
Definition ovlp_amg_dg_backend.hh:39
IndexSet::IndexType IndexType
Definition ovlp_amg_dg_backend.hh:38
void scatter(MessageBuffer &buff, const EntityType &e, size_t n)
Definition ovlp_amg_dg_backend.hh:91
Definition ovlp_amg_dg_backend.hh:128
bool contains(int dim, int codim) const
returns true if data for this codim should be communicated
Definition ovlp_amg_dg_backend.hh:149
MatrixExchangeDataHandle(const GFS &gfs_, M &m_, const LocalToGlobalMap &l2g_, const GlobalToLocalMap &g2l_, M &m2_)
constructor
Definition ovlp_amg_dg_backend.hh:232
std::map< IndexType, IdType > LocalToGlobalMap
Definition ovlp_amg_dg_backend.hh:145
M::block_type B
Definition ovlp_amg_dg_backend.hh:139
GV::Grid Grid
Definition ovlp_amg_dg_backend.hh:134
void scatter(MessageBuffer &buff, const EntityType &e, size_t n)
Definition ovlp_amg_dg_backend.hh:205
void gather(MessageBuffer &buff, const EntityType &e) const
pack data from user to message buffer
Definition ovlp_amg_dg_backend.hh:185
Grid::Traits::GlobalIdSet GlobalIdSet
Definition ovlp_amg_dg_backend.hh:135
std::map< IdType, IndexType > GlobalToLocalMap
Definition ovlp_amg_dg_backend.hh:146
std::pair< IdType, B > DataType
export type of data for message buffer
Definition ovlp_amg_dg_backend.hh:142
GV::IndexSet IndexSet
Definition ovlp_amg_dg_backend.hh:132
IndexSet::IndexType IndexType
Definition ovlp_amg_dg_backend.hh:133
GlobalIdSet::IdType IdType
Definition ovlp_amg_dg_backend.hh:136
bool fixedSize(int dim, int codim) const
returns true if size per entity of given dim and codim is a constant
Definition ovlp_amg_dg_backend.hh:155
GFS::Traits::GridView GV
Definition ovlp_amg_dg_backend.hh:131
size_t size(EntityType &e) const
Definition ovlp_amg_dg_backend.hh:165
Definition ovlp_amg_dg_backend.hh:295
virtual void pre(V &x, W &b) override
Prepare the preconditioner.
Definition ovlp_amg_dg_backend.hh:343
Dune::PDELab::Backend::Vector< CGGFS, typename CGPrec::domain_type::field_type > CGV
Definition ovlp_amg_dg_backend.hh:313
virtual void apply(V &x, const W &b) override
Apply the precondioner.
Definition ovlp_amg_dg_backend.hh:357
SolverCategory::Category category() const override
Definition ovlp_amg_dg_backend.hh:317
Dune::PDELab::Backend::Vector< DGGFS, typename DGPrec::range_type::field_type > W
Definition ovlp_amg_dg_backend.hh:310
Backend::Native< V > X
Definition ovlp_amg_dg_backend.hh:311
Backend::Native< W > Y
Definition ovlp_amg_dg_backend.hh:312
Dune::PDELab::Backend::Vector< CGGFS, typename CGPrec::range_type::field_type > CGW
Definition ovlp_amg_dg_backend.hh:314
virtual void post(V &x) override
Clean up.
Definition ovlp_amg_dg_backend.hh:419
Dune::PDELab::Backend::Vector< DGGFS, typename DGPrec::domain_type::field_type > V
Definition ovlp_amg_dg_backend.hh:309
OvlpDGAMGPrec(const DGGFS &dggfs_, DGMatrix &dgmatrix_, DGPrec &dgprec_, const DGCC &dgcc_, const CGGFS &cggfs_, CGPrec &cgprec_, const CGCC &cgcc_, P &p_, const DGHelper &dghelper_, const Comm &comm_, int n1_, int n2_)
Constructor.
Definition ovlp_amg_dg_backend.hh:329
Definition ovlp_amg_dg_backend.hh:459
Dune::SeqSSOR< CGMatrix, CGVector, CGVector, 1 > Smoother
Definition ovlp_amg_dg_backend.hh:490
Dune::TransposedMatMultMatResult< P, Matrix >::type PTADG
Definition ovlp_amg_dg_backend.hh:484
Dune::BlockPreconditioner< CGVector, CGVector, Comm, Smoother > ParSmoother
Definition ovlp_amg_dg_backend.hh:491
Dune::Amg::AMG< ParCGOperator, CGVector, ParSmoother, Comm > AMG
Definition ovlp_amg_dg_backend.hh:492
DGGO::Traits::TrialGridFunctionSpace GFS
Definition ovlp_amg_dg_backend.hh:462
DGGO::Traits::Jacobian M
Definition ovlp_amg_dg_backend.hh:465
Backend::Native< CGV > CGVector
Definition ovlp_amg_dg_backend.hh:473
void setDGSmootherRelaxation(double relaxation_)
set number of presmoothing steps on the DG level
Definition ovlp_amg_dg_backend.hh:664
Dune::PDELab::ISTL::BCRSMatrixBackend MBE
Definition ovlp_amg_dg_backend.hh:476
Backend::Native< V > Vector
Definition ovlp_amg_dg_backend.hh:468
Dune::PDELab::Backend::Vector< CGGFS, field_type > CGV
Definition ovlp_amg_dg_backend.hh:472
Backend::Native< M > Matrix
Definition ovlp_amg_dg_backend.hh:467
void setNoDGPostSmoothSteps(int n2_)
set number of postsmoothing steps on the DG level
Definition ovlp_amg_dg_backend.hh:676
bool getReuse() const
Return whether the AMG is reused during call to apply()
Definition ovlp_amg_dg_backend.hh:571
Vector::field_type field_type
Definition ovlp_amg_dg_backend.hh:469
Backend::Native< PMatrix > P
Definition ovlp_amg_dg_backend.hh:481
DGGO::Traits::Domain V
Definition ovlp_amg_dg_backend.hh:466
Dune::OverlappingSchwarzOperator< CGMatrix, CGVector, CGVector, Comm > ParCGOperator
Definition ovlp_amg_dg_backend.hh:489
ISTLBackend_OVLP_AMG_4_DG(DGGO &dggo_, const DGCC &dgcc_, CGGFS &cggfs_, const CGCC &cgcc_, unsigned maxiter_=5000, int verbose_=1, bool reuse_=false, bool usesuperlu_=true)
Definition ovlp_amg_dg_backend.hh:578
Dune::Amg::Parameters Parameters
Definition ovlp_amg_dg_backend.hh:493
void setNoDGPreSmoothSteps(int n1_)
set number of presmoothing steps on the DG level
Definition ovlp_amg_dg_backend.hh:670
Dune::PDELab::GridOperator< CGGFS, GFS, CGTODGLOP, MBE, field_type, field_type, field_type, CC, CC > PGO
Definition ovlp_amg_dg_backend.hh:479
void apply(M &A, V &z, V &r, typename Dune::template FieldTraits< typename V::ElementType >::real_type reduction)
solve the given linear system
Definition ovlp_amg_dg_backend.hh:689
Dune::MatMultMatResult< PTADG, P >::type CGMatrix
Definition ovlp_amg_dg_backend.hh:485
PMatrix & prolongation_matrix()
Definition ovlp_amg_dg_backend.hh:538
void setReuse(bool reuse_)
Set whether the AMG should be reused again during call to apply().
Definition ovlp_amg_dg_backend.hh:565
TransferLOP CGTODGLOP
Definition ovlp_amg_dg_backend.hh:478
void setParameters(const Parameters &amg_parameters_)
set AMG parameters
Definition ovlp_amg_dg_backend.hh:547
Dune::PDELab::ISTL::CommSelector< s, Dune::MPIHelper::isFake >::type Comm
Definition ovlp_amg_dg_backend.hh:488
Dune::PDELab::EmptyTransformation CC
Definition ovlp_amg_dg_backend.hh:477
const Parameters & parameters() const
Get the parameters describing the behaviuour of AMG.
Definition ovlp_amg_dg_backend.hh:559
PGO::Jacobian PMatrix
Definition ovlp_amg_dg_backend.hh:480
ISTLBackend_OVLP_AMG_4_DG(DGGO &dggo_, const DGCC &dgcc_, CGGFS &cggfs_, const CGCC &cgcc_, const ParameterTree &params)
Definition ovlp_amg_dg_backend.hh:622
Definition ovlpistlsolverbackend.hh:43
Definition ovlpistlsolverbackend.hh:385
const ISTL::ParallelHelper< DGGO::Traits::TrialGridFunctionSpace > & parallelHelper() const
Definition ovlpistlsolverbackend.hh:415
Definition ovlpistlsolverbackend.hh:435
Definition parallelhelper.hh:51
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 constraintstransformation.hh:112
Definition genericdatahandle.hh:667
Standard grid operator implementation.
Definition gridoperator.hh:36
void jacobian(const Domain &x, Jacobian &a) const
Assembler jacobian.
Definition gridoperator.hh:184
Dune::PDELab::Backend::Matrix< MBE, Domain, Range, field_type > Jacobian
The type of the jacobian.
Definition gridoperator.hh:47
Default flags for all local operators.
Definition flags.hh:19
Default class for additional methods in instationary local operators.
Definition idefault.hh:90
Implements linear and nonlinear versions of jacobian_apply_volume() based on alpha_volume()
Definition numericaljacobianapply.hh:34
sparsity pattern generator
Definition pattern.hh:14
T end(T... args)
T endl(T... args)
T find(T... args)
T make_pair(T... args)
T reset(T... args)