5#ifndef DUNE_ISTL_GSETC_HH
6#define DUNE_ISTL_GSETC_HH
68 template<
int I, WithDiagType diag, WithRelaxType relax>
70 template<
class M,
class X,
class Y,
class K>
71 static void bltsolve (
const M& A, X& v,
const Y& d,
const K& w)
74 typedef typename M::ConstRowIterator rowiterator;
75 typedef typename M::ConstColIterator coliterator;
76 typedef typename Y::block_type bblock;
79 rowiterator endi=A.end();
80 for (rowiterator i=A.begin(); i!=endi; ++i)
82 bblock rhs(d[i.index()]);
84 for (j=(*i).begin(); j.index()<i.index(); ++j)
85 (*j).mmv(v[j.index()],rhs);
89 template<
class M,
class X,
class Y,
class K>
90 static void butsolve (
const M& A, X& v,
const Y& d,
const K& w)
93 typedef typename M::ConstRowIterator rowiterator;
94 typedef typename M::ConstColIterator coliterator;
95 typedef typename Y::block_type bblock;
98 rowiterator rendi=A.beforeBegin();
99 for (rowiterator i=A.beforeEnd(); i!=rendi; --i)
101 bblock rhs(d[i.index()]);
103 for (j=(*i).beforeEnd(); j.index()>i.index(); --j)
104 (*j).mmv(v[j.index()],rhs);
113 template<
class M,
class X,
class Y,
class K>
114 static void bltsolve (
const M& A, X& v,
const Y& d,
const K& w)
119 template<
class M,
class X,
class Y,
class K>
120 static void butsolve (
const M& A, X& v,
const Y& d,
const K& w)
128 template<
class M,
class X,
class Y,
class K>
129 static void bltsolve (
const M& A, X& v,
const Y& d,
const K& )
133 template<
class M,
class X,
class Y,
class K>
134 static void butsolve (
const M& A, X& v,
const Y& d,
const K& )
141 template<
class M,
class X,
class Y,
class K>
142 static void bltsolve (
const M& , X& v,
const Y& d,
const K& w)
147 template<
class M,
class X,
class Y,
class K>
148 static void butsolve (
const M& , X& v,
const Y& d,
const K& w)
156 template<
class M,
class X,
class Y,
class K>
157 static void bltsolve (
const M& , X& v,
const Y& d,
const K& )
161 template<
class M,
class X,
class Y,
class K>
162 static void butsolve (
const M& , X& v,
const Y& d,
const K& )
174 template<
class M,
class X,
class Y>
177 typename X::field_type w=1;
181 template<
class M,
class X,
class Y,
class K>
182 void bltsolve (
const M& A, X& v,
const Y& d,
const K& w)
187 template<
class M,
class X,
class Y>
190 typename X::field_type w=1;
194 template<
class M,
class X,
class Y,
class K>
201 template<
class M,
class X,
class Y>
204 typename X::field_type w=1;
208 template<
class M,
class X,
class Y,
class K>
209 void butsolve (
const M& A, X& v,
const Y& d,
const K& w)
214 template<
class M,
class X,
class Y>
217 typename X::field_type w=1;
221 template<
class M,
class X,
class Y,
class K>
230 template<
class M,
class X,
class Y,
int l>
233 typename X::field_type w=1;
237 template<
class M,
class X,
class Y,
class K,
int l>
243 template<
class M,
class X,
class Y,
int l>
246 typename X::field_type w=1;
250 template<
class M,
class X,
class Y,
class K,
int l>
257 template<
class M,
class X,
class Y,
int l>
260 typename X::field_type w=1;
264 template<
class M,
class X,
class Y,
class K,
int l>
270 template<
class M,
class X,
class Y,
int l>
273 typename X::field_type w=1;
277 template<
class M,
class X,
class Y,
class K,
int l>
293 template<
int I, WithRelaxType relax>
295 template<
class M,
class X,
class Y,
class K>
296 static void bdsolve (
const M& A, X& v,
const Y& d,
const K& w)
299 typedef typename M::ConstRowIterator rowiterator;
300 typedef typename M::ConstColIterator coliterator;
303 rowiterator rendi=A.beforeBegin();
304 for (rowiterator i=A.beforeEnd(); i!=rendi; --i)
306 coliterator ii=(*i).find(i.index());
315 template<
class M,
class X,
class Y,
class K>
316 static void bdsolve (
const M& A, X& v,
const Y& d,
const K& w)
324 template<
class M,
class X,
class Y,
class K>
325 static void bdsolve (
const M& A, X& v,
const Y& d,
const K& )
336 template<
class M,
class X,
class Y>
339 typename X::field_type w=1;
343 template<
class M,
class X,
class Y,
class K>
344 void bdsolve (
const M& A, X& v,
const Y& d,
const K& w)
352 template<
class M,
class X,
class Y,
int l>
355 typename X::field_type w=1;
359 template<
class M,
class X,
class Y,
class K,
int l>
374 template<
int I,
typename M>
377 template<
class X,
class Y,
class K>
378 static void dbgs (
const M& A, X& x,
const Y& b,
const K& w)
380 typedef typename M::ConstRowIterator rowiterator;
381 typedef typename M::ConstColIterator coliterator;
382 typedef typename Y::block_type bblock;
387 rowiterator endi=A.end();
388 for (rowiterator i=A.begin(); i!=endi; ++i)
391 coliterator endj=(*i).end();
392 coliterator j=(*i).begin();
395 for (; j.index()<i.index(); ++j)
396 rhs -= (*j) * x[j.index()];
397 coliterator diag=j++;
398 for (; j != endj; ++j)
399 rhs -= (*j) * x[j.index()];
400 x[i.index()] = rhs / (*diag);
404 for (; j.index()<i.index(); ++j)
405 (*j).mmv(x[j.index()],rhs);
406 coliterator diag=j++;
407 for (; j != endj; ++j)
408 (*j).mmv(x[j.index()],rhs);
417 template<
class X,
class Y,
class K>
418 static void bsorf (
const M& A, X& x,
const Y& b,
const K& w)
420 typedef typename M::ConstRowIterator rowiterator;
421 typedef typename M::ConstColIterator coliterator;
422 typedef typename Y::block_type bblock;
423 typedef typename X::block_type xblock;
427 rowiterator endi=A.end();
428 for (rowiterator i=A.begin(); i!=endi; ++i)
431 coliterator endj=(*i).end();
432 coliterator j=(*i).begin();
435 for (; j.index()<i.index(); ++j)
436 rhs -= (*j) * x[j.index()];
439 rhs -= (*j) * x[j.index()];
445 for (; j.index()<i.index(); ++j)
446 (*j).mmv(x[j.index()],rhs);
449 (*j).mmv(x[j.index()],rhs);
452 x[i.index()].axpy(w,v);
457 template<
class X,
class Y,
class K>
458 static void bsorb (
const M& A, X& x,
const Y& b,
const K& w)
460 typedef typename M::ConstRowIterator rowiterator;
461 typedef typename M::ConstColIterator coliterator;
462 typedef typename Y::block_type bblock;
463 typedef typename X::block_type xblock;
467 rowiterator endi=A.beforeBegin();
468 for (rowiterator i=A.beforeEnd(); i!=endi; --i)
471 coliterator endj=(*i).end();
472 coliterator j=(*i).begin();
475 for (; j.index()<i.index(); ++j)
476 rhs -= (*j) * x[j.index()];
479 rhs -= (*j) * x[j.index()];
485 for (; j.index()<i.index(); ++j)
486 j->mmv(x[j.index()],rhs);
489 j->mmv(x[j.index()],rhs);
492 x[i.index()].axpy(w,v);
497 template<
class X,
class Y,
class K>
498 static void dbjac (
const M& A, X& x,
const Y& b,
const K& w)
500 typedef typename M::ConstRowIterator rowiterator;
501 typedef typename M::ConstColIterator coliterator;
502 typedef typename Y::block_type bblock;
507 rowiterator endi=A.end();
508 for (rowiterator i=A.begin(); i!=endi; ++i)
511 coliterator endj=(*i).end();
512 coliterator j=(*i).begin();
515 for (; j.index()<i.index(); ++j)
516 rhs -= (*j) * x[j.index()];
519 rhs -= (*j) * x[j.index()];
520 v[i.index()] = rhs / (*diag);
524 for (; j.index()<i.index(); ++j)
525 j->mmv(x[j.index()],rhs);
528 j->mmv(x[j.index()],rhs);
538 template<
class X,
class Y,
class K>
539 static void dbgs (
const M& A, X& x,
const Y& b,
const K& )
543 template<
class X,
class Y,
class K>
544 static void bsorf (
const M& A, X& x,
const Y& b,
const K& )
548 template<
class X,
class Y,
class K>
549 static void bsorb (
const M& A, X& x,
const Y& b,
const K& )
553 template<
class X,
class Y,
class K>
554 static void dbjac (
const M& A, X& x,
const Y& b,
const K& )
560 template<
int I,
typename T1,
typename... MultiTypeMatrixArgs>
563 typename... MultiTypeVectorArgs,
575 typename... MultiTypeVectorArgs,
587 typename... MultiTypeVectorArgs,
599 typename... MultiTypeVectorArgs,
615 template<
class M,
class X,
class Y,
class K>
616 void dbgs (
const M& A, X& x,
const Y& b,
const K& w)
621 template<
class M,
class X,
class Y,
class K,
int l>
627 template<
class M,
class X,
class Y,
class K>
628 void bsorf (
const M& A, X& x,
const Y& b,
const K& w)
633 template<
class M,
class X,
class Y,
class K,
int l>
639 template<
class M,
class X,
class Y,
class K>
640 void bsorb (
const M& A, X& x,
const Y& b,
const K& w)
645 template<
class M,
class X,
class Y,
class K,
int l>
651 template<
class M,
class X,
class Y,
class K>
652 void dbjac (
const M& A, X& x,
const Y& b,
const K& w)
657 template<
class M,
class X,
class Y,
class K,
int l>
static void dbjac(const TMatrix &A, TVector &x, const TVector &b, const K &w)
Definition multitypeblockmatrix.hh:584
static void dbgs(const TMatrix &A, TVector &x, const TVector &b, const K &w)
Definition multitypeblockmatrix.hh:500
static void bsorb(const TMatrix &A, TVector &x, const TVector &b, const K &w)
Definition multitypeblockmatrix.hh:556
static constexpr size_type N()
Return the number of matrix rows.
Definition multitypeblockmatrix.hh:84
static void bsorf(const TMatrix &A, TVector &x, const TVector &b, const K &w)
Definition multitypeblockmatrix.hh:529
void bltsolve(const M &A, X &v, const Y &d)
block lower triangular solve
Definition gsetc.hh:175
WithDiagType
Definition gsetc.hh:49
void bsorb(const M &A, X &x, const Y &b, const K &w)
SSOR step.
Definition gsetc.hh:640
void ubltsolve(const M &A, X &v, const Y &d)
unit block lower triangular solve
Definition gsetc.hh:188
void dbjac(const M &A, X &x, const Y &b, const K &w)
Jacobi step.
Definition gsetc.hh:652
void dbgs(const M &A, X &x, const Y &b, const K &w)
GS step.
Definition gsetc.hh:616
WithRelaxType
Definition gsetc.hh:54
void bdsolve(const M &A, X &v, const Y &d)
block diagonal solve, no relaxation
Definition gsetc.hh:337
void butsolve(const M &A, X &v, const Y &d)
block upper triangular solve
Definition gsetc.hh:202
void bsorf(const M &A, X &x, const Y &b, const K &w)
SOR step.
Definition gsetc.hh:628
void ubutsolve(const M &A, X &v, const Y &d)
unit block upper triangular solve
Definition gsetc.hh:215
@ nodiag
Definition gsetc.hh:51
@ withdiag
Definition gsetc.hh:50
@ norelax
Definition gsetc.hh:56
@ withrelax
Definition gsetc.hh:55
static constexpr size_type M()
static constexpr size_type N()
A Vector class to support different block types.
Definition multitypeblockvector.hh:59
A Matrix class to support different block types.
Definition multitypeblockmatrix.hh:46
compile-time parameter for block recursion depth
Definition gsetc.hh:45
@ recursion_level
Definition gsetc.hh:46
static void butsolve(const M &A, X &v, const Y &d, const K &w)
Definition gsetc.hh:90
static void bltsolve(const M &A, X &v, const Y &d, const K &w)
Definition gsetc.hh:71
static void bltsolve(const M &A, X &v, const Y &d, const K &w)
Definition gsetc.hh:114
static void butsolve(const M &A, X &v, const Y &d, const K &w)
Definition gsetc.hh:120
static void bltsolve(const M &A, X &v, const Y &d, const K &)
Definition gsetc.hh:129
static void butsolve(const M &A, X &v, const Y &d, const K &)
Definition gsetc.hh:134
static void bltsolve(const M &, X &v, const Y &d, const K &w)
Definition gsetc.hh:142
static void butsolve(const M &, X &v, const Y &d, const K &w)
Definition gsetc.hh:148
static void bltsolve(const M &, X &v, const Y &d, const K &)
Definition gsetc.hh:157
static void butsolve(const M &, X &v, const Y &d, const K &)
Definition gsetc.hh:162
static void bdsolve(const M &A, X &v, const Y &d, const K &w)
Definition gsetc.hh:296
static void bdsolve(const M &A, X &v, const Y &d, const K &w)
Definition gsetc.hh:316
static void bdsolve(const M &A, X &v, const Y &d, const K &)
Definition gsetc.hh:325
static void bsorb(const M &A, X &x, const Y &b, const K &w)
Definition gsetc.hh:458
static void bsorf(const M &A, X &x, const Y &b, const K &w)
Definition gsetc.hh:418
static void dbjac(const M &A, X &x, const Y &b, const K &w)
Definition gsetc.hh:498
static void dbgs(const M &A, X &x, const Y &b, const K &w)
Definition gsetc.hh:378
static void dbgs(const M &A, X &x, const Y &b, const K &)
Definition gsetc.hh:539
static void dbjac(const M &A, X &x, const Y &b, const K &)
Definition gsetc.hh:554
static void bsorf(const M &A, X &x, const Y &b, const K &)
Definition gsetc.hh:544
static void bsorb(const M &A, X &x, const Y &b, const K &)
Definition gsetc.hh:549
static void dbgs(const MultiTypeBlockMatrix< T1, MultiTypeMatrixArgs... > &A, MultiTypeBlockVector< MultiTypeVectorArgs... > &x, const MultiTypeBlockVector< MultiTypeVectorArgs... > &b, const K &w)
Definition gsetc.hh:565
static void dbjac(const MultiTypeBlockMatrix< T1, MultiTypeMatrixArgs... > &A, MultiTypeBlockVector< MultiTypeVectorArgs... > &x, const MultiTypeBlockVector< MultiTypeVectorArgs... > &b, const K &w)
Definition gsetc.hh:602
static void bsorf(const MultiTypeBlockMatrix< T1, MultiTypeMatrixArgs... > &A, MultiTypeBlockVector< MultiTypeVectorArgs... > &x, const MultiTypeBlockVector< MultiTypeVectorArgs... > &b, const K &w)
Definition gsetc.hh:577
static void bsorb(const MultiTypeBlockMatrix< T1, MultiTypeMatrixArgs... > &A, MultiTypeBlockVector< MultiTypeVectorArgs... > &x, const MultiTypeBlockVector< MultiTypeVectorArgs... > &b, const K &w)
Definition gsetc.hh:589