Dune Core Modules (2.5.2)

overlappingschwarz.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_ISTL_OVERLAPPINGSCHWARZ_HH
4 #define DUNE_ISTL_OVERLAPPINGSCHWARZ_HH
5 #include <cassert>
6 #include <algorithm>
7 #include <functional>
8 #include <vector>
9 #include <set>
10 #include <dune/common/dynmatrix.hh>
11 #include <dune/common/sllist.hh>
12 #include <dune/common/unused.hh>
13 #include "preconditioners.hh"
14 #include "superlu.hh"
15 #include "umfpack.hh"
16 #include "bvector.hh"
17 #include "bcrsmatrix.hh"
18 #include "ilusubdomainsolver.hh"
19 #include <dune/istl/solvertype.hh>
20 
21 namespace Dune
22 {
23 
35  template<class M, class X, class TM, class TD, class TA>
36  class SeqOverlappingSchwarz;
37 
41  template<class I, class S, class D>
43  {
44  public:
46  typedef D subdomain_vector;
47 
48  typedef I InitializerList;
49  typedef typename InitializerList::value_type AtomInitializer;
50  typedef typename AtomInitializer::Matrix Matrix;
51  typedef typename Matrix::const_iterator Iter;
52  typedef typename Matrix::row_type::const_iterator CIter;
53 
54  typedef S IndexSet;
55  typedef typename IndexSet::size_type size_type;
56 
57  OverlappingSchwarzInitializer(InitializerList& il,
58  const IndexSet& indices,
59  const subdomain_vector& domains);
60 
61 
62  void addRowNnz(const Iter& row);
63 
64  void allocate();
65 
66  void countEntries(const Iter& row, const CIter& col) const;
67 
68  void calcColstart() const;
69 
70  void copyValue(const Iter& row, const CIter& col) const;
71 
72  void createMatrix() const;
73  private:
74  class IndexMap
75  {
76  public:
77  typedef typename S::size_type size_type;
78  typedef std::map<size_type,size_type> Map;
79  typedef typename Map::iterator iterator;
80  typedef typename Map::const_iterator const_iterator;
81 
82  IndexMap();
83 
84  void insert(size_type grow);
85 
86  const_iterator find(size_type grow) const;
87 
88  iterator find(size_type grow);
89 
90  iterator begin();
91 
92  const_iterator begin() const;
93 
94  iterator end();
95 
96  const_iterator end() const;
97 
98  private:
99  std::map<size_type,size_type> map_;
100  size_type row;
101  };
102 
103 
104  typedef typename InitializerList::iterator InitIterator;
105  typedef typename IndexSet::const_iterator IndexIteratur;
106  InitializerList* initializers;
107  const IndexSet *indices;
108  mutable std::vector<IndexMap> indexMaps;
109  const subdomain_vector& domains;
110  };
111 
116  {};
117 
122  {};
123 
129  {};
130 
135  template<class M, class X, class Y>
137 
138  // Specialization for BCRSMatrix
139  template<class K, int n, class Al, class X, class Y>
140  class DynamicMatrixSubdomainSolver< BCRSMatrix< FieldMatrix<K,n,n>, Al>, X, Y >
141  {
142  typedef BCRSMatrix< FieldMatrix<K,n,n>, Al> M;
143  public:
145  typedef typename std::remove_const<M>::type matrix_type;
146  typedef K field_type;
147  typedef typename std::remove_const<M>::type rilu_type;
149  typedef X domain_type;
151  typedef Y range_type;
152 
158  {
159  assert(v.size() > 0);
160  assert(v.size() == d.size());
161  assert(A.rows() <= v.size());
162  assert(A.cols() <= v.size());
163  size_t sz = A.rows();
164  v.resize(sz);
165  d.resize(sz);
166  A.solve(v,d);
167  v.resize(v.capacity());
168  d.resize(d.capacity());
169  }
170 
178  template<class S>
179  void setSubMatrix(const M& BCRS, S& rowset)
180  {
181  size_t sz = rowset.size();
182  A.resize(sz*n,sz*n);
183  typedef typename S::const_iterator SIter;
184  size_t r = 0, c = 0;
185  for(SIter rowIdx = rowset.begin(), rowEnd=rowset.end();
186  rowIdx!= rowEnd; ++rowIdx, r++)
187  {
188  c = 0;
189  for(SIter colIdx = rowset.begin(), colEnd=rowset.end();
190  colIdx!= colEnd; ++colIdx, c++)
191  {
192  if (BCRS[*rowIdx].find(*colIdx) == BCRS[*rowIdx].end())
193  continue;
194  for (size_t i=0; i<n; i++)
195  {
196  for (size_t j=0; j<n; j++)
197  {
198  A[r*n+i][c*n+j] = BCRS[*rowIdx][*colIdx][i][j];
199  }
200  }
201  }
202  }
203  }
204  private:
205  DynamicMatrix<K> A;
206  };
207 
208  template<typename T, bool tag>
209  class OverlappingAssignerHelper
210  {};
211 
212  template<typename T>
213  using OverlappingAssigner = OverlappingAssignerHelper<T, Dune::StoresColumnCompressed<T>::value>;
214 
215  // specialization for DynamicMatrix
216  template<class K, int n, class Al, class X, class Y>
217  class OverlappingAssignerHelper< DynamicMatrixSubdomainSolver< BCRSMatrix< FieldMatrix<K,n,n>, Al>, X, Y >,false>
218  {
219  public:
220  typedef BCRSMatrix< FieldMatrix<K,n,n>, Al> matrix_type;
221  typedef K field_type;
222  typedef Y range_type;
223  typedef typename range_type::block_type block_type;
224  typedef typename matrix_type::size_type size_type;
225 
233  OverlappingAssignerHelper(std::size_t maxlength, const BCRSMatrix<FieldMatrix<K,n,n>, Al>& mat_, const X& b_, Y& x_);
234 
238  inline
239  void deallocate();
240 
244  inline
245  void resetIndexForNextDomain();
246 
251  inline
252  DynamicVector<K> & lhs();
253 
258  inline
259  DynamicVector<K> & rhs();
260 
265  inline
266  void relaxResult(field_type relax);
267 
272  void operator()(const size_type& domainIndex);
273 
281  inline
282  void assignResult(block_type& res);
283 
284  private:
288  const matrix_type* mat;
290  // we need a pointer, because we have to avoid deep copies
291  DynamicVector<field_type> * rhs_;
293  // we need a pointer, because we have to avoid deep copies
294  DynamicVector<field_type> * lhs_;
296  const range_type* b;
298  range_type* x;
300  std::size_t i;
302  std::size_t maxlength_;
303  };
304 
305 #if HAVE_SUPERLU || HAVE_SUITESPARSE_UMFPACK
306  template<template<class> class S, int n, int m, typename T, typename A>
307  struct OverlappingAssignerHelper<S<BCRSMatrix<FieldMatrix<T,n,m>, A> >, true>
308  {
309  typedef BCRSMatrix<FieldMatrix<T,n,m>, A> matrix_type;
310  typedef typename S<BCRSMatrix<FieldMatrix<T,n,m>, A> >::range_type range_type;
311  typedef typename range_type::field_type field_type;
312  typedef typename range_type::block_type block_type;
313 
314  typedef typename matrix_type::size_type size_type;
315 
323  OverlappingAssignerHelper(std::size_t maxlength, const matrix_type& mat,
324  const range_type& b, range_type& x);
330  void deallocate();
331 
332  /*
333  * @brief Resets the local index to zero.
334  */
335  void resetIndexForNextDomain();
336 
341  field_type* lhs();
342 
347  field_type* rhs();
348 
353  void relaxResult(field_type relax);
354 
359  void operator()(const size_type& domain);
360 
368  void assignResult(block_type& res);
369 
370  private:
374  const matrix_type* mat;
376  field_type* rhs_;
378  field_type* lhs_;
380  const range_type* b;
382  range_type* x;
384  std::size_t i;
386  std::size_t maxlength_;
387  };
388 
389 #endif // HAVE_SUPERLU || HAVE_SUITESPARSE_UMFPACK
390 
391  template<class M, class X, class Y>
392  class OverlappingAssignerILUBase
393  {
394  public:
395  typedef M matrix_type;
396 
397  typedef typename M::field_type field_type;
398 
399  typedef typename Y::block_type block_type;
400 
401  typedef typename matrix_type::size_type size_type;
409  OverlappingAssignerILUBase(std::size_t maxlength, const M& mat,
410  const Y& b, X& x);
416  void deallocate();
417 
421  void resetIndexForNextDomain();
422 
427  X& lhs();
428 
433  Y& rhs();
434 
439  void relaxResult(field_type relax);
440 
445  void operator()(const size_type& domain);
446 
454  void assignResult(block_type& res);
455 
456  private:
460  const M* mat;
462  X* lhs_;
464  Y* rhs_;
466  const Y* b;
468  X* x;
470  size_type i;
471  };
472 
473  // specialization for ILU0
474  template<class M, class X, class Y>
475  class OverlappingAssignerHelper<ILU0SubdomainSolver<M,X,Y>, false>
476  : public OverlappingAssignerILUBase<M,X,Y>
477  {
478  public:
486  OverlappingAssignerHelper(std::size_t maxlength, const M& mat,
487  const Y& b, X& x)
488  : OverlappingAssignerILUBase<M,X,Y>(maxlength, mat,b,x)
489  {}
490  };
491 
492  // specialization for ILUN
493  template<class M, class X, class Y>
494  class OverlappingAssignerHelper<ILUNSubdomainSolver<M,X,Y>,false>
495  : public OverlappingAssignerILUBase<M,X,Y>
496  {
497  public:
505  OverlappingAssignerHelper(std::size_t maxlength, const M& mat,
506  const Y& b, X& x)
507  : OverlappingAssignerILUBase<M,X,Y>(maxlength, mat,b,x)
508  {}
509  };
510 
511  template<typename S, typename T>
512  struct AdditiveAdder
513  {};
514 
515  template<typename S, typename T, typename A, int n>
516  struct AdditiveAdder<S, BlockVector<FieldVector<T,n>,A> >
517  {
518  typedef typename A::size_type size_type;
519  AdditiveAdder(BlockVector<FieldVector<T,n>,A>& v, BlockVector<FieldVector<T,n>,A>& x,
520  OverlappingAssigner<S>& assigner, const T& relax_);
521  void operator()(const size_type& domain);
522  void axpy();
523 
524  private:
525  BlockVector<FieldVector<T,n>,A>* v;
526  BlockVector<FieldVector<T,n>,A>* x;
527  OverlappingAssigner<S>* assigner;
528  T relax;
529  };
530 
531  template<typename S,typename T>
532  struct MultiplicativeAdder
533  {};
534 
535  template<typename S, typename T, typename A, int n>
536  struct MultiplicativeAdder<S, BlockVector<FieldVector<T,n>,A> >
537  {
538  typedef typename A::size_type size_type;
539  MultiplicativeAdder(BlockVector<FieldVector<T,n>,A>& v, BlockVector<FieldVector<T,n>,A>& x,
540  OverlappingAssigner<S>& assigner_, const T& relax_);
541  void operator()(const size_type& domain);
542  void axpy();
543 
544  private:
545  BlockVector<FieldVector<T,n>,A>* x;
546  OverlappingAssigner<S>* assigner;
547  T relax;
548  };
549 
559  template<typename T, class X, class S>
561  {};
562 
563  template<class X, class S>
565  {
566  typedef AdditiveAdder<S,X> Adder;
567  };
568 
569  template<class X, class S>
570  struct AdderSelector<MultiplicativeSchwarzMode,X,S>
571  {
572  typedef MultiplicativeAdder<S,X> Adder;
573  };
574 
575  template<class X, class S>
576  struct AdderSelector<SymmetricMultiplicativeSchwarzMode,X,S>
577  {
578  typedef MultiplicativeAdder<S,X> Adder;
579  };
580 
592  template<typename T1, typename T2, bool forward>
594  {
595  typedef T1 solver_vector;
596  typedef typename solver_vector::iterator solver_iterator;
597  typedef T2 subdomain_vector;
598  typedef typename subdomain_vector::const_iterator domain_iterator;
599 
600  static solver_iterator begin(solver_vector& sv)
601  {
602  return sv.begin();
603  }
604 
605  static solver_iterator end(solver_vector& sv)
606  {
607  return sv.end();
608  }
609  static domain_iterator begin(const subdomain_vector& sv)
610  {
611  return sv.begin();
612  }
613 
614  static domain_iterator end(const subdomain_vector& sv)
615  {
616  return sv.end();
617  }
618  };
619 
620  template<typename T1, typename T2>
621  struct IteratorDirectionSelector<T1,T2,false>
622  {
623  typedef T1 solver_vector;
624  typedef typename solver_vector::reverse_iterator solver_iterator;
625  typedef T2 subdomain_vector;
626  typedef typename subdomain_vector::const_reverse_iterator domain_iterator;
627 
628  static solver_iterator begin(solver_vector& sv)
629  {
630  return sv.rbegin();
631  }
632 
633  static solver_iterator end(solver_vector& sv)
634  {
635  return sv.rend();
636  }
637  static domain_iterator begin(const subdomain_vector& sv)
638  {
639  return sv.rbegin();
640  }
641 
642  static domain_iterator end(const subdomain_vector& sv)
643  {
644  return sv.rend();
645  }
646  };
647 
656  template<class T>
658  {
659  typedef T smoother;
660  typedef typename smoother::range_type range_type;
661 
662  static void apply(smoother& sm, range_type& v, const range_type& b)
663  {
664  sm.template apply<true>(v, b);
665  }
666  };
667 
668  template<class M, class X, class TD, class TA>
670  {
672  typedef typename smoother::range_type range_type;
673 
674  static void apply(smoother& sm, range_type& v, const range_type& b)
675  {
676  sm.template apply<true>(v, b);
677  sm.template apply<false>(v, b);
678  }
679  };
680 
681  template<class T, bool tag>
682  struct SeqOverlappingSchwarzAssemblerHelper
683  {};
684 
685  template<class T>
686  using SeqOverlappingSchwarzAssembler = SeqOverlappingSchwarzAssemblerHelper<T,Dune::StoresColumnCompressed<T>::value>;
687 
688  template<class K, int n, class Al, class X, class Y>
689  struct SeqOverlappingSchwarzAssemblerHelper< DynamicMatrixSubdomainSolver< BCRSMatrix< FieldMatrix<K,n,n>, Al>, X, Y >,false>
690  {
691  typedef BCRSMatrix< FieldMatrix<K,n,n>, Al> matrix_type;
692  template<class RowToDomain, class Solvers, class SubDomains>
693  static std::size_t assembleLocalProblems(const RowToDomain& rowToDomain, const matrix_type& mat,
694  Solvers& solvers, const SubDomains& domains,
695  bool onTheFly);
696  };
697 
698  template<template<class> class S, typename T, typename A, int m, int n>
699  struct SeqOverlappingSchwarzAssemblerHelper<S<BCRSMatrix<FieldMatrix<T,m,n>,A> >,true>
700  {
701  typedef BCRSMatrix<FieldMatrix<T,m,n>,A> matrix_type;
702  template<class RowToDomain, class Solvers, class SubDomains>
703  static std::size_t assembleLocalProblems(const RowToDomain& rowToDomain, const matrix_type& mat,
704  Solvers& solvers, const SubDomains& domains,
705  bool onTheFly);
706  };
707 
708  template<class M,class X, class Y>
709  struct SeqOverlappingSchwarzAssemblerILUBase
710  {
711  typedef M matrix_type;
712  template<class RowToDomain, class Solvers, class SubDomains>
713  static std::size_t assembleLocalProblems(const RowToDomain& rowToDomain, const matrix_type& mat,
714  Solvers& solvers, const SubDomains& domains,
715  bool onTheFly);
716  };
717 
718  template<class M,class X, class Y>
719  struct SeqOverlappingSchwarzAssemblerHelper<ILU0SubdomainSolver<M,X,Y>,false>
720  : public SeqOverlappingSchwarzAssemblerILUBase<M,X,Y>
721  {};
722 
723  template<class M,class X, class Y>
724  struct SeqOverlappingSchwarzAssemblerHelper<ILUNSubdomainSolver<M,X,Y>,false>
725  : public SeqOverlappingSchwarzAssemblerILUBase<M,X,Y>
726  {};
727 
738  template<class M, class X, class TM=AdditiveSchwarzMode,
739  class TD=ILU0SubdomainSolver<M,X,X>, class TA=std::allocator<X> >
741  : public Preconditioner<X,X>
742  {
743  public:
747  typedef M matrix_type;
748 
752  typedef X domain_type;
753 
757  typedef X range_type;
758 
765  typedef TM Mode;
766 
770  typedef typename X::field_type field_type;
771 
773  typedef typename matrix_type::size_type size_type;
774 
776  typedef TA allocator;
777 
779  typedef std::set<size_type, std::less<size_type>,
780  typename TA::template rebind<size_type>::other>
782 
784  typedef std::vector<subdomain_type, typename TA::template rebind<subdomain_type>::other> subdomain_vector;
785 
788 
790  typedef std::vector<subdomain_list, typename TA::template rebind<subdomain_list>::other > rowtodomain_vector;
791 
793  typedef TD slu;
794 
796  typedef std::vector<slu, typename TA::template rebind<slu>::other> slu_vector;
797 
798  enum {
801  };
802 
816  SeqOverlappingSchwarz(const matrix_type& mat, const subdomain_vector& subDomains,
817  field_type relaxationFactor=1, bool onTheFly_=true);
818 
830  SeqOverlappingSchwarz(const matrix_type& mat, const rowtodomain_vector& rowToDomain,
831  field_type relaxationFactor=1, bool onTheFly_=true);
832 
838  virtual void pre (X& x, X& b)
839  {
842  }
843 
849  virtual void apply (X& v, const X& d);
850 
856  virtual void post (X& x)
857  {
859  }
860 
861  template<bool forward>
862  void apply(X& v, const X& d);
863 
864  private:
865  const M& mat;
866  slu_vector solvers;
867  subdomain_vector subDomains;
868  field_type relax;
869 
870  typename M::size_type maxlength;
871 
872  bool onTheFly;
873  };
874 
875 
876 
877  template<class I, class S, class D>
879  const IndexSet& idx,
880  const subdomain_vector& domains_)
881  : initializers(&il), indices(&idx), indexMaps(il.size()), domains(domains_)
882  {}
883 
884 
885  template<class I, class S, class D>
886  void OverlappingSchwarzInitializer<I,S,D>::addRowNnz(const Iter& row)
887  {
888  typedef typename IndexSet::value_type::const_iterator iterator;
889  for(iterator domain=(*indices)[row.index()].begin(); domain != (*indices)[row.index()].end(); ++domain) {
890  (*initializers)[*domain].addRowNnz(row, domains[*domain]);
891  indexMaps[*domain].insert(row.index());
892  }
893  }
894 
895  template<class I, class S, class D>
896  void OverlappingSchwarzInitializer<I,S,D>::allocate()
897  {
898  std::for_each(initializers->begin(), initializers->end(),
899  std::mem_fun_ref(&AtomInitializer::allocateMatrixStorage));
900  std::for_each(initializers->begin(), initializers->end(),
901  std::mem_fun_ref(&AtomInitializer::allocateMarker));
902  }
903 
904  template<class I, class S, class D>
905  void OverlappingSchwarzInitializer<I,S,D>::countEntries(const Iter& row, const CIter& col) const
906  {
907  typedef typename IndexSet::value_type::const_iterator iterator;
908  for(iterator domain=(*indices)[row.index()].begin(); domain != (*indices)[row.index()].end(); ++domain) {
909  typename std::map<size_type,size_type>::const_iterator v = indexMaps[*domain].find(col.index());
910  if(v!= indexMaps[*domain].end()) {
911  (*initializers)[*domain].countEntries(indexMaps[*domain].find(col.index())->second);
912  }
913  }
914  }
915 
916  template<class I, class S, class D>
917  void OverlappingSchwarzInitializer<I,S,D>::calcColstart() const
918  {
919  std::for_each(initializers->begin(), initializers->end(),
920  std::mem_fun_ref(&AtomInitializer::calcColstart));
921  }
922 
923  template<class I, class S, class D>
924  void OverlappingSchwarzInitializer<I,S,D>::copyValue(const Iter& row, const CIter& col) const
925  {
926  typedef typename IndexSet::value_type::const_iterator iterator;
927  for(iterator domain=(*indices)[row.index()].begin(); domain!= (*indices)[row.index()].end(); ++domain) {
928  typename std::map<size_type,size_type>::const_iterator v = indexMaps[*domain].find(col.index());
929  if(v!= indexMaps[*domain].end()) {
930  assert(indexMaps[*domain].end()!=indexMaps[*domain].find(row.index()));
931  (*initializers)[*domain].copyValue(col, indexMaps[*domain].find(row.index())->second,
932  v->second);
933  }
934  }
935  }
936 
937  template<class I, class S, class D>
938  void OverlappingSchwarzInitializer<I,S,D>::createMatrix() const
939  {
940  std::vector<IndexMap>().swap(indexMaps);
941  std::for_each(initializers->begin(), initializers->end(),
942  std::mem_fun_ref(&AtomInitializer::createMatrix));
943  }
944 
945  template<class I, class S, class D>
946  OverlappingSchwarzInitializer<I,S,D>::IndexMap::IndexMap()
947  : row(0)
948  {}
949 
950  template<class I, class S, class D>
951  void OverlappingSchwarzInitializer<I,S,D>::IndexMap::insert(size_type grow)
952  {
953  assert(map_.find(grow)==map_.end());
954  map_.insert(std::make_pair(grow, row++));
955  }
956 
957  template<class I, class S, class D>
958  typename OverlappingSchwarzInitializer<I,S,D>::IndexMap::const_iterator
959  OverlappingSchwarzInitializer<I,S,D>::IndexMap::find(size_type grow) const
960  {
961  return map_.find(grow);
962  }
963 
964  template<class I, class S, class D>
965  typename OverlappingSchwarzInitializer<I,S,D>::IndexMap::iterator
966  OverlappingSchwarzInitializer<I,S,D>::IndexMap::find(size_type grow)
967  {
968  return map_.find(grow);
969  }
970 
971  template<class I, class S, class D>
972  typename OverlappingSchwarzInitializer<I,S,D>::IndexMap::const_iterator
973  OverlappingSchwarzInitializer<I,S,D>::IndexMap::end() const
974  {
975  return map_.end();
976  }
977 
978  template<class I, class S, class D>
979  typename OverlappingSchwarzInitializer<I,S,D>::IndexMap::iterator
980  OverlappingSchwarzInitializer<I,S,D>::IndexMap::end()
981  {
982  return map_.end();
983  }
984 
985  template<class I, class S, class D>
986  typename OverlappingSchwarzInitializer<I,S,D>::IndexMap::const_iterator
987  OverlappingSchwarzInitializer<I,S,D>::IndexMap::begin() const
988  {
989  return map_.begin();
990  }
991 
992  template<class I, class S, class D>
993  typename OverlappingSchwarzInitializer<I,S,D>::IndexMap::iterator
994  OverlappingSchwarzInitializer<I,S,D>::IndexMap::begin()
995  {
996  return map_.begin();
997  }
998 
999  template<class M, class X, class TM, class TD, class TA>
1001  field_type relaxationFactor, bool fly)
1002  : mat(mat_), relax(relaxationFactor), onTheFly(fly)
1003  {
1004  typedef typename rowtodomain_vector::const_iterator RowDomainIterator;
1005  typedef typename subdomain_list::const_iterator DomainIterator;
1006 #ifdef DUNE_ISTL_WITH_CHECKING
1007  assert(rowToDomain.size()==mat.N());
1008  assert(rowToDomain.size()==mat.M());
1009 
1010  for(RowDomainIterator iter=rowToDomain.begin(); iter != rowToDomain.end(); ++iter)
1011  assert(iter->size()>0);
1012 
1013 #endif
1014  // calculate the number of domains
1015  size_type domains=0;
1016  for(RowDomainIterator iter=rowToDomain.begin(); iter != rowToDomain.end(); ++iter)
1017  for(DomainIterator d=iter->begin(); d != iter->end(); ++d)
1018  domains=std::max(domains, *d);
1019  ++domains;
1020 
1021  solvers.resize(domains);
1022  subDomains.resize(domains);
1023 
1024  // initialize subdomains to row mapping from row to subdomain mapping
1025  size_type row=0;
1026  for(RowDomainIterator iter=rowToDomain.begin(); iter != rowToDomain.end(); ++iter, ++row)
1027  for(DomainIterator d=iter->begin(); d != iter->end(); ++d)
1028  subDomains[*d].insert(row);
1029 
1030 #ifdef DUNE_ISTL_WITH_CHECKING
1031  size_type i=0;
1032  typedef typename subdomain_vector::const_iterator iterator;
1033  for(iterator iter=subDomains.begin(); iter != subDomains.end(); ++iter) {
1034  typedef typename subdomain_type::const_iterator entry_iterator;
1035  Dune::dvverb<<"domain "<<i++<<":";
1036  for(entry_iterator entry = iter->begin(); entry != iter->end(); ++entry) {
1037  Dune::dvverb<<" "<<*entry;
1038  }
1039  Dune::dvverb<<std::endl;
1040  }
1041 #endif
1042  maxlength = SeqOverlappingSchwarzAssembler<slu>
1043  ::assembleLocalProblems(rowToDomain, mat, solvers, subDomains, onTheFly);
1044  }
1045 
1046  template<class M, class X, class TM, class TD, class TA>
1048  const subdomain_vector& sd,
1049  field_type relaxationFactor,
1050  bool fly)
1051  : mat(mat_), solvers(sd.size()), subDomains(sd), relax(relaxationFactor),
1052  onTheFly(fly)
1053  {
1054  typedef typename subdomain_vector::const_iterator DomainIterator;
1055 
1056 #ifdef DUNE_ISTL_WITH_CHECKING
1057  size_type i=0;
1058 
1059  for(DomainIterator d=sd.begin(); d != sd.end(); ++d,++i) {
1060  //std::cout<<i<<": "<<d->size()<<std::endl;
1061  assert(d->size()>0);
1062  typedef typename DomainIterator::value_type::const_iterator entry_iterator;
1063  Dune::dvverb<<"domain "<<i<<":";
1064  for(entry_iterator entry = d->begin(); entry != d->end(); ++entry) {
1065  Dune::dvverb<<" "<<*entry;
1066  }
1067  Dune::dvverb<<std::endl;
1068  }
1069 
1070 #endif
1071 
1072  // Create a row to subdomain mapping
1073  rowtodomain_vector rowToDomain(mat.N());
1074 
1075  size_type domainId=0;
1076 
1077  for(DomainIterator domain=sd.begin(); domain != sd.end(); ++domain, ++domainId) {
1078  typedef typename subdomain_type::const_iterator iterator;
1079  for(iterator row=domain->begin(); row != domain->end(); ++row)
1080  rowToDomain[*row].push_back(domainId);
1081  }
1082 
1083  maxlength = SeqOverlappingSchwarzAssembler<slu>
1084  ::assembleLocalProblems(rowToDomain, mat, solvers, subDomains, onTheFly);
1085  }
1086 
1093  template<class M>
1095 
1096  template<typename T, typename A, int n, int m>
1098  {
1099  template<class Domain>
1100  static int size(const Domain & d)
1101  {
1102  assert(n==m);
1103  return m*d.size();
1104  }
1105  };
1106 
1107  template<class K, int n, class Al, class X, class Y>
1108  template<class RowToDomain, class Solvers, class SubDomains>
1109  std::size_t
1110  SeqOverlappingSchwarzAssemblerHelper< DynamicMatrixSubdomainSolver< BCRSMatrix< FieldMatrix<K,n,n>, Al>, X, Y >,false>::
1111  assembleLocalProblems(const RowToDomain& rowToDomain,
1112  const matrix_type& mat,
1113  Solvers& solvers,
1114  const SubDomains& subDomains,
1115  bool onTheFly)
1116  {
1117  DUNE_UNUSED_PARAMETER(onTheFly);
1118  DUNE_UNUSED_PARAMETER(rowToDomain);
1119  DUNE_UNUSED_PARAMETER(mat);
1120  DUNE_UNUSED_PARAMETER(solvers);
1121  typedef typename SubDomains::const_iterator DomainIterator;
1122  std::size_t maxlength = 0;
1123 
1124  assert(onTheFly);
1125 
1126  for(DomainIterator domain=subDomains.begin(); domain!=subDomains.end(); ++domain)
1127  maxlength=std::max(maxlength, domain->size());
1128  maxlength*=n;
1129 
1130  return maxlength;
1131  }
1132 
1133 #if HAVE_SUPERLU || HAVE_SUITESPARSE_UMFPACK
1134  template<template<class> class S, typename T, typename A, int m, int n>
1135  template<class RowToDomain, class Solvers, class SubDomains>
1136  std::size_t SeqOverlappingSchwarzAssemblerHelper<S<BCRSMatrix<FieldMatrix<T,m,n>,A> >,true>::assembleLocalProblems(const RowToDomain& rowToDomain,
1137  const matrix_type& mat,
1138  Solvers& solvers,
1139  const SubDomains& subDomains,
1140  bool onTheFly)
1141  {
1142  typedef typename S<BCRSMatrix<FieldMatrix<T,m,n>,A> >::MatrixInitializer MatrixInitializer;
1143  typedef typename std::vector<MatrixInitializer>::iterator InitializerIterator;
1144  typedef typename SubDomains::const_iterator DomainIterator;
1145  typedef typename Solvers::iterator SolverIterator;
1146  std::size_t maxlength = 0;
1147 
1148  if(onTheFly) {
1149  for(DomainIterator domain=subDomains.begin(); domain!=subDomains.end(); ++domain)
1150  maxlength=std::max(maxlength, domain->size());
1151  maxlength*=mat[0].begin()->N();
1152  }else{
1153  // initialize the initializers
1154  DomainIterator domain=subDomains.begin();
1155 
1156  // Create the initializers list.
1157  std::vector<MatrixInitializer> initializers(subDomains.size());
1158 
1159  SolverIterator solver=solvers.begin();
1160  for(InitializerIterator initializer=initializers.begin(); initializer!=initializers.end();
1161  ++initializer, ++solver, ++domain) {
1162  solver->getInternalMatrix().N_=SeqOverlappingSchwarzDomainSize<matrix_type>::size(*domain);
1163  solver->getInternalMatrix().M_=SeqOverlappingSchwarzDomainSize<matrix_type>::size(*domain);
1164  //solver->setVerbosity(true);
1165  *initializer=MatrixInitializer(solver->getInternalMatrix());
1166  }
1167 
1168  // Set up the supermatrices according to the subdomains
1169  typedef OverlappingSchwarzInitializer<std::vector<MatrixInitializer>,
1170  RowToDomain, SubDomains> Initializer;
1171 
1172  Initializer initializer(initializers, rowToDomain, subDomains);
1173  copyToColCompMatrix(initializer, mat);
1174 
1175  // Calculate the LU decompositions
1176  std::for_each(solvers.begin(), solvers.end(), std::mem_fun_ref(&S<BCRSMatrix<FieldMatrix<T,m,n>,A> >::decompose));
1177  for (SolverIterator solverIt = solvers.begin(); solverIt != solvers.end(); ++solverIt)
1178  {
1179  assert(solverIt->getInternalMatrix().N() == solverIt->getInternalMatrix().M());
1180  maxlength = std::max(maxlength, solverIt->getInternalMatrix().N());
1181  }
1182  }
1183  return maxlength;
1184  }
1185 
1186 #endif // HAVE_SUPERLU || HAVE_SUITESPARSE_UMFPACK
1187 
1188  template<class M,class X,class Y>
1189  template<class RowToDomain, class Solvers, class SubDomains>
1190  std::size_t SeqOverlappingSchwarzAssemblerILUBase<M,X,Y>::assembleLocalProblems(const RowToDomain& rowToDomain,
1191  const matrix_type& mat,
1192  Solvers& solvers,
1193  const SubDomains& subDomains,
1194  bool onTheFly)
1195  {
1196  DUNE_UNUSED_PARAMETER(rowToDomain);
1197  typedef typename SubDomains::const_iterator DomainIterator;
1198  typedef typename Solvers::iterator SolverIterator;
1199  std::size_t maxlength = 0;
1200 
1201  if(onTheFly) {
1202  for(DomainIterator domain=subDomains.begin(); domain!=subDomains.end(); ++domain)
1203  maxlength=std::max(maxlength, domain->size());
1204  }else{
1205  // initialize the solvers of the local prolems.
1206  SolverIterator solver=solvers.begin();
1207  for(DomainIterator domain=subDomains.begin(); domain!=subDomains.end();
1208  ++domain, ++solver) {
1209  solver->setSubMatrix(mat, *domain);
1210  maxlength=std::max(maxlength, domain->size());
1211  }
1212  }
1213 
1214  return maxlength;
1215 
1216  }
1217 
1218 
1219  template<class M, class X, class TM, class TD, class TA>
1221  {
1223  }
1224 
1225  template<class M, class X, class TM, class TD, class TA>
1226  template<bool forward>
1227  void SeqOverlappingSchwarz<M,X,TM,TD,TA>::apply(X& x, const X& b)
1228  {
1229  typedef slu_vector solver_vector;
1230  typedef typename IteratorDirectionSelector<solver_vector,subdomain_vector,forward>::solver_iterator iterator;
1231  typedef typename IteratorDirectionSelector<solver_vector,subdomain_vector,forward>::domain_iterator
1232  domain_iterator;
1233 
1234  OverlappingAssigner<TD> assigner(maxlength, mat, b, x);
1235 
1238  X v(x); // temporary for the update
1239  v=0;
1240 
1241  typedef typename AdderSelector<TM,X,TD >::Adder Adder;
1242  Adder adder(v, x, assigner, relax);
1243 
1244  for(; domain != IteratorDirectionSelector<solver_vector,subdomain_vector,forward>::end(subDomains); ++domain) {
1245  //Copy rhs to C-array for SuperLU
1246  std::for_each(domain->begin(), domain->end(), assigner);
1247  assigner.resetIndexForNextDomain();
1248  if(onTheFly) {
1249  // Create the subdomain solver
1250  slu sdsolver;
1251  sdsolver.setSubMatrix(mat, *domain);
1252  // Apply
1253  sdsolver.apply(assigner.lhs(), assigner.rhs());
1254  }else{
1255  solver->apply(assigner.lhs(), assigner.rhs());
1256  ++solver;
1257  }
1258 
1259  //Add relaxed correction to from SuperLU to v
1260  std::for_each(domain->begin(), domain->end(), adder);
1261  assigner.resetIndexForNextDomain();
1262 
1263  }
1264 
1265  adder.axpy();
1266  assigner.deallocate();
1267  }
1268 
1269  template<class K, int n, class Al, class X, class Y>
1270  OverlappingAssignerHelper< DynamicMatrixSubdomainSolver< BCRSMatrix< FieldMatrix<K,n,n>, Al>, X, Y >,false>
1271  ::OverlappingAssignerHelper(std::size_t maxlength, const BCRSMatrix<FieldMatrix<K,n,n>, Al>& mat_,
1272  const X& b_, Y& x_) :
1273  mat(&mat_),
1274  rhs_( new DynamicVector<field_type>(maxlength, 42) ),
1275  lhs_( new DynamicVector<field_type>(maxlength, -42) ),
1276  b(&b_),
1277  x(&x_),
1278  i(0),
1279  maxlength_(maxlength)
1280  {}
1281 
1282  template<class K, int n, class Al, class X, class Y>
1283  void
1284  OverlappingAssignerHelper< DynamicMatrixSubdomainSolver< BCRSMatrix< FieldMatrix<K,n,n>, Al>, X, Y >,false>
1285  ::deallocate()
1286  {
1287  delete rhs_;
1288  delete lhs_;
1289  }
1290 
1291  template<class K, int n, class Al, class X, class Y>
1292  void
1293  OverlappingAssignerHelper< DynamicMatrixSubdomainSolver< BCRSMatrix< FieldMatrix<K,n,n>, Al>, X, Y >,false>
1294  ::resetIndexForNextDomain()
1295  {
1296  i=0;
1297  }
1298 
1299  template<class K, int n, class Al, class X, class Y>
1301  OverlappingAssignerHelper< DynamicMatrixSubdomainSolver< BCRSMatrix< FieldMatrix<K,n,n>, Al>, X, Y >,false>
1302  ::lhs()
1303  {
1304  return *lhs_;
1305  }
1306 
1307  template<class K, int n, class Al, class X, class Y>
1309  OverlappingAssignerHelper< DynamicMatrixSubdomainSolver< BCRSMatrix< FieldMatrix<K,n,n>, Al>, X, Y >,false>
1310  ::rhs()
1311  {
1312  return *rhs_;
1313  }
1314 
1315  template<class K, int n, class Al, class X, class Y>
1316  void
1317  OverlappingAssignerHelper< DynamicMatrixSubdomainSolver< BCRSMatrix< FieldMatrix<K,n,n>, Al>, X, Y >,false>
1318  ::relaxResult(field_type relax)
1319  {
1320  lhs() *= relax;
1321  }
1322 
1323  template<class K, int n, class Al, class X, class Y>
1324  void
1325  OverlappingAssignerHelper< DynamicMatrixSubdomainSolver< BCRSMatrix< FieldMatrix<K,n,n>, Al>, X, Y >,false>
1326  ::operator()(const size_type& domainIndex)
1327  {
1328  lhs() = 0.0;
1329 #if 0
1330  //assign right hand side of current domainindex block
1331  for(size_type j=0; j<n; ++j, ++i) {
1332  assert(i<maxlength_);
1333  rhs()[i]=(*b)[domainIndex][j];
1334  }
1335 
1336  // loop over all Matrix row entries and calculate defect.
1337  typedef typename matrix_type::ConstColIterator col_iterator;
1338 
1339  // calculate defect for current row index block
1340  for(col_iterator col=(*mat)[domainIndex].begin(); col!=(*mat)[domainIndex].end(); ++col) {
1341  block_type tmp(0.0);
1342  (*col).mv((*x)[col.index()], tmp);
1343  i-=n;
1344  for(size_type j=0; j<n; ++j, ++i) {
1345  assert(i<maxlength_);
1346  rhs()[i]-=tmp[j];
1347  }
1348  }
1349 #else
1350  //assign right hand side of current domainindex block
1351  for(size_type j=0; j<n; ++j, ++i) {
1352  assert(i<maxlength_);
1353  rhs()[i]=(*b)[domainIndex][j];
1354 
1355  // loop over all Matrix row entries and calculate defect.
1356  typedef typename matrix_type::ConstColIterator col_iterator;
1357 
1358  // calculate defect for current row index block
1359  for(col_iterator col=(*mat)[domainIndex].begin(); col!=(*mat)[domainIndex].end(); ++col) {
1360  for(size_type k=0; k<n; ++k) {
1361  rhs()[i]-=(*col)[j][k] * (*x)[col.index()][k];
1362  }
1363  }
1364  }
1365 #endif
1366  }
1367 
1368  template<class K, int n, class Al, class X, class Y>
1369  void
1370  OverlappingAssignerHelper< DynamicMatrixSubdomainSolver< BCRSMatrix< FieldMatrix<K,n,n>, Al>, X, Y >,false>
1371  ::assignResult(block_type& res)
1372  {
1373  // assign the result of the local solve to the global vector
1374  for(size_type j=0; j<n; ++j, ++i) {
1375  assert(i<maxlength_);
1376  res[j]+=lhs()[i];
1377  }
1378  }
1379 
1380 #if HAVE_SUPERLU || HAVE_SUITESPARSE_UMFPACK
1381 
1382  template<template<class> class S, int n, int m, typename T, typename A>
1383  OverlappingAssignerHelper<S<BCRSMatrix<FieldMatrix<T,n,m>,A> >,true>
1384  ::OverlappingAssignerHelper(std::size_t maxlength,
1385  const BCRSMatrix<FieldMatrix<T,n,m>,A>& mat_,
1386  const range_type& b_,
1387  range_type& x_)
1388  : mat(&mat_),
1389  b(&b_),
1390  x(&x_), i(0), maxlength_(maxlength)
1391  {
1392  rhs_ = new field_type[maxlength];
1393  lhs_ = new field_type[maxlength];
1394 
1395  }
1396 
1397  template<template<class> class S, int n, int m, typename T, typename A>
1398  void OverlappingAssignerHelper<S<BCRSMatrix<FieldMatrix<T,n,m>,A> >,true>::deallocate()
1399  {
1400  delete[] rhs_;
1401  delete[] lhs_;
1402  }
1403 
1404  template<template<class> class S, int n, int m, typename T, typename A>
1405  void OverlappingAssignerHelper<S<BCRSMatrix<FieldMatrix<T,n,m>,A> >,true>::operator()(const size_type& domainIndex)
1406  {
1407  //assign right hand side of current domainindex block
1408  // rhs is an array of doubles!
1409  // rhs[starti] = b[domainindex]
1410  for(size_type j=0; j<n; ++j, ++i) {
1411  assert(i<maxlength_);
1412  rhs_[i]=(*b)[domainIndex][j];
1413  }
1414 
1415 
1416  // loop over all Matrix row entries and calculate defect.
1417  typedef typename matrix_type::ConstColIterator col_iterator;
1418 
1419  // calculate defect for current row index block
1420  for(col_iterator col=(*mat)[domainIndex].begin(); col!=(*mat)[domainIndex].end(); ++col) {
1421  block_type tmp;
1422  (*col).mv((*x)[col.index()], tmp);
1423  i-=n;
1424  for(size_type j=0; j<n; ++j, ++i) {
1425  assert(i<maxlength_);
1426  rhs_[i]-=tmp[j];
1427  }
1428 
1429  }
1430 
1431  }
1432 
1433  template<template<class> class S, int n, int m, typename T, typename A>
1434  void OverlappingAssignerHelper<S<BCRSMatrix<FieldMatrix<T,n,m>,A> >,true>::relaxResult(field_type relax)
1435  {
1436  for(size_type j=i+n; i<j; ++i) {
1437  assert(i<maxlength_);
1438  lhs_[i]*=relax;
1439  }
1440  i-=n;
1441  }
1442 
1443  template<template<class> class S, int n, int m, typename T, typename A>
1444  void OverlappingAssignerHelper<S<BCRSMatrix<FieldMatrix<T,n,m>,A> >,true>::assignResult(block_type& res)
1445  {
1446  // assign the result of the local solve to the global vector
1447  for(size_type j=0; j<n; ++j, ++i) {
1448  assert(i<maxlength_);
1449  res[j]+=lhs_[i];
1450  }
1451  }
1452 
1453  template<template<class> class S, int n, int m, typename T, typename A>
1454  void OverlappingAssignerHelper<S<BCRSMatrix<FieldMatrix<T,n,m>,A> >,true>::resetIndexForNextDomain()
1455  {
1456  i=0;
1457  }
1458 
1459  template<template<class> class S, int n, int m, typename T, typename A>
1460  typename OverlappingAssignerHelper<S<BCRSMatrix<FieldMatrix<T,n,m>,A> >,true>::field_type*
1461  OverlappingAssignerHelper<S<BCRSMatrix<FieldMatrix<T,n,m>,A> >,true>::lhs()
1462  {
1463  return lhs_;
1464  }
1465 
1466  template<template<class> class S, int n, int m, typename T, typename A>
1467  typename OverlappingAssignerHelper<S<BCRSMatrix<FieldMatrix<T,n,m>,A> >,true>::field_type*
1468  OverlappingAssignerHelper<S<BCRSMatrix<FieldMatrix<T,n,m>,A> >,true>::rhs()
1469  {
1470  return rhs_;
1471  }
1472 
1473 #endif // HAVE_SUPERLU || HAVE_SUITESPARSE_UMFPACK
1474 
1475  template<class M, class X, class Y>
1476  OverlappingAssignerILUBase<M,X,Y>::OverlappingAssignerILUBase(std::size_t maxlength,
1477  const M& mat_,
1478  const Y& b_,
1479  X& x_)
1480  : mat(&mat_),
1481  b(&b_),
1482  x(&x_), i(0)
1483  {
1484  rhs_= new Y(maxlength);
1485  lhs_ = new X(maxlength);
1486  }
1487 
1488  template<class M, class X, class Y>
1489  void OverlappingAssignerILUBase<M,X,Y>::deallocate()
1490  {
1491  delete rhs_;
1492  delete lhs_;
1493  }
1494 
1495  template<class M, class X, class Y>
1496  void OverlappingAssignerILUBase<M,X,Y>::operator()(const size_type& domainIndex)
1497  {
1498  (*rhs_)[i]=(*b)[domainIndex];
1499 
1500  // loop over all Matrix row entries and calculate defect.
1501  typedef typename matrix_type::ConstColIterator col_iterator;
1502 
1503  // calculate defect for current row index block
1504  for(col_iterator col=(*mat)[domainIndex].begin(); col!=(*mat)[domainIndex].end(); ++col) {
1505  (*col).mmv((*x)[col.index()], (*rhs_)[i]);
1506  }
1507  // Goto next local index
1508  ++i;
1509  }
1510 
1511  template<class M, class X, class Y>
1512  void OverlappingAssignerILUBase<M,X,Y>::relaxResult(field_type relax)
1513  {
1514  (*lhs_)[i]*=relax;
1515  }
1516 
1517  template<class M, class X, class Y>
1518  void OverlappingAssignerILUBase<M,X,Y>::assignResult(block_type& res)
1519  {
1520  res+=(*lhs_)[i++];
1521  }
1522 
1523  template<class M, class X, class Y>
1524  X& OverlappingAssignerILUBase<M,X,Y>::lhs()
1525  {
1526  return *lhs_;
1527  }
1528 
1529  template<class M, class X, class Y>
1530  Y& OverlappingAssignerILUBase<M,X,Y>::rhs()
1531  {
1532  return *rhs_;
1533  }
1534 
1535  template<class M, class X, class Y>
1536  void OverlappingAssignerILUBase<M,X,Y>::resetIndexForNextDomain()
1537  {
1538  i=0;
1539  }
1540 
1541  template<typename S, typename T, typename A, int n>
1542  AdditiveAdder<S,BlockVector<FieldVector<T,n>,A> >::AdditiveAdder(BlockVector<FieldVector<T,n>,A>& v_,
1544  OverlappingAssigner<S>& assigner_,
1545  const T& relax_)
1546  : v(&v_), x(&x_), assigner(&assigner_), relax(relax_)
1547  {}
1548 
1549  template<typename S, typename T, typename A, int n>
1550  void AdditiveAdder<S,BlockVector<FieldVector<T,n>,A> >::operator()(const size_type& domainIndex)
1551  {
1552  // add the result of the local solve to the current update
1553  assigner->assignResult((*v)[domainIndex]);
1554  }
1555 
1556 
1557  template<typename S, typename T, typename A, int n>
1558  void AdditiveAdder<S,BlockVector<FieldVector<T,n>,A> >::axpy()
1559  {
1560  // relax the update and add it to the current guess.
1561  x->axpy(relax,*v);
1562  }
1563 
1564 
1565  template<typename S, typename T, typename A, int n>
1566  MultiplicativeAdder<S,BlockVector<FieldVector<T,n>,A> >
1567  ::MultiplicativeAdder(BlockVector<FieldVector<T,n>,A>& v_,
1568  BlockVector<FieldVector<T,n>,A>& x_,
1569  OverlappingAssigner<S>& assigner_, const T& relax_)
1570  : x(&x_), assigner(&assigner_), relax(relax_)
1571  {
1573  }
1574 
1575 
1576  template<typename S,typename T, typename A, int n>
1577  void MultiplicativeAdder<S,BlockVector<FieldVector<T,n>,A> >::operator()(const size_type& domainIndex)
1578  {
1579  // add the result of the local solve to the current guess
1580  assigner->relaxResult(relax);
1581  assigner->assignResult((*x)[domainIndex]);
1582  }
1583 
1584 
1585  template<typename S,typename T, typename A, int n>
1586  void MultiplicativeAdder<S,BlockVector<FieldVector<T,n>,A> >::axpy()
1587  {
1588  // nothing to do, as the corrections already relaxed and added in operator()
1589  }
1590 
1591 
1593 }
1594 
1595 #endif
Implementation of the BCRSMatrix class.
This file implements a vector space as a tensor product of a given vector space. The number of compon...
A sparse block matrix with compressed row storage.
Definition: bcrsmatrix.hh:423
A vector of blocks with memory management.
Definition: bvector.hh:313
Iterator begin()
begin iterator
Definition: densevector.hh:308
Iterator end()
end iterator
Definition: densevector.hh:314
Iterator find(size_type i)
return iterator to given element or end()
Definition: densevector.hh:334
Exact subdomain solver using Dune::DynamicMatrix<T>::solve.
Definition: overlappingschwarz.hh:136
size_type capacity() const
Number of elements for which memory has been allocated.
Definition: dynvector.hh:133
A dense n x m matrix.
Definition: fmatrix.hh:68
vector space out of a tensor product of fields.
Definition: fvector.hh:93
Index Set Interface base class.
Definition: indexidset.hh:76
RowIterator begin()
Get iterator to first row.
Definition: matrix.hh:609
Initializer for SuperLU Matrices representing the subdomains.
Definition: overlappingschwarz.hh:43
D subdomain_vector
The vector type containing the subdomain to row index mapping.
Definition: overlappingschwarz.hh:46
Base class for matrix free definition of preconditioners.
Definition: preconditioner.hh:26
A constant iterator for the SLList.
Definition: sllist.hh:369
A single linked list.
Definition: sllist.hh:42
Sequential overlapping Schwarz preconditioner.
Definition: overlappingschwarz.hh:742
X::field_type field_type
The field type of the preconditioner.
Definition: overlappingschwarz.hh:770
void apply(X &v, const X &d)
Apply one step of the preconditioner to the system A(v)=d.
M matrix_type
The type of the matrix to precondition.
Definition: overlappingschwarz.hh:747
TM Mode
The mode (additive or multiplicative) of the Schwarz method.
Definition: overlappingschwarz.hh:765
X range_type
The range type of the preconditioner.
Definition: overlappingschwarz.hh:757
X domain_type
The domain type of the preconditioner.
Definition: overlappingschwarz.hh:752
TD slu
The type for the subdomain solver in use.
Definition: overlappingschwarz.hh:793
virtual void pre(X &x, X &b)
Prepare the preconditioner.
Definition: overlappingschwarz.hh:838
virtual void post(X &x)
Postprocess the preconditioner.
Definition: overlappingschwarz.hh:856
std::vector< subdomain_type, typename TA::template rebind< subdomain_type >::other > subdomain_vector
The vector type containing the subdomain to row index mapping.
Definition: overlappingschwarz.hh:784
TA allocator
The allocator to use.
Definition: overlappingschwarz.hh:776
SLList< size_type, typename TA::template rebind< size_type >::other > subdomain_list
The type for the row to subdomain mapping.
Definition: overlappingschwarz.hh:787
std::vector< subdomain_list, typename TA::template rebind< subdomain_list >::other > rowtodomain_vector
The vector type containing the row index to subdomain mapping.
Definition: overlappingschwarz.hh:790
std::vector< slu, typename TA::template rebind< slu >::other > slu_vector
The vector type containing subdomain solvers.
Definition: overlappingschwarz.hh:796
matrix_type::size_type size_type
The return type of the size method.
Definition: overlappingschwarz.hh:773
@ category
The category the precondtioner is part of.
Definition: overlappingschwarz.hh:800
std::set< size_type, std::less< size_type >, typename TA::template rebind< size_type >::other > subdomain_type
The type for the subdomain to row index mapping.
Definition: overlappingschwarz.hh:781
RealIterator< const B > const_iterator
iterator class for sequential access
Definition: basearray.hh:204
size_type N() const
number of blocks in the vector (are of size 1 here)
Definition: bvector.hh:277
iterator class for sequential access
Definition: basearray.hh:565
This file implements a dense matrix with dynamic numbers of rows and columns.
virtual void apply(X &v, const X &d)
Apply the precondtioner.
Definition: overlappingschwarz.hh:1220
SeqOverlappingSchwarz(const matrix_type &mat, const subdomain_vector &subDomains, field_type relaxationFactor=1, bool onTheFly_=true)
Construct the overlapping Schwarz method.
Definition: overlappingschwarz.hh:1047
SeqOverlappingSchwarz(const matrix_type &mat, const rowtodomain_vector &rowToDomain, field_type relaxationFactor=1, bool onTheFly_=true)
Definition: overlappingschwarz.hh:1000
DVVerbType dvverb(std::cout)
stream for very verbose output.
Definition: stdstreams.hh:93
Various local subdomain solvers based on ILU for SeqOverlappingSchwarz.
Dune namespace.
Definition: alignment.hh:11
Define general preconditioner interface.
Implements a singly linked list together with the necessary iterators.
Templates characterizing the type of a solver.
template meta program for choosing how to add the correction.
Definition: overlappingschwarz.hh:561
Tag that the tells the schwarz method to be additive.
Definition: overlappingschwarz.hh:116
Helper template meta program for application of overlapping schwarz.
Definition: overlappingschwarz.hh:594
Tag that tells the Schwarz method to be multiplicative.
Definition: overlappingschwarz.hh:122
Helper template meta program for application of overlapping schwarz.
Definition: overlappingschwarz.hh:658
Definition: overlappingschwarz.hh:1094
@ sequential
Category for sequential solvers.
Definition: solvercategory.hh:21
Tag that tells the Schwarz method to be multiplicative and symmetric.
Definition: overlappingschwarz.hh:129
Classes for using SuperLU with ISTL matrices.
Classes for using UMFPack with ISTL matrices.
Definition of the DUNE_UNUSED macro for the case that config.h is not available.
#define DUNE_UNUSED_PARAMETER(parm)
A macro to mark intentionally unused function parameters with.
Definition: unused.hh:18
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 9, 22:29, 2024)