FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
vanka.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
9#include <kernel/solver/base.hpp>
10#include <kernel/adjacency/graph.hpp>
11#include <kernel/lafem/dense_vector.hpp>
12#include <kernel/lafem/dense_vector_blocked.hpp>
13#include <kernel/lafem/power_vector.hpp>
14#include <kernel/lafem/tuple_vector.hpp>
15#include <kernel/lafem/sparse_matrix_csr.hpp>
16#include <kernel/lafem/sparse_matrix_bcsr.hpp>
17#include <kernel/lafem/power_diag_matrix.hpp>
18#include <kernel/lafem/power_full_matrix.hpp>
19#include <kernel/lafem/power_row_matrix.hpp>
20#include <kernel/lafem/power_col_matrix.hpp>
21#include <kernel/lafem/saddle_point_matrix.hpp>
22#include <kernel/util/stop_watch.hpp>
23
24// includes, system
25#include <map>
26#include <set>
27#include <vector>
28
29namespace FEAT
30{
31 namespace Solver
32 {
34 namespace Intern
35 {
49 template<typename Vector_>
50 class VankaVector;
51
68 template<typename Matrix_>
69 class VankaMatrix;
70
71 template<typename DT_, typename IT_>
72 class VankaVector<LAFEM::DenseVector<DT_, IT_>>
73 {
74 public:
75 typedef LAFEM::DenseVector<DT_, IT_> VectorType;
76 static constexpr int dim = 1;
77
78 protected:
79 Memory::TypedView<DT_> _vec_view;
80
81 public:
83 explicit VankaVector(VectorType& vec_cor) :
84 _vec_view(vec_cor.elements_view_rw())
85 {
86 }
87
89 explicit VankaVector(const VectorType& vec_def) :
90 _vec_view(vec_def.elements_view_r())
91 {
92 }
93
94 IT_ gather_def(DT_* x, const IT_* idx, const IT_ n, const IT_ off) const
95 {
96 for(IT_ i(0); i < n; ++i)
97 {
98 x[off+i] = _vec_view(idx[i]);
99 }
100 return off+n;
101 }
102
103 IT_ scatter_cor(const DT_ omega, const DT_* x, const IT_* idx, const IT_ n, const IT_ off)
104 {
105 for(IT_ i(0); i < n; ++i)
106 {
107 _vec_view[idx[i]] += omega * x[off+i];
108 }
109 return off+n;
110 }
111 };
112
113 template<typename DT_, typename IT_, int dim_>
114 class VankaVector<LAFEM::DenseVectorBlocked<DT_, IT_, dim_>>
115 {
116 public:
117 typedef LAFEM::DenseVectorBlocked<DT_, IT_, dim_> VectorType;
118 typedef typename VectorType::ValueType ValueType;
119 static constexpr int dim = dim_;
120
121 protected:
122 Memory::TypedView<ValueType> _vec_view;
123
124 public:
126 explicit VankaVector(VectorType& vec_cor) :
127 _vec_view(vec_cor.elements_view_rw())
128 {
129 }
130
132 explicit VankaVector(const VectorType& vec_def) :
133 _vec_view(vec_def.elements_view_r())
134 {
135 }
136
137 IT_ gather_def(DT_* x, const IT_* idx, const IT_ n, const IT_ off) const
138 {
139 for(IT_ i(0); i < n; ++i)
140 {
141 const ValueType& vi = _vec_view(idx[i]);
142 for(int j(0); j < dim; ++j)
143 {
144 x[off + i*IT_(dim) + IT_(j)] = vi[j];
145 }
146 }
147 return off + IT_(dim)*n;
148 }
149
150 IT_ scatter_cor(const DT_ omega, const DT_* x, const IT_* idx, const IT_ n, const IT_ off)
151 {
152 for(IT_ i(0); i < n; ++i)
153 {
154 ValueType& vi = _vec_view[idx[i]];
155 for(int j(0); j < dim; ++j)
156 {
157 vi[j] += omega * x[off + i*IT_(dim) + IT_(j)];
158 }
159 }
160 return off + IT_(dim)*n;
161 }
162 };
163
164 template<typename SubVector_, int dim_>
165 class VankaVector<LAFEM::PowerVector<SubVector_, dim_>>
166 {
167 public:
168 typedef LAFEM::PowerVector<SubVector_, dim_> VectorType;
169 typedef VankaVector<SubVector_> FirstClass;
170 typedef VankaVector<LAFEM::PowerVector<SubVector_, dim_-1>> RestClass;
171
172 static constexpr int dim = FirstClass::dim + RestClass::dim;
173
174 protected:
175 FirstClass _first;
176 RestClass _rest;
177
178 public:
179 explicit VankaVector(VectorType& vec_cor) :
180 _first(vec_cor.first()),
181 _rest(vec_cor.rest())
182 {
183 }
184
185 explicit VankaVector(const VectorType& vec_cor) :
186 _first(vec_cor.first()),
187 _rest(vec_cor.rest())
188 {
189 }
190
191 template<typename DT_, typename IT_>
192 IT_ gather_def(DT_* x, const IT_* idx, const IT_ n, const IT_ off) const
193 {
194 IT_ noff = _first.gather_def(x, idx, n, off);
195 return _rest.gather_def(x, idx, n, noff);
196 }
197
198 template<typename DT_, typename IT_>
199 IT_ scatter_cor(const DT_ omega, const DT_* x, const IT_* idx, const IT_ n, const IT_ off)
200 {
201 IT_ noff = _first.scatter_cor(omega, x, idx, n, off);
202 return _rest.scatter_cor(omega, x, idx, n, noff);
203 }
204 };
205
206 template<typename SubVector_>
207 class VankaVector<LAFEM::PowerVector<SubVector_, 1>>
208 {
209 public:
210 typedef LAFEM::PowerVector<SubVector_, 1> VectorType;
211 typedef VankaVector<SubVector_> FirstClass;
212
213 static constexpr int dim = FirstClass::dim;
214
215 protected:
216 FirstClass _first;
217
218 public:
219 explicit VankaVector(VectorType& vec_cor) :
220 _first(vec_cor.first())
221 {
222 }
223
224 explicit VankaVector(const VectorType& vec_cor) :
225 _first(vec_cor.first())
226 {
227 }
228
229 template<typename DT_, typename IT_>
230 IT_ gather_def(DT_* x, const IT_* idx, const IT_ n, const IT_ off) const
231 {
232 return _first.gather_def(x, idx, n, off);
233 }
234
235 template<typename DT_, typename IT_>
236 IT_ scatter_cor(const DT_ omega, const DT_* x, const IT_* idx, const IT_ n, const IT_ off)
237 {
238 return _first.scatter_cor(omega, x, idx, n, off);
239 }
240 };
241
242 template<typename DT_, typename IT_>
243 class VankaMatrix<LAFEM::SparseMatrixCSR<DT_, IT_>>
244 {
245 public:
246 typedef LAFEM::SparseMatrixCSR<DT_, IT_> MatrixType;
247 typedef LAFEM::DenseVector<DT_, IT_> VectorTypeR;
248
249 static constexpr int row_dim = 1;
250 static constexpr int col_dim = 1;
251
252 protected:
253 const Memory::TypedView<IT_> _row_ptr;
254 const Memory::TypedView<IT_> _col_idx;
255 const Memory::TypedView<DT_> _mat_val;
256
257 public:
258 explicit VankaMatrix(const MatrixType& matrix) :
259 _row_ptr(matrix.row_ptr_view_r()),
260 _col_idx(matrix.col_idx_view_r()),
261 _mat_val(matrix.val_view_r())
262 {
263 }
264
265 std::pair<IT_, IT_> gather_full(
266 DT_* data, const IT_* ridx, const IT_* cidx,
267 const IT_ m, const IT_ n, const IT_ stride,
268 const IT_ mo = IT_(0), const IT_ no = IT_(0)) const
269 {
270 // empty matrix?
271 if(_mat_val.is_nullptr())
272 return std::make_pair(mo+m, no+n);
273
274 // loop over all local rows
275 for(IT_ i(0); i < m; ++i)
276 {
277 // get row index
278 const IT_ ri = ridx[i];
279
280 // initialize loop variable for local columns
281 IT_ j = IT_(0);
282
283 // loop over the ri row of our matrix
284 for(IT_ ai = _row_ptr[ri]; ai < _row_ptr[ri+1]; ++ai)
285 {
286 // get column index
287 const IT_ rj = _col_idx[ai];
288
289 // now search its position in our local matrix
290 while((j < n) && (cidx[j] < rj))
291 {
292 ++j;
293 }
294 // did we find our local entry?
295 if((j < n) && (cidx[j] == rj))
296 {
297 // found, so store it in our local matrix
298 data[(mo + i) * stride + no + j] = _mat_val[ai];
299 }
300 }
301 }
302 return std::make_pair(mo+m, no+n);
303 }
304
305 IT_ gather_diag(DT_* data, const IT_* idx, const IT_ m, const IT_ mo = IT_(0)) const
306 {
307 // loop over all local rows
308 for(IT_ i(0); i < m; ++i)
309 {
310 // get row index
311 const IT_ ri = idx[i];
312
313 // find diagonal entry
314 for(IT_ ai = _row_ptr[ri]; ai < _row_ptr[ri+1]; ++ai)
315 {
316 // is it our diagonal?
317 if(_col_idx[ai] == ri)
318 {
319 data[mo+i] = _mat_val[ai];
320 break;
321 }
322 }
323 }
324 return mo + m;
325 }
326
327 IT_ mult_cor(DT_* x, const DT_ alpha, const VectorTypeR& vec_cor, const IT_* idx, const IT_ m, const IT_ off) const
328 {
329 if(_mat_val.is_nullptr())
330 return off + m;
331
332 const Memory::TypedView<DT_> v = vec_cor.elements_view_r();
333
334 // loop over all local rows
335 for(IT_ i(0); i < m; ++i)
336 {
337 const IT_ vi = idx[i];
338
339 // loop over all columns
340 DT_ r = DT_(0);
341 for(IT_ k = _row_ptr[vi]; k < _row_ptr[vi+1]; ++k)
342 {
343 r += _mat_val[k] * v[_col_idx[k]];
344 }
345 x[off+i] += alpha * r;
346 }
347 return off + m;
348 }
349 };
350
351 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
352 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
353 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
354
355 template<typename DT_, typename IT_, int row_dim_, int col_dim_>
356 class VankaMatrix<LAFEM::SparseMatrixBCSR<DT_, IT_, row_dim_, col_dim_>>
357 {
358 public:
359 typedef LAFEM::SparseMatrixBCSR<DT_, IT_, row_dim_, col_dim_> MatrixType;
360
361 typedef typename MatrixType::ValueType MatVal;
362
363 static constexpr int row_dim = row_dim_;
364 static constexpr int col_dim = col_dim_;
365
366 protected:
367 const Memory::TypedView<IT_> _row_ptr;
368 const Memory::TypedView<IT_> _col_idx;
369 const Memory::TypedView<MatVal> _mat_val;
370
371 public:
372 explicit VankaMatrix(const MatrixType& matrix) :
373 _row_ptr(matrix.row_ptr_view_r()),
374 _col_idx(matrix.col_idx_view_r()),
375 _mat_val(matrix.val_view_r())
376 {
377 }
378
379 std::pair<IT_, IT_> gather_full(
380 DT_* data, const IT_* ridx, const IT_* cidx,
381 const IT_ m, const IT_ n, const IT_ stride,
382 const IT_ mo = IT_(0), const IT_ no = IT_(0)) const
383 {
384 // empty matrix?
385 XASSERTM(!_mat_val.is_nullptr(), "Vanka: invalid empty BCSR matrix");
386
387 // loop over all local rows
388 for(IT_ i(0); i < m; ++i)
389 {
390 // get row index
391 const IT_ ri = ridx[i];
392
393 // initialize loop variable for local columns
394 IT_ j = IT_(0);
395
396 // loop over the ri row of our matrix
397 for(IT_ ai = _row_ptr[ri]; ai < _row_ptr[ri+1]; ++ai)
398 {
399 // get column index
400 const IT_ rj = _col_idx[ai];
401
402 // now search its position in our local matrix
403 while((j < n) && (cidx[j] < rj))
404 {
405 ++j;
406 }
407 // did we find our local entry?
408 if((j < n) && (cidx[j] == rj))
409 {
410 // found, so store it in our local matrix
411 const MatVal& mv = _mat_val[ai];
412
413 // copy matrix block
414 for(int ii(0); ii < row_dim; ++ii)
415 {
416 // compute offset
417 const IT_ lro = (mo + i * IT_(row_dim) + IT_(ii)) * stride + no + j * IT_(col_dim);
418
419 // copy block row
420 for(int jj(0); jj < col_dim; ++jj)
421 {
422 data[lro + IT_(jj)] = mv[ii][jj];
423 }
424 }
425 }
426 }
427 }
428 return std::make_pair(mo + IT_(row_dim)*m, no + IT_(col_dim)*n);
429 }
430
431 IT_ gather_diag(DT_* data, const IT_* idx, const IT_ m, const IT_ mo = IT_(0)) const
432 {
433 // loop over all local rows
434 for(IT_ i(0); i < m; ++i)
435 {
436 // get row index
437 const IT_ ri = idx[i];
438
439 // find diagonal entry
440 for(IT_ ai = _row_ptr[ri]; ai < _row_ptr[ri+1]; ++ai)
441 {
442 // is it our diagonal?
443 if(_col_idx[ai] == ri)
444 {
445 const MatVal& mv = _mat_val[ai];
446
447 // copy block diagonal
448 for(int k(0); k < row_dim; ++k)
449 {
450 data[mo + i*IT_(row_dim) + IT_(k)] = mv[k][k];
451 }
452 break;
453 }
454 }
455 }
456 return mo + m;
457 }
458
459 IT_ mult_cor(DT_* x, const DT_ alpha, const LAFEM::DenseVectorBlocked<DT_, IT_, col_dim_>& vec_cor,
460 const IT_* idx, const IT_ m, const IT_ off) const
461 {
462 if(_mat_val.is_nullptr())
463 return off + m;
464
465 typedef LAFEM::DenseVectorBlocked<DT_, IT_, col_dim_> VectorType;
466 typedef typename VectorType::ValueType VecVal;
467 const Memory::TypedView<VecVal> v = vec_cor.elements_view_r();
468
469 // loop over all local rows
470 for(IT_ i(0); i < m; ++i)
471 {
472 const IT_ vi = idx[i];
473
474 // loop over all columns
475 for(IT_ k = _row_ptr[vi]; k < _row_ptr[vi+1]; ++k)
476 {
477 // get matrix and vector values
478 const MatVal& mv = _mat_val[k];
479 const VecVal& vv = v[_col_idx[k]];
480
481 // loop over all block rows
482 for(int ii(0); ii < row_dim; ++ii)
483 {
484 DT_ r = DT_(0);
485 // loop over all block columns
486 for(int jj(0); jj < col_dim; ++jj)
487 {
488 r += mv[ii][jj] * vv[jj];
489 }
490 x[off + i*IT_(row_dim) + IT_(ii)] += alpha * r;
491 }
492 }
493 }
494 return off + m* IT_(row_dim);
495 }
496
497 IT_ mult_cor(DT_* x, const DT_ alpha, const LAFEM::DenseVector<DT_, IT_>& vec_cor,
498 const IT_* idx, const IT_ m, const IT_ off) const
499 {
500 if(_mat_val.is_nullptr())
501 return off + m;
502
503 const Memory::TypedView<DT_> v = vec_cor.elements_view_r();
504
505 // loop over all local rows
506 for(IT_ i(0); i < m; ++i)
507 {
508 const IT_ vi = idx[i];
509
510 // loop over all columns
511 for(IT_ k = _row_ptr[vi]; k < _row_ptr[vi+1]; ++k)
512 {
513 // get matrix and vector values
514 const MatVal& mv = _mat_val[k];
515 //const VecVal& vv = v[_col_idx[k]];
516
517 // compute vector offset
518 const IT_ vo = _col_idx[k] * IT_(col_dim);
519
520 // loop over all block rows
521 for(int ii(0); ii < row_dim; ++ii)
522 {
523 DT_ r = DT_(0);
524 // loop over all block columns
525 for(int jj(0); jj < col_dim; ++jj)
526 {
527 r += mv[ii][jj] * v[vo + IT_(jj)];
528 }
529 x[off + i*IT_(row_dim) + IT_(ii)] += alpha * r;
530 }
531 }
532 }
533 return off + m* IT_(row_dim);
534 }
535 };
536
537 // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
538 // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
539 // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
540
541 template<typename SubMatrix_, int dim_>
542 class VankaMatrix<LAFEM::PowerDiagMatrix<SubMatrix_, dim_>>
543 {
544 public:
545 typedef LAFEM::PowerDiagMatrix<SubMatrix_, dim_> MatrixType;
546 typedef typename MatrixType::VectorTypeR VectorTypeR;
547 typedef VankaMatrix<SubMatrix_> FirstClass;
548 typedef VankaMatrix<LAFEM::PowerDiagMatrix<SubMatrix_, dim_-1>> RestClass;
549
550 static constexpr int row_dim = FirstClass::row_dim + RestClass::row_dim;
551 static constexpr int col_dim = FirstClass::col_dim + RestClass::col_dim;
552
553 protected:
554 FirstClass _first;
555 RestClass _rest;
556
557 public:
558 explicit VankaMatrix(const MatrixType& matrix) :
559 _first(matrix.first()),
560 _rest(matrix.rest())
561 {
562 }
563
564 template<typename DT_, typename IT_>
565 std::pair<IT_, IT_> gather_full(
566 DT_* data, const IT_* ridx, const IT_* cidx,
567 const IT_ m, const IT_ n, const IT_ stride,
568 const IT_ mo = IT_(0), const IT_ no = IT_(0)) const
569 {
570 std::pair<IT_, IT_> mn = _first.gather_full(data, ridx, cidx, m, n, stride, mo, no);
571 return _rest.gather_full(data, ridx, cidx, m, n, stride, mn.first, mn.second);
572 }
573
574 template<typename DT_, typename IT_>
575 IT_ gather_diag(DT_* data, const IT_* idx, const IT_ m, const IT_ mo = IT_(0)) const
576 {
577 IT_ mno = _first.gather_diag(data, idx, m, mo);
578 return _rest.gather_diag(data, idx, m, mno);
579 }
580
581 template<typename DT_, typename IT_>
582 IT_ mult_cor(DT_* x, const DT_ alpha, const VectorTypeR& vec_cor, const IT_* idx, const IT_ m, const IT_ off) const
583 {
584 IT_ noff = _first.mult_cor(x, alpha, vec_cor.first(), idx, m, off);
585 return _rest.mult_cor(x, alpha, vec_cor.rest(), idx, m, noff);
586 }
587 };
588
589 template<typename SubMatrix_>
590 class VankaMatrix<LAFEM::PowerDiagMatrix<SubMatrix_, 1>>
591 {
592 public:
593 typedef LAFEM::PowerDiagMatrix<SubMatrix_, 1> MatrixType;
594 typedef typename MatrixType::VectorTypeR VectorTypeR;
595 typedef VankaMatrix<SubMatrix_> FirstClass;
596
597 static constexpr int row_dim = FirstClass::row_dim;
598 static constexpr int col_dim = FirstClass::col_dim;
599
600 protected:
601 FirstClass _first;
602
603 public:
604 explicit VankaMatrix(const MatrixType& matrix) :
605 _first(matrix.first())
606 {
607 }
608
609 template<typename DT_, typename IT_>
610 std::pair<IT_, IT_> gather_full(
611 DT_* data, const IT_* ridx, const IT_* cidx,
612 const IT_ m, const IT_ n, const IT_ stride,
613 const IT_ mo = IT_(0), const IT_ no = IT_(0)) const
614 {
615 return _first.gather_full(data, ridx, cidx, m, n, stride, mo, no);
616 }
617
618 template<typename DT_, typename IT_>
619 IT_ gather_diag(DT_* data, const IT_* idx, const IT_ m, const IT_ mo = IT_(0)) const
620 {
621 return _first.gather_diag(data, idx, m, mo);
622 }
623
624 template<typename DT_, typename IT_>
625 IT_ mult_cor(DT_* x, const DT_ alpha, const VectorTypeR& vec_cor, const IT_* idx, const IT_ m, const IT_ off) const
626 {
627 return _first.mult_cor(x, alpha, vec_cor.first(), idx, m, off);
628 }
629 };
630
631 template<typename SubMatrix_, int dim_>
632 class VankaMatrix<LAFEM::PowerColMatrix<SubMatrix_, dim_>>
633 {
634 public:
635 typedef LAFEM::PowerColMatrix<SubMatrix_, dim_> MatrixType;
636 typedef typename MatrixType::VectorTypeR VectorTypeR;
637 typedef VankaMatrix<SubMatrix_> FirstClass;
638 typedef VankaMatrix<LAFEM::PowerColMatrix<SubMatrix_, dim_-1>> RestClass;
639
640 static constexpr int row_dim = FirstClass::row_dim + RestClass::row_dim;
641 static constexpr int col_dim = FirstClass::col_dim;
642
643 protected:
644 FirstClass _first;
645 RestClass _rest;
646
647 public:
648 explicit VankaMatrix(const MatrixType& matrix) :
649 _first(matrix.first()),
650 _rest(matrix.rest())
651 {
652 }
653
654 template<typename DT_, typename IT_>
655 std::pair<IT_, IT_> gather_full(
656 DT_* data, const IT_* ridx, const IT_* cidx,
657 const IT_ m, const IT_ n, const IT_ stride,
658 const IT_ mo = IT_(0), const IT_ no = IT_(0)) const
659 {
660 std::pair<IT_, IT_> mno = _first.gather_full(data, ridx, cidx, m, n, stride, mo, no);
661 return _rest.gather_full(data, ridx, cidx, m, n, stride, mno.first, no);
662 }
663
664 template<int ro_, int co_, typename DT_, typename IT_>
665 IT_ gather_diag_pfm(DT_* data, const IT_* idx, const IT_ m, const IT_ mo = IT_(0)) const
666 {
667 IT_ mno = _first.template gather_diag_pfm<ro_, co_>(data, idx, m, mo);
668 return _rest.template gather_diag_pfm<ro_+1, co_>(data, idx, m, mno);
669 }
670
671 template<typename DT_, typename IT_>
672 IT_ mult_cor(DT_* x, const DT_ alpha, const VectorTypeR& vec_cor, const IT_* idx, const IT_ m, const IT_ off) const
673 {
674 IT_ noff = _first.mult_cor(x, alpha, vec_cor, idx, m, off);
675 return _rest.mult_cor(x, alpha, vec_cor, idx, m, noff);
676 }
677 };
678
679 template<typename SubMatrix_>
680 class VankaMatrix<LAFEM::PowerColMatrix<SubMatrix_, 1>>
681 {
682 public:
683 typedef LAFEM::PowerColMatrix<SubMatrix_, 1> MatrixType;
684 typedef typename MatrixType::VectorTypeR VectorTypeR;
685 typedef VankaMatrix<SubMatrix_> FirstClass;
686
687 static constexpr int row_dim = FirstClass::row_dim;
688 static constexpr int col_dim = FirstClass::col_dim;
689
690 protected:
691 VankaMatrix<SubMatrix_> _first;
692
693 public:
694 explicit VankaMatrix(const MatrixType& matrix) :
695 _first(matrix.first())
696 {
697 }
698
699 template<typename DT_, typename IT_>
700 std::pair<IT_, IT_> gather_full(
701 DT_* data, const IT_* ridx, const IT_* cidx,
702 const IT_ m, const IT_ n, const IT_ stride,
703 const IT_ mo = IT_(0), const IT_ no = IT_(0)) const
704 {
705 return _first.gather_full(data, ridx, cidx, m, n, stride, mo, no);
706 }
707
708 template<int ro_, int co_, typename DT_, typename IT_>
709 IT_ gather_diag_pfm(DT_* data, const IT_* idx, const IT_ m, const IT_ mo = IT_(0)) const
710 {
711 return _first.template gather_diag_pfm<ro_, co_>(data, idx, m, mo);
712 }
713
714 template<typename DT_, typename IT_>
715 IT_ mult_cor(DT_* x, const DT_ alpha, const VectorTypeR& vec_cor, const IT_* idx, const IT_ m, const IT_ off) const
716 {
717 return _first.mult_cor(x, alpha, vec_cor, idx, m, off);
718 }
719 };
720
721 template<typename SubMatrix_, int dim_>
722 class VankaMatrix<LAFEM::PowerRowMatrix<SubMatrix_, dim_>>
723 {
724 public:
725 typedef LAFEM::PowerRowMatrix<SubMatrix_, dim_> MatrixType;
726 typedef typename MatrixType::VectorTypeR VectorTypeR;
727 typedef VankaMatrix<SubMatrix_> FirstClass;
728 typedef VankaMatrix<LAFEM::PowerRowMatrix<SubMatrix_, dim_-1>> RestClass;
729
730 static constexpr int row_dim = FirstClass::row_dim;
731 static constexpr int col_dim = FirstClass::col_dim + RestClass::col_dim;
732
733 protected:
734 FirstClass _first;
735 RestClass _rest;
736
737 public:
738 explicit VankaMatrix(const MatrixType& matrix) :
739 _first(matrix.first()),
740 _rest(matrix.rest())
741 {
742 }
743
744 template<typename DT_, typename IT_>
745 std::pair<IT_, IT_> gather_full(
746 DT_* data, const IT_* ridx, const IT_* cidx,
747 const IT_ m, const IT_ n, const IT_ stride,
748 const IT_ mo = IT_(0), const IT_ no = IT_(0)) const
749 {
750 std::pair<IT_, IT_> mno = _first.gather_full(data, ridx, cidx, m, n, stride, mo, no);
751 return _rest.gather_full(data, ridx, cidx, m, n, stride, mo, mno.second);
752 }
753
754 template<int ro_, int co_, typename DT_, typename IT_>
755 IT_ gather_diag_pfm(DT_* data, const IT_* idx, const IT_ m, const IT_ mo = IT_(0)) const
756 {
757 if(ro_ == co_)
758 return _first.gather_diag(data, idx, m, mo);
759 else
760 return _rest.template gather_diag_pfm<ro_, co_+1>(data, idx, m, mo);
761 }
762
763 template<typename DT_, typename IT_>
764 IT_ mult_cor(DT_* x, const DT_ alpha, const VectorTypeR& vec_cor, const IT_* idx, const IT_ m, const IT_ off) const
765 {
766 _first.mult_cor(x, alpha, vec_cor.first(), idx, m, off);
767 return _rest.mult_cor(x, alpha, vec_cor.rest(), idx, m, off);
768 }
769 };
770
771 template<typename SubMatrix_>
772 class VankaMatrix<LAFEM::PowerRowMatrix<SubMatrix_, 1>>
773 {
774 public:
775 typedef LAFEM::PowerRowMatrix<SubMatrix_, 1> MatrixType;
776 typedef VankaMatrix<SubMatrix_> FirstClass;
777 typedef typename MatrixType::VectorTypeR VectorTypeR;
778
779 static constexpr int row_dim = FirstClass::row_dim;
780 static constexpr int col_dim = FirstClass::col_dim;
781
782 protected:
783 FirstClass _first;
784
785 public:
786 explicit VankaMatrix(const MatrixType& matrix) :
787 _first(matrix.first())
788 {
789 }
790
791 template<typename DT_, typename IT_>
792 std::pair<IT_, IT_> gather_full(
793 DT_* data, const IT_* ridx, const IT_* cidx,
794 const IT_ m, const IT_ n, const IT_ stride,
795 const IT_ mo = IT_(0), const IT_ no = IT_(0)) const
796 {
797 return _first.gather_full(data, ridx, cidx, m, n, stride, mo, no);
798 }
799
800 template<int ro_, int co_, typename DT_, typename IT_>
801 IT_ gather_diag_pfm(DT_* data, const IT_* idx, const IT_ m, const IT_ mo = IT_(0)) const
802 {
803 if(ro_ == co_)
804 return _first.gather_diag(data, idx, m, mo);
805 else
806 return mo;
807 }
808
809 template<typename DT_, typename IT_>
810 IT_ mult_cor(DT_* x, const DT_ alpha, const VectorTypeR& vec_cor, const IT_* idx, const IT_ m, const IT_ off) const
811 {
812 return _first.mult_cor(x, alpha, vec_cor.first(), idx, m, off);
813 }
814 };
815
816 template<typename SubMatrix_, int dim_w_, int dim_h_>
817 class VankaMatrix<LAFEM::PowerFullMatrix<SubMatrix_, dim_w_, dim_h_>>
818 {
819 public:
820 typedef LAFEM::PowerFullMatrix<SubMatrix_, dim_w_, dim_h_> MatrixType;
821 typedef typename MatrixType::VectorTypeR VectorTypeR;
822 typedef VankaMatrix<typename MatrixType::ContClass> ContClass;
823
824 static constexpr int row_dim = ContClass::row_dim;
825 static constexpr int col_dim = ContClass::col_dim;
826
827 protected:
828 ContClass _cont;
829
830 public:
831 explicit VankaMatrix(const MatrixType& matrix) :
832 _cont(matrix.get_container())
833 {
834 }
835
836 template<typename DT_, typename IT_>
837 std::pair<IT_, IT_> gather_full(
838 DT_* data, const IT_* ridx, const IT_* cidx,
839 const IT_ m, const IT_ n, const IT_ stride,
840 const IT_ mo = IT_(0), const IT_ no = IT_(0)) const
841 {
842 return _cont.gather_full(data, ridx, cidx, m, n, stride, mo, no);
843 }
844
845 template<typename DT_, typename IT_>
846 IT_ gather_diag(DT_* data, const IT_* idx, const IT_ m, const IT_ mo = IT_(0)) const
847 {
848 return _cont.template gather_diag_pfm<0,0>(data, idx, m, mo);
849 }
850
851 template<typename DT_, typename IT_>
852 IT_ mult_cor(DT_* x, const DT_ alpha, const VectorTypeR& vec_cor, const IT_* idx, const IT_ m, const IT_ off) const
853 {
854 return _cont.mult_cor(x, alpha, vec_cor, idx, m, off);
855 }
856 };
857
858 template<typename DT_, typename IT_>
859 Memory::TypedView<IT_> vanka_row_ptr(
860 const LAFEM::SparseMatrixCSR<DT_, IT_>& matrix)
861 {
862 return matrix.row_ptr_view_r();
863 }
864
865 template<typename DT_, typename IT_, int m_, int n_>
866 Memory::TypedView<IT_> vanka_row_ptr(
867 const LAFEM::SparseMatrixBCSR<DT_, IT_, m_, n_>& matrix)
868 {
869 return matrix.row_ptr_view_r();
870 }
871
872 template<typename DT_, typename IT_, int dim_>
873 Memory::TypedView<IT_> vanka_row_ptr(
874 const LAFEM::PowerColMatrix<LAFEM::SparseMatrixCSR<DT_, IT_>, dim_>& matrix)
875 {
876 return matrix.first().row_ptr_view_r();
877 }
878
879 template<typename DT_, typename IT_, int dim_>
880 Memory::TypedView<IT_> vanka_row_ptr(
881 const LAFEM::PowerRowMatrix<LAFEM::SparseMatrixCSR<DT_, IT_>, dim_>& matrix)
882 {
883 return matrix.first().row_ptr_view_r();
884 }
885
886 template<typename DT_, typename IT_, int dim_>
887 Memory::TypedView<IT_> vanka_row_ptr(
888 const LAFEM::PowerDiagMatrix<LAFEM::SparseMatrixCSR<DT_, IT_>, dim_>& matrix)
889 {
890 return matrix.first().row_ptr_view_r();
891 }
892
893 template<typename DT_, typename IT_, int row_dim_, int col_dim_>
894 Memory::TypedView<IT_> vanka_row_ptr(
895 const LAFEM::PowerFullMatrix<LAFEM::SparseMatrixCSR<DT_, IT_>, row_dim_, col_dim_>& matrix)
896 {
897 return matrix.first().row_ptr_view_r();
898 }
899
900 template<typename DT_, typename IT_>
901 Memory::TypedView<IT_> vanka_col_idx(
902 const LAFEM::SparseMatrixCSR<DT_, IT_>& matrix)
903 {
904 return matrix.col_idx_view_r();
905 }
906
907 template<typename DT_, typename IT_, int m_, int n_>
908 Memory::TypedView<IT_> vanka_col_idx(
909 const LAFEM::SparseMatrixBCSR<DT_, IT_, m_, n_>& matrix)
910 {
911 return matrix.col_idx_view_r();
912 }
913
914 template<typename DT_, typename IT_, int dim_>
915 Memory::TypedView<IT_> vanka_col_idx(
916 const LAFEM::PowerColMatrix<LAFEM::SparseMatrixCSR<DT_, IT_>, dim_>& matrix)
917 {
918 return matrix.first().col_idx_view_r();
919 }
920
921 template<typename DT_, typename IT_, int dim_>
922 Memory::TypedView<IT_> vanka_col_idx(
923 const LAFEM::PowerRowMatrix<LAFEM::SparseMatrixCSR<DT_, IT_>, dim_>& matrix)
924 {
925 return matrix.first().col_idx_view_r();
926 }
927
928 template<typename DT_, typename IT_, int dim_>
929 Memory::TypedView<IT_> vanka_col_idx(
930 const LAFEM::PowerDiagMatrix<LAFEM::SparseMatrixCSR<DT_, IT_>, dim_>& matrix)
931 {
932 return matrix.first().col_idx_view_r();
933 }
934
935 template<typename DT_, typename IT_, int row_dim_, int col_dim_>
936 Memory::TypedView<IT_> vanka_col_idx(
937 const LAFEM::PowerFullMatrix<LAFEM::SparseMatrixCSR<DT_, IT_>, row_dim_, col_dim_>& matrix)
938 {
939 return matrix.first().col_idx_view_r();
940 }
941
942 } // namespace Intern
944
951 enum class VankaType
952 {
954 nodal_diag_mult = 0x000,
956 nodal_full_mult = 0x001,
958 block_diag_mult = 0x010,
960 block_full_mult = 0x011,
962 nodal_diag_add = 0x100,
964 nodal_full_add = 0x101,
966 block_diag_add = 0x110,
968 block_full_add = 0x111
969 };
970
979 public SolverException
980 {
981 public:
982 VankaFactorError() : SolverException("Vanka Factorization Error") {}
983 };
984
993 template<typename Matrix_, typename Filter_>
994 class Vanka;
995
1068 template<typename MatrixA_, typename MatrixB_, typename MatrixD_, typename Filter_>
1069 class Vanka<LAFEM::SaddlePointMatrix<MatrixA_, MatrixB_, MatrixD_>, Filter_> :
1070 public SolverBase<LAFEM::TupleVector<typename MatrixB_::VectorTypeL, typename MatrixD_::VectorTypeL>>
1071 {
1072 public:
1076 typedef Filter_ FilterType;
1077
1084
1086 typedef typename MatrixD_::VectorTypeR VectorV;
1088 typedef typename MatrixB_::VectorTypeR VectorP;
1089
1090 protected:
1091 // our Vanka matrix types
1092 typedef Intern::VankaMatrix<MatrixA_> VankaMatrixA;
1093 typedef Intern::VankaMatrix<MatrixB_> VankaMatrixB;
1094 typedef Intern::VankaMatrix<MatrixD_> VankaMatrixD;
1095
1096 // dimension sanity checks
1097 static_assert(VankaMatrixA::row_dim == VankaMatrixA::col_dim, "Matrix A has invalid dimensions");
1098 static_assert(VankaMatrixA::row_dim == VankaMatrixB::row_dim, "Matrices A and B have incompatible dimensions");
1099 static_assert(VankaMatrixA::col_dim == VankaMatrixD::col_dim, "Matrices A and D have incompatible dimensions");
1100 static_assert(VankaMatrixB::col_dim == VankaMatrixD::row_dim, "Matrices B and D have incompatible dimensions");
1101
1102 // for now, B and D cannot have more than 1 pressure dimension...
1103 static_assert(VankaMatrixB::col_dim == 1, "Invalid pressure space dimension");
1104
1120 std::vector<IndexType> _block_v_ptr, _block_v_idx;
1122 std::vector<IndexType> _block_p_ptr, _block_p_idx;
1124 std::vector<DataType> _data;
1126 std::vector<DataType> _vdef, _vcor;
1128 VectorType _vec_scale, _vec_tmp1, _vec_tmp2;
1129
1130 // stop watch for symbolic factorization
1131 StopWatch watch_init_symbolic;
1132 // stop watch for numeric factorization
1133 StopWatch watch_init_numeric;
1134 // stop watch for apply time
1135 StopWatch watch_apply;
1136
1137 public:
1156 explicit Vanka(const MatrixType& matrix, const FilterType& filter, VankaType type,
1157 DataType omega = DataType(1), Index num_iter = Index(1)) :
1158 _matrix(matrix),
1159 _filter(filter),
1160 _type(type),
1161 _omega(omega),
1162 _num_iter(num_iter)
1163 {
1164 }
1165
1167 virtual String name() const override
1168 {
1169 return "Vanka";
1170 }
1171
1173 virtual void init_symbolic() override
1174 {
1175 watch_init_symbolic.start();
1176
1177 bool block = ((int(_type) & 0x010) != 0);
1178 bool multi = ((int(_type) & 0x100) == 0);
1179
1180 // compute pressure block graph
1181 if(block)
1182 {
1183 this->_build_p_block();
1184 }
1185 else
1186 {
1187 this->_build_p_nodal();
1188 }
1189
1190 // compute velocity block graph
1191 this->_build_v_block();
1192
1193 // allocate memory for numerical factorization
1194 this->_alloc_data();
1195
1196 // allocate temporary vector for additive
1197 if(!multi)
1198 {
1199 this->_vec_scale = this->_matrix.create_vector_r();
1200 this->_vec_tmp1 = this->_matrix.create_vector_r();
1201 this->_vec_tmp2 = this->_matrix.create_vector_r();
1202 }
1203
1204 watch_init_symbolic.stop();
1205 }
1206
1208 virtual void done_symbolic() override
1209 {
1210 _vec_tmp2.clear();
1211 _vec_tmp1.clear();
1212 _vec_scale.clear();
1213 _vdef.clear();
1214 _vcor.clear();
1215 _data.clear();
1216 _block_v_ptr.clear();
1217 _block_v_idx.clear();
1218 _block_p_ptr.clear();
1219 _block_p_idx.clear();
1220 }
1221
1223 virtual void init_numeric() override
1224 {
1225 watch_init_numeric.start();
1226
1227 bool full = ((int(_type) & 0x001) != 0);
1228 bool multi = ((int(_type) & 0x100) == 0);
1229
1230 if(full)
1231 {
1232 this->_factor_full();
1233 }
1234 else
1235 {
1236 this->_factor_diag();
1237 }
1238
1239 if(!multi)
1240 {
1241 this->_calc_scale();
1242 }
1243
1244 watch_init_numeric.stop();
1245 }
1246
1247 virtual Status apply(VectorType& vec_cor, const VectorType& vec_def) override
1248 {
1249 watch_apply.start();
1250
1251 bool full = ((int(_type) & 0x001) != 0);
1252 if(full)
1253 {
1254 this->_apply_full(vec_cor, vec_def);
1255 }
1256 else
1257 {
1258 this->_apply_diag(vec_cor, vec_def);
1259 }
1260
1261 watch_apply.stop();
1262
1263 return Status::success;
1264 }
1265
1266 std::size_t data_size() const
1267 {
1268 return _data.size();
1269 }
1270
1271 std::size_t bytes() const
1272 {
1273 return sizeof(IndexType) * (_block_v_ptr.size() + _block_v_idx.size() + _block_p_ptr.size() + _block_p_idx.size())
1274 + sizeof(DataType) * (_data.size() + _vdef.size() + _vcor.size())
1275 + _vec_scale.bytes() + _vec_tmp1.bytes() + _vec_tmp2.bytes();
1276 }
1277
1282 {
1283 watch_init_symbolic.reset();
1284 watch_init_numeric.reset();
1285 watch_apply.reset();
1286 }
1287
1291 double time_init_symbolic() const
1292 {
1293 return watch_init_symbolic.elapsed();
1294 }
1295
1299 double time_init_numeric() const
1300 {
1301 return watch_init_numeric.elapsed();
1302 }
1303
1307 double time_apply() const
1308 {
1309 return watch_apply.elapsed();
1310 }
1311
1312 protected:
1320 {
1321 // fetch matrix dimensions
1322 const IndexType m = IndexType(_matrix.block_d().num_rows());
1323
1324 // fetch the matrix arrays
1325 const Memory::TypedView<IndexType> row_ptr_b = Intern::vanka_row_ptr(_matrix.block_b());
1326 const Memory::TypedView<IndexType> col_idx_b = Intern::vanka_col_idx(_matrix.block_b());
1327 const Memory::TypedView<IndexType> row_ptr_d = Intern::vanka_row_ptr(_matrix.block_d());
1328 const Memory::TypedView<IndexType> col_idx_d = Intern::vanka_col_idx(_matrix.block_d());
1329
1330 // clear block arrays
1331 _block_p_ptr.clear();
1332 _block_p_idx.clear();
1333 _block_p_ptr.push_back(IndexType(0));
1334
1335 // local map
1336 std::map<IndexType, int> map_s;
1337
1338 // allocate mask vector
1339 std::vector<int> mask(std::size_t(m), 0);
1340
1341 // loop over all pressure nodes
1342 for(Index i(0); i < m; ++i)
1343 {
1344 // is this node already processed?
1345 if(mask[i] != 0)
1346 continue;
1347
1348 // clear the local map
1349 map_s.clear();
1350
1351 // okay, loop over all entries of D
1352 for(IndexType kd = row_ptr_d[i]; kd < row_ptr_d[i+1]; ++kd)
1353 {
1354 // fetch the column index of D
1355 const IndexType col_d = col_idx_d[kd];
1356
1357 // loop over the row of B
1358 for(IndexType kb = row_ptr_b[col_d]; kb < row_ptr_b[col_d+1]; ++kb)
1359 {
1360 // fetch the column index of B
1361 const IndexType col_b = col_idx_b[kb];
1362
1363 // insert into map
1364 auto ib = map_s.emplace(col_b, 1);
1365 if(!ib.second)
1366 {
1367 // node already exists, increment counter then
1368 ++(ib.first->second);
1369 }
1370 }
1371 }
1372
1373 // compute the map degree
1374 int ideg = 0;
1375 for(auto it = map_s.begin(); it != map_s.end(); ++it)
1376 ideg = Math::max(ideg, it->second);
1377
1378 // loop over all map entries with maximum degree
1379 for(auto it = map_s.begin(); it != map_s.end(); ++it)
1380 {
1381 if(ideg == it->second)
1382 {
1383 // insert into map
1384 _block_p_idx.push_back(it->first);
1385 mask[it->first] = 1;
1386 }
1387 }
1388
1389 // push row
1390 _block_p_ptr.push_back(IndexType(_block_p_idx.size()));
1391 }
1392 }
1393
1398 {
1399 const IndexType m = IndexType(_matrix.block_d().num_rows());
1400
1401 // clear block arrays
1402 _block_p_ptr.clear();
1403 _block_p_idx.clear();
1404 _block_p_ptr.reserve(m+1);
1405 _block_p_idx.reserve(m);
1406 for(IndexType i(0); i < m; ++i)
1407 {
1408 _block_p_ptr.push_back(i);
1409 _block_p_idx.push_back(i);
1410 }
1411 _block_p_ptr.push_back(m);
1412 }
1413
1416 {
1417 // fetch the matrix arrays
1418 const Memory::TypedView<IndexType> row_ptr_d = Intern::vanka_row_ptr(_matrix.block_d());
1419 const Memory::TypedView<IndexType> col_idx_d = Intern::vanka_col_idx(_matrix.block_d());
1420
1421 // fetch number of pressure blocks
1422 const IndexType m = IndexType(_block_p_ptr.size()-1);
1423
1424 // clear block arrays
1425 _block_v_ptr.clear();
1426 _block_v_idx.clear();
1427 _block_v_ptr.reserve(m+1);
1428 _block_v_ptr.push_back(IndexType(0));
1429
1430 std::set<IndexType> set_v;
1431
1432 // loop over all pressure blocks
1433 for(IndexType i(0); i < m; ++i)
1434 {
1435 // loop over all pressure dofs in the current block
1436 for(IndexType j = _block_p_ptr[i]; j < _block_p_ptr[i+1]; ++j)
1437 {
1438 // get the pressure dof index
1439 const IndexType pix = _block_p_idx[j];
1440
1441 // now loop over the corresponding row of D
1442 for(IndexType k = row_ptr_d[pix]; k < row_ptr_d[pix+1]; ++k)
1443 {
1444 // insert velocity dof into block set
1445 set_v.insert(col_idx_d[k]);
1446 }
1447 }
1448
1449 // push velocity block
1450 for(auto it = set_v.begin(); it != set_v.end(); ++it)
1451 {
1452 _block_v_idx.push_back(*it);
1453 }
1454
1455 // update pointer
1456 _block_v_ptr.push_back(IndexType(_block_v_idx.size()));
1457
1458 // clear local set
1459 set_v.clear();
1460 }
1461 }
1462
1465 {
1466 // get the dimension of our system
1467 const IndexType dim = IndexType(Intern::VankaMatrix<MatrixA_>::row_dim);
1468
1469 // use diagonal?
1470 bool diag = ((int(_type) & 1) == 0);
1471
1472 // number of non-zero entries
1473 IndexType nze = IndexType(0);
1474
1475 // reset degrees
1476 _degree_v = _degree_p = IndexType(0);
1477
1478 // loop over all blocks
1479 const IndexType m = IndexType(_block_p_ptr.size()-1);
1480 for(IndexType i(0); i < m; ++i)
1481 {
1482 // get number of velocity and pressure dofs
1483 IndexType nv = _block_v_ptr[i+1] - _block_v_ptr[i];
1484 IndexType np = _block_p_ptr[i+1] - _block_p_ptr[i];
1485
1486 // update degrees
1487 _degree_v = Math::max(nv, _degree_v);
1488 _degree_p = Math::max(np, _degree_p);
1489
1490 // update count
1491 if(diag)
1492 {
1493 // main diagonal of A
1494 nze += dim * nv;
1495 // matrices B and D
1496 nze += IndexType(2) * dim * nv * np;
1497 // Schur-Complement matrix S
1498 nze += np * np;
1499 }
1500 else
1501 {
1502 // dense local systems
1503 nze += Math::sqr(dim*nv + np);
1504 }
1505 }
1506
1507 // finally, allocate our memory
1508 _data.resize(nze);
1509 _vdef.resize(dim*_degree_v + _degree_p);
1510 _vcor.resize(dim*_degree_v + _degree_p);
1511 }
1512
1515 {
1516 // create a Vanka Vector
1517 this->_vec_scale.format();
1518
1519 {
1520 Intern::VankaVector<VectorV> vanka_v(this->_vec_scale.template at<0>());
1521 Intern::VankaVector<VectorP> vanka_p(this->_vec_scale.template at<1>());
1522
1523 // get our data arrays
1524 const IndexType* vptr = _block_v_ptr.data();
1525 const IndexType* vidx = _block_v_idx.data();
1526 const IndexType* pptr = _block_p_ptr.data();
1527 const IndexType* pidx = _block_p_idx.data();
1528
1529 // create a vector of ones
1530 std::vector<DataType> vec_one(vanka_v.dim*_degree_v + _degree_p, DataType(1));
1531 const DataType* vone = vec_one.data();
1532
1533 // loop over all blocks
1534 const IndexType nblocks = IndexType(_block_v_ptr.size() - 1);
1535 for(IndexType iblock(0); iblock < nblocks; ++iblock)
1536 {
1537 // get number of velocity and pressure dofs
1538 const IndexType nv = vptr[iblock+1] - vptr[iblock];
1539 const IndexType np = pptr[iblock+1] - pptr[iblock];
1540
1541 // scatter ones
1542 vanka_v.scatter_cor(DataType(1), vone, &vidx[vptr[iblock]], nv, IndexType(0));
1543 vanka_p.scatter_cor(DataType(1), vone, &pidx[pptr[iblock]], np, IndexType(0));
1544 }
1545 }
1546
1547 // invert components
1548 this->_vec_scale.component_invert(this->_vec_scale);
1549 }
1550
1553 {
1554 Intern::VankaMatrix<MatrixA_> vanka_a(_matrix.block_a());
1555 Intern::VankaMatrix<MatrixB_> vanka_b(_matrix.block_b());
1556 Intern::VankaMatrix<MatrixD_> vanka_d(_matrix.block_d());
1557
1558 // get the dimension of our system
1559 const IndexType dim = IndexType(vanka_a.row_dim);
1560
1561 // get our data arrays
1562 DataType* data = _data.data();
1563 const IndexType* vptr = _block_v_ptr.data();
1564 const IndexType* vidx = _block_v_idx.data();
1565 const IndexType* pptr = _block_p_ptr.data();
1566 const IndexType* pidx = _block_p_idx.data();
1567
1568 // format block data
1569 Memory::memset_main(data, 0, sizeof(DataType) * _data.size());
1570
1571 // allocate pivot array
1572 std::vector<IndexType> pivot(3*(dim*_degree_v + _degree_p));
1573
1574 // current block offset
1575 IndexType block_offset = IndexType(0);
1576
1577 // loop over all blocks
1578 const IndexType nblocks = IndexType(_block_v_ptr.size() - 1);
1579 for(IndexType iblock(0); iblock < nblocks; ++iblock)
1580 {
1581 // get number of velocity and pressure dofs
1582 const IndexType nv = vptr[iblock+1] - vptr[iblock];
1583 const IndexType np = pptr[iblock+1] - pptr[iblock];
1584
1585 // get our local indices
1586 const IndexType* loc_vidx = &vidx[vptr[iblock]];
1587 const IndexType* loc_pidx = &pidx[pptr[iblock]];
1588
1589 // compute matrix stride
1590 const IndexType n = dim*nv + np;
1591 const IndexType block_size = n*n;
1592
1593 // get our block data array pointer
1594 DataType* block_data = &data[block_offset];
1595
1596 // gather matrix a
1597 std::pair<IndexType,IndexType> ao =
1598 vanka_a.gather_full(block_data, loc_vidx, loc_vidx, nv, nv, n);
1599 vanka_b.gather_full(block_data, loc_vidx, loc_pidx, nv, np, n, IndexType(0), ao.second);
1600 vanka_d.gather_full(block_data, loc_pidx, loc_vidx, np, nv, n, ao.first, IndexType(0));
1601
1602 // invert local matrix block
1603 /*DataType ret =*/ Math::invert_matrix(n, n, block_data, pivot.data());
1604 //if(!Math::isnormal(ret))
1605 //{
1606 // Don't throw any exceptions, as this often leads to false alerts
1607 //throw VankaFactorError();
1608 //}
1609
1610 // increment block data offset
1611 block_offset += block_size;
1612 }
1613 }
1614
1616 void _apply_full(VectorType& vec_cor, const VectorType& vec_def)
1617 {
1618 // format correction vector
1619 vec_cor.format();
1620
1621 // do we use the multiplicative variant?
1622 const bool multi = ((int(_type) & 0x100) == 0);
1623
1624 // additive?
1625 if(!multi)
1626 {
1627 this->_vec_tmp1.copy(vec_def);
1628 this->_vec_tmp2.format();
1629 }
1630
1631 // get our sub-vectors
1632 VectorV& vec_cv = (multi ? vec_cor.template at<0>() : this->_vec_tmp2.template at<0>());
1633 VectorP& vec_cp = (multi ? vec_cor.template at<1>() : this->_vec_tmp2.template at<1>());
1634 const VectorV& vec_dv = (multi ? vec_def.template at<0>() : this->_vec_tmp1.template at<0>());
1635 const VectorP& vec_dp = (multi ? vec_def.template at<1>() : this->_vec_tmp1.template at<1>());
1636
1637 // get velocity vector dimension
1638 const IndexType velo_dim = IndexType(Intern::VankaVector<VectorV>::dim);
1639
1640 // get block count
1641 const IndexType num_blocks = IndexType(_block_v_ptr.size()-1);
1642
1643 // get block data arrays
1644 const IndexType* vptr = _block_v_ptr.data();
1645 const IndexType* vidx = _block_v_idx.data();
1646 const IndexType* pptr = _block_p_ptr.data();
1647 const IndexType* pidx = _block_p_idx.data();
1648
1649 // get local data and vectors
1650 const DataType* lmat_data = _data.data();
1651 DataType* lcor = _vcor.data();
1652 DataType* ldef = _vdef.data();
1653
1654 Index flops(0);
1655
1656 // iterate
1657 for(IndexType iter(0); iter < _num_iter; ++iter)
1658 {
1659 // additive variant?
1660 if((!multi) && (iter > IndexType(0)))
1661 {
1662 // compute current defect
1663 this->_matrix.apply(_vec_tmp1, vec_cor, vec_def, -DataType(1));
1664 _vec_tmp2.format();
1665 }
1666
1667 TimeStamp stamp_kernel;
1668
1669 // reset block offset
1670 IndexType block_offset = IndexType(0);
1671
1672 // loop over all blocks
1673 for(IndexType iblock(0); iblock < num_blocks; ++iblock)
1674 {
1675 // get local sizes
1676 const IndexType nv = vptr[iblock+1] - vptr[iblock];
1677 const IndexType np = pptr[iblock+1] - pptr[iblock];
1678
1679 // get our local indices
1680 const IndexType* loc_vidx = &vidx[vptr[iblock]];
1681 const IndexType* loc_pidx = &pidx[pptr[iblock]];
1682
1683 // compute local degree
1684 const IndexType n = velo_dim * nv + np;
1685
1686 // get our local matrix data
1687 const DataType* lmat = &lmat_data[block_offset];
1688
1689 // get local vectors
1690 DataType* lcor_v = lcor;
1691 DataType* lcor_p = &lcor[velo_dim * nv];
1692 DataType* ldef_v = ldef;
1693 DataType* ldef_p = &ldef[velo_dim * nv];
1694
1695 // gather local defect
1696 {
1697 Intern::VankaVector<VectorV> vanka_dv(vec_dv);
1698 Intern::VankaVector<VectorP> vanka_dp(vec_dp);
1699 vanka_dv.gather_def(ldef_v, loc_vidx, nv, IndexType(0));
1700 vanka_dp.gather_def(ldef_p, loc_pidx, np, IndexType(0));
1701 }
1702
1703 // multiplicative variants only:
1704 if(multi)
1705 {
1706 Intern::VankaMatrix<MatrixA_> vanka_a(_matrix.block_a());
1707 Intern::VankaMatrix<MatrixB_> vanka_b(_matrix.block_b());
1708 Intern::VankaMatrix<MatrixD_> vanka_d(_matrix.block_d());
1709
1710 // subtract A*x
1711 vanka_a.mult_cor(ldef_v, -DataType(1), vec_cv, loc_vidx, nv, IndexType(0));
1712 vanka_b.mult_cor(ldef_v, -DataType(1), vec_cp, loc_vidx, nv, IndexType(0));
1713 vanka_d.mult_cor(ldef_p, -DataType(1), vec_cv, loc_pidx, np, IndexType(0));
1714 }
1715
1716 // solve local system
1717 for(IndexType i(0); i < n; ++i)
1718 {
1719 lcor[i] = DataType(0);
1720 for(IndexType j(0); j < n; ++j)
1721 {
1722 lcor[i] += lmat[i*n + j] * ldef[j];
1723 }
1724 }
1725 flops += 2*n*n;
1726
1727 // scatter result
1728 {
1729 Intern::VankaVector<VectorV> vanka_cv(vec_cv);
1730 Intern::VankaVector<VectorP> vanka_cp(vec_cp);
1731 vanka_cv.scatter_cor(_omega, lcor_v, loc_vidx, nv, IndexType(0));
1732 vanka_cp.scatter_cor(_omega, lcor_p, loc_pidx, np, IndexType(0));
1733 }
1734
1735 // update block offset
1736 block_offset += n*n;
1737 }
1738
1739 Statistics::add_time_precon(stamp_kernel.elapsed_now());
1740
1741 // additive variant?
1742 if(!multi)
1743 {
1744 // multiply by scaling vector
1745 this->_vec_tmp2.component_product(this->_vec_tmp2, this->_vec_scale);
1746
1747 // update correction vector
1748 vec_cor.axpy(this->_vec_tmp2);
1749 }
1750
1751 // apply filter
1752 _filter.filter_cor(vec_cor);
1753 }
1754
1755 Statistics::add_flops(flops);
1756 }
1757
1760 {
1761 Intern::VankaMatrix<MatrixA_> vanka_a(_matrix.block_a());
1762 Intern::VankaMatrix<MatrixB_> vanka_b(_matrix.block_b());
1763 Intern::VankaMatrix<MatrixD_> vanka_d(_matrix.block_d());
1764
1765 // get the dimension of our system
1766 const IndexType dim = IndexType(vanka_a.row_dim);
1767
1768 // get our data arrays
1769 DataType* data = _data.data();
1770 const IndexType* vptr = _block_v_ptr.data();
1771 const IndexType* vidx = _block_v_idx.data();
1772 const IndexType* pptr = _block_p_ptr.data();
1773 const IndexType* pidx = _block_p_idx.data();
1774
1775 // format block data
1776 Memory::memset_main(data, 0, sizeof(DataType) * _data.size());
1777
1778 // allocate pivot array (pressure only)
1779 std::vector<IndexType> pivot(3*_degree_p);
1780
1781 // current block offset
1782 IndexType block_offset = IndexType(0);
1783
1784 // loop over all blocks
1785 const IndexType nblocks = IndexType(_block_v_ptr.size() - 1);
1786 for(IndexType iblock(0); iblock < nblocks; ++iblock)
1787 {
1788 // get number of velocity and pressure dofs
1789 const IndexType nv = vptr[iblock+1] - vptr[iblock];
1790 const IndexType np = pptr[iblock+1] - pptr[iblock];
1791 const IndexType dnv = dim*nv;
1792
1793 // get our local indices
1794 const IndexType* loc_vidx = &vidx[vptr[iblock]];
1795 const IndexType* loc_pidx = &pidx[pptr[iblock]];
1796
1797 // compute local block size
1798 const IndexType block_size = dnv + IndexType(2) * dnv * np + np*np;
1799
1800 // get our block data array pointer
1801 DataType* block_data = &data[block_offset];
1802
1803 // get our local matrices
1804 DataType* loc_a = block_data;
1805 DataType* loc_b = &block_data[dnv];
1806 DataType* loc_d = &block_data[dnv + dnv*np];
1807 DataType* loc_s = &block_data[dnv + IndexType(2)*dnv*np];
1808
1809 // gather diag(A)
1810 vanka_a.gather_diag(loc_a, loc_vidx, nv);
1811 // gather B and D
1812 vanka_b.gather_full(loc_b, loc_vidx, loc_pidx, nv, np, np);
1813 vanka_d.gather_full(loc_d, loc_pidx, loc_vidx, np, nv, dnv);
1814
1815 // invert diag(A) and pre-multiply D by diag(A)^{-1}
1816 for(IndexType i(0); i < dnv; ++i)
1817 {
1818 // invert a_ii
1819 loc_a[i] = DataType(1) / loc_a[i];
1820
1821 // make sure we have a normal value
1822 if(!Math::isnormal(loc_a[i]))
1823 {
1824 throw VankaFactorError();
1825 }
1826
1827 // pre-multiply D by diag(A)^{-1}
1828 for(IndexType j(0); j < np; ++j)
1829 {
1830 loc_d[j*dnv + i] *= loc_a[i];
1831 }
1832 }
1833
1834 // calculate Schur-complement of A:
1835 // S := -D * diag(A)^{-1} * B
1836 for(IndexType i(0); i < np; ++i)
1837 {
1838 for(IndexType j(0); j < np; ++j)
1839 {
1840 DataType s = DataType(0);
1841 for(IndexType k(0); k < dnv; ++k)
1842 {
1843 // Note: D is already pre-multiplied by diag(A)^{-1}
1844 s += loc_d[i*dnv + k] * loc_b[k*np + j];
1845 }
1846 loc_s[i*np + j] = -s;
1847 }
1848 }
1849
1850 // invert local matrix S
1851 DataType det = Math::invert_matrix(np, np, loc_s, pivot.data());
1852 if(!Math::isnormal(det))
1853 {
1855 throw VankaFactorError();
1856 }
1857
1858 // increment block data offset
1859 block_offset += block_size;
1860 }
1861 }
1862
1864 void _apply_diag(VectorType& vec_cor, const VectorType& vec_def)
1865 {
1866 // format correction vector
1867 vec_cor.format();
1868
1869 // do we use the multiplicative variant?
1870 const bool multi = ((int(_type) & 0x100) == 0);
1871
1872 // additive?
1873 if(!multi)
1874 {
1875 this->_vec_tmp1.copy(vec_def);
1876 this->_vec_tmp2.format();
1877 }
1878
1879 // get our sub-vectors
1880 VectorV& vec_cv = (multi ? vec_cor.template at<0>() : this->_vec_tmp2.template at<0>());
1881 VectorP& vec_cp = (multi ? vec_cor.template at<1>() : this->_vec_tmp2.template at<1>());
1882 const VectorV& vec_dv = (multi ? vec_def.template at<0>() : this->_vec_tmp1.template at<0>());
1883 const VectorP& vec_dp = (multi ? vec_def.template at<1>() : this->_vec_tmp1.template at<1>());
1884
1885 // get velocity vector dimension
1886 const IndexType velo_dim = IndexType(Intern::VankaVector<VectorV>::dim);
1887
1888 // get block count
1889 const IndexType num_blocks = IndexType(_block_v_ptr.size()-1);
1890
1891 // get block data arrays
1892 const IndexType* vptr = _block_v_ptr.data();
1893 const IndexType* vidx = _block_v_idx.data();
1894 const IndexType* pptr = _block_p_ptr.data();
1895 const IndexType* pidx = _block_p_idx.data();
1896
1897 // get local data and vectors
1898 const DataType* data = _data.data();
1899 DataType* lcor = _vcor.data();
1900 DataType* ldef = _vdef.data();
1901
1902 Index flops(0);
1903
1904 // iterate
1905 for(IndexType iter(0); iter < _num_iter; ++iter)
1906 {
1907 // additive variant?
1908 if((!multi) && (iter > IndexType(0)))
1909 {
1910 // compute current defect
1911 this->_matrix.apply(_vec_tmp1, vec_cor, vec_def, -DataType(1));
1912 _vec_tmp2.format();
1913 }
1914
1915 TimeStamp stamp_kernel;
1916
1917 // reset block offset
1918 IndexType block_offset = IndexType(0);
1919
1920 // loop over all blocks
1921 for(IndexType iblock(0); iblock < num_blocks; ++iblock)
1922 {
1923 // get local sizes
1924 const IndexType nv = vptr[iblock+1] - vptr[iblock];
1925 const IndexType np = pptr[iblock+1] - pptr[iblock];
1926 const IndexType dnv = velo_dim*nv;
1927
1928 // get our local indices
1929 const IndexType* loc_vidx = &vidx[vptr[iblock]];
1930 const IndexType* loc_pidx = &pidx[pptr[iblock]];
1931
1932 // compute local block size
1933 const IndexType block_size = dnv + IndexType(2) * dnv * np + np*np;
1934
1935 // get our block data array pointer
1936 const DataType* block_data = &data[block_offset];
1937
1938 // get our local matrices
1939 const DataType* loc_a = block_data;
1940 const DataType* loc_b = &block_data[dnv];
1941 const DataType* loc_d = &block_data[dnv + dnv*np];
1942 const DataType* loc_s = &block_data[dnv + IndexType(2)*dnv*np];
1943
1944 // get local vectors
1945 DataType* lcor_v = lcor;
1946 DataType* lcor_p = &lcor[dnv];
1947 DataType* ldef_v = ldef;
1948 DataType* ldef_p = &ldef[dnv];
1949
1950 // gather local defect
1951 {
1952 Intern::VankaVector<VectorV> vanka_dv(vec_dv);
1953 Intern::VankaVector<VectorP> vanka_dp(vec_dp);
1954 vanka_dv.gather_def(ldef_v, loc_vidx, nv, IndexType(0));
1955 vanka_dp.gather_def(ldef_p, loc_pidx, np, IndexType(0));
1956 }
1957
1958 // multiplicative variants only:
1959 if(multi)
1960 {
1961 Intern::VankaMatrix<MatrixA_> vanka_a(_matrix.block_a());
1962 Intern::VankaMatrix<MatrixB_> vanka_b(_matrix.block_b());
1963 Intern::VankaMatrix<MatrixD_> vanka_d(_matrix.block_d());
1964 // subtract A*x
1965 vanka_a.mult_cor(ldef_v, -DataType(1), vec_cv, loc_vidx, nv, IndexType(0));
1966 vanka_b.mult_cor(ldef_v, -DataType(1), vec_cp, loc_vidx, nv, IndexType(0));
1967 vanka_d.mult_cor(ldef_p, -DataType(1), vec_cv, loc_pidx, np, IndexType(0));
1968 }
1969
1970 // update pressure RHS:
1971 // g_p := f_p - D * diag(A)^{-1} * f_u
1972 for(IndexType i(0); i < np; ++i)
1973 {
1974 DataType r = DataType(0);
1975 for(IndexType j(0); j < dnv; ++j)
1976 {
1977 // Note: D is already pre-multiplied by diag(A)^{-1}
1978 r += loc_d[i*dnv + j] * ldef_v[j];
1979 }
1980 ldef_p[i] -= r;
1981 }
1982 flops += 2*np*dnv;
1983
1984 // solve pressure:
1985 // p := S^{-1} * g_p
1986 for(IndexType i(0); i < np; ++i)
1987 {
1988 DataType r = DataType(0);
1989 for(IndexType j(0); j < np; ++j)
1990 {
1991 r += loc_s[i*np + j] * ldef_p[j];
1992 }
1993 lcor_p[i] = r;
1994 }
1995 flops += 2*np*np;
1996
1997 // update velocity RHS and solve velocity
1998 for(IndexType i(0); i < dnv; ++i)
1999 {
2000 DataType xb = DataType(0);
2001 for(IndexType j(0); j < np; ++j)
2002 {
2003 xb += loc_b[i*np + j] * lcor_p[j];
2004 }
2005 // solve: u := diag(A)^{-1} * (f_u - B*p)
2006 lcor_v[i] = loc_a[i] * (ldef_v[i] - xb);
2007 }
2008 flops += dnv * (2*np + 2);
2009
2010 // scatter result
2011 {
2012 Intern::VankaVector<VectorV> vanka_cv(vec_cv);
2013 Intern::VankaVector<VectorP> vanka_cp(vec_cp);
2014 vanka_cv.scatter_cor(_omega, lcor_v, loc_vidx, nv, IndexType(0));
2015 vanka_cp.scatter_cor(_omega, lcor_p, loc_pidx, np, IndexType(0));
2016 }
2017
2018 // update block offset
2019 block_offset += block_size;
2020 }
2021
2022 Statistics::add_time_precon(stamp_kernel.elapsed_now());
2023
2024 // additive variant?
2025 if(!multi)
2026 {
2027 // multiply by scaling vector
2028 this->_vec_tmp2.component_product(this->_vec_tmp2, this->_vec_scale);
2029
2030 // update correction vector
2031 vec_cor.axpy(this->_vec_tmp2);
2032 }
2033
2034 // apply filter
2035 _filter.filter_cor(vec_cor);
2036 }
2037
2038 Statistics::add_flops(flops);
2039 }
2040 }; // class Vanka<...>
2041
2063 template<typename MatrixA_, typename MatrixB_, typename MatrixD_, typename Filter_>
2064 std::shared_ptr<Vanka<LAFEM::SaddlePointMatrix<MatrixA_, MatrixB_, MatrixD_>, Filter_>> new_vanka(
2066 const Filter_& filter,
2067 VankaType type,
2068 typename MatrixA_::DataType omega = typename MatrixA_::DataType(1),
2069 Index num_iter = Index(1))
2070 {
2071 return std::make_shared<Vanka<LAFEM::SaddlePointMatrix<MatrixA_, MatrixB_, MatrixD_>, Filter_>>
2072 (matrix, filter, type, omega, num_iter);
2073 }
2074 } // namespace Solver
2075} // namespace FEAT
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Definition: assertion.hpp:263
Saddle-Point matrix meta class template.
MatrixTypeA::DataType DataType
data type
MatrixTypeA & block_a()
Returns the sub-matrix block A.
VectorTypeR create_vector_r() const
Returns a new compatible R-Vector.
void apply(VectorTypeL &r, const VectorTypeR &x) const
Applies this matrix onto a vector.
MatrixTypeA::IndexType IndexType
index type
MatrixTypeB & block_b()
Returns the sub-matrix block B.
MatrixTypeD & block_d()
Returns the sub-matrix block D.
Variadic TupleVector class template.
std::size_t bytes() const
Returns the total amount of bytes allocated.
void copy(const TupleVector &x, bool full=false)
Performs .
void clear()
Free all allocated arrays.
void format()
Reset all elements of the container to a given value or zero if missing.
Typed memory view class.
Polymorphic solver interface.
Definition: base.hpp:183
Base-class for solver generated exceptions.
Definition: base.hpp:127
virtual void init_numeric() override
Performs numeric factorization.
Definition: vanka.hpp:1223
void _calc_scale()
Calculate the scaling vector for additive Vanka.
Definition: vanka.hpp:1514
double time_apply() const
Returns the total accumulated time for the solver application.
Definition: vanka.hpp:1307
virtual void done_symbolic() override
Releases the symbolic factorization data.
Definition: vanka.hpp:1208
void _factor_diag()
Performs the 'diagonal' numerical factorization.
Definition: vanka.hpp:1759
void _alloc_data()
Allocates the data arrays for numerical factorization.
Definition: vanka.hpp:1464
virtual void init_symbolic() override
Performs symbolic factorization.
Definition: vanka.hpp:1173
void _apply_full(VectorType &vec_cor, const VectorType &vec_def)
Applies the 'full' Vanka iteration.
Definition: vanka.hpp:1616
double time_init_numeric() const
Returns the total accumulated time for numeric initialization.
Definition: vanka.hpp:1299
virtual String name() const override
Returns the name of the solver.
Definition: vanka.hpp:1167
void reset_timings()
Resets the internal stop watches for time measurement.
Definition: vanka.hpp:1281
Vanka(const MatrixType &matrix, const FilterType &filter, VankaType type, DataType omega=DataType(1), Index num_iter=Index(1))
Constructor.
Definition: vanka.hpp:1156
void _apply_diag(VectorType &vec_cor, const VectorType &vec_def)
Applies the 'diagonal' Vanka iteration.
Definition: vanka.hpp:1864
double time_init_symbolic() const
Returns the total accumulated time for symbolic initialization.
Definition: vanka.hpp:1291
LAFEM::SaddlePointMatrix< MatrixA_, MatrixB_, MatrixD_ > MatrixType
our matrix type
Definition: vanka.hpp:1074
Vanka Factorization Error.
Definition: vanka.hpp:980
Vanka preconditioner/smoother class template.
Definition: vanka.hpp:994
static void add_flops(Index flops)
Add an amount of flops to the global flop counter.
Definition: statistics.hpp:206
Stop-Watch class.
Definition: stop_watch.hpp:21
double elapsed() const
Returns the total elapsed time in seconds.
Definition: stop_watch.hpp:70
void start()
Starts the stop-watch.
Definition: stop_watch.hpp:43
void reset()
Resets the elapsed time.
Definition: stop_watch.hpp:36
void stop()
Stops the stop-watch and increments elapsed time.
Definition: stop_watch.hpp:51
String class implementation.
Definition: string.hpp:47
Time stamp class.
Definition: time_stamp.hpp:54
double elapsed_now() const
Calculates the time elapsed between the time stamp and now.
Definition: time_stamp.hpp:121
bool isnormal(T_ x)
Checks whether a value is normal.
T_ sqr(T_ x)
Returns the square of a value.
Definition: math.hpp:95
DT_ invert_matrix(const IT_ n, const IT_ stride, DT_ a[], IT_ p[])
Inverts a matrix and returns its determinant.
Definition: math.hpp:1292
T_ max(T_ a, T_ b)
Returns the maximum of two values.
Definition: math.hpp:137
void memset_main(void *ptr, int value, std::size_t bytes)
Formats all bytes of a memory block in main memory to a given value.
VankaType
Vanka type enumeration.
Definition: vanka.hpp:952
@ nodal_full_mult
Nodal full Vanka type (multiplicative)
@ block_diag_add
Blocked diagonal Vanka type (additive)
@ nodal_full_add
Nodal full Vanka type (additive)
@ block_diag_mult
Blocked diagonal Vanka type (multiplicative)
@ nodal_diag_mult
Nodal diagonal Vanka type (multiplicative)
@ block_full_mult
Blocked full Vanka type (multiplicative)
@ nodal_diag_add
Nodal diagonal Vanka type (additive)
@ block_full_add
Blocked full Vanka type (additive)
Status
Solver status return codes enumeration.
Definition: base.hpp:47
@ success
solving successful (convergence criterion fulfilled)
@ iter
Plot every iteration (if applicable)
@ full
full Uzawa preconditioner
@ rest
restriction (multigrid)
std::shared_ptr< Vanka< LAFEM::SaddlePointMatrix< MatrixA_, MatrixB_, MatrixD_ >, Filter_ > > new_vanka(const LAFEM::SaddlePointMatrix< MatrixA_, MatrixB_, MatrixD_ > &matrix, const Filter_ &filter, VankaType type, typename MatrixA_::DataType omega=typename MatrixA_::DataType(1), Index num_iter=Index(1))
Creates a new Vanka solver object.
Definition: vanka.hpp:2064
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.