FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
ssor_precond.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
10#include <kernel/solver/base.hpp>
11
12namespace FEAT
13{
14 namespace Solver
15 {
16 namespace Intern
17 {
18 int cuda_ssor_forward_apply(int m, double * y, const double * x, const double * csrVal, const int * csrColInd, int ncolors, double omega,
19 int * colored_row_ptr, int * rows_per_color, int * inverse_row_ptr);
20 int cuda_ssor_backward_apply(int m, double * y, const double * x, const double * csrVal, const int * csrColInd, int ncolors, double omega,
21 int * colored_row_ptr, int * rows_per_color, int * inverse_row_ptr);
22 template <int BlockSize_>
23 int cuda_ssor_forward_bcsr_apply(int m, double * y, const double * x, const double * csrVal, const int * csrColInd, int ncolors, double omega,
24 int * colored_row_ptr, int * rows_per_color, int * inverse_row_ptr);
25 template <int BlockSize_>
26 int cuda_ssor_backward_bcsr_apply(int m, double * y, const double * x, const double * csrVal, const int * csrColInd, int ncolors, double omega,
27 int * colored_row_ptr, int * rows_per_color, int * inverse_row_ptr);
28 void cuda_sor_done_symbolic(int * colored_row_ptr, int * rows_per_color, int * inverse_row_ptr);
29 void cuda_sor_init_symbolic(int m, int nnz, const double * csrVal, const int * csrRowPtr, const int * csrColInd, int & ncolors,
30 int* & colored_row_ptr, int* & rows_per_color, int* & inverse_row_ptr);
31 }
32
47 template<typename Matrix_>
49 {
50 public:
51 typedef typename Matrix_::DataType DataType;
52 typedef typename Matrix_::VectorTypeL VectorType;
53
54 virtual void set_omega(DataType omega) = 0;
55
56 virtual void init_symbolic() = 0;
57
58 virtual void done_symbolic() = 0;
59
60 virtual String name() const = 0;
61
62 virtual Status apply(VectorType& vec_cor, const VectorType& vec_def) = 0;
63
64 virtual ~SSORPrecondBase() {}
65 }; // SSORPrecondBase class
66
67 template<PreferredBackend backend_, typename Matrix_, typename Filter_>
69
83 template<typename Filter_, typename DT_, typename IT_>
85 public SSORPrecondBase<typename LAFEM::SparseMatrixCSR<DT_, IT_>>
86 {
87 public:
89 typedef DT_ DataType;
90 typedef IT_ IndexType;
91 typedef Filter_ FilterType;
92 typedef typename MatrixType::VectorTypeL VectorType;
93
94 protected:
95 const MatrixType& _matrix;
96 const FilterType& _filter;
97 DataType _omega;
98
99 public:
113 explicit SSORPrecondWithBackend(const MatrixType& matrix, const FilterType& filter, const DataType omega = DataType(1)) :
114 _matrix(matrix),
115 _filter(filter),
116 _omega(omega)
117 {
118 if (_matrix.columns() != _matrix.rows())
119 {
120 XABORTM("Matrix is not square!");
121 }
122 }
123
124 explicit SSORPrecondWithBackend(const String& section_name, const PropertyMap* section,
125 const MatrixType& matrix, const FilterType& filter) :
126 _matrix(matrix),
127 _filter(filter),
128 _omega(1)
129 {
130 if (_matrix.columns() != _matrix.rows())
131 {
132 XABORTM("Matrix is not square!");
133 }
134
135 auto omega_p = section->query("omega");
136 if(omega_p.second && !omega_p.first.parse(this->_omega))
137 throw ParseError(section_name + ".omega", omega_p.first, "a positive float");
138 }
139
141 virtual String name() const override
142 {
143 return "SSOR";
144 }
145
153 virtual void set_omega(DataType omega) override
154 {
155 XASSERT(omega > DataType(0));
156 _omega = omega;
157 }
158
159 virtual void init_symbolic() override
160 {
161 }
162
163 virtual void done_symbolic() override
164 {
165 }
166
167 virtual Status apply(VectorType& vec_cor, const VectorType& vec_def) override
168 {
169 XASSERTM(_matrix.rows() == vec_cor.size(), "matrix / vector size mismatch!");
170 XASSERTM(_matrix.rows() == vec_def.size(), "matrix / vector size mismatch!");
171
172 TimeStamp ts_start;
173
174 // copy in-vector to out-vector
175 vec_cor.copy(vec_def);
176
177 _apply_intern(_matrix, vec_cor, vec_def);
178
179 vec_cor.scale(vec_cor, _omega * (DataType(2.0) - _omega));
180
181 this->_filter.filter_cor(vec_cor);
182
183 TimeStamp ts_stop;
184 Statistics::add_time_precon(ts_stop.elapsed(ts_start));
185 Statistics::add_flops(_matrix.used_elements() *2 + 6 * vec_cor.size());
186
187 return Status::success;
188 }
189
190 protected:
191 void _apply_intern(const LAFEM::SparseMatrixCSR<DataType, IndexType>& matrix, VectorType& vec_cor, const VectorType& vec_def)
192 {
193 // create pointers
194 DataType * pout(vec_cor.elements());
195 const DataType * pin(vec_def.elements());
196 const DataType * pval(matrix.val());
197 const IndexType * pcol_ind(matrix.col_ind());
198 const IndexType * prow_ptr(matrix.row_ptr());
199 const IndexType n((IndexType(matrix.rows())));
200
201 // __forward-insertion__
202 // iteration over all rows
203 for (Index i(0); i < n; ++i)
204 {
205 IndexType col;
206 DataType d(0);
207 // iteration over all elements on the left side of the main-diagonal
208 for (col = prow_ptr[i]; pcol_ind[col] < i; ++col)
209 {
210 d += pval[col] * pout[pcol_ind[col]];
211 }
212 pout[i] = (pin[i] - _omega * d) / pval[col];
213 }
214
215 // __backward-insertion__
216 // iteration over all rows
217 for (Index i(n); i > 0;)
218 {
219 --i;
220 IndexType col;
221 DataType d(0);
222 // iteration over all elements on the right side of the main-diagonal
223 for (col = prow_ptr[i+1] - IndexType(1); pcol_ind[col] > i; --col)
224 {
225 d += pval[col] * pout[pcol_ind[col]];
226 }
227 pout[i] -= _omega * d / pval[col];
228 }
229 }
230 }; // class SSORPrecondWithBackend<generic, SparseMatrixCSR>
231
232 template<typename Filter_, typename DT_, typename IT_, int BlockHeight_, int BlockWidth_>
233 class SSORPrecondWithBackend<PreferredBackend::generic, LAFEM::SparseMatrixBCSR<DT_, IT_, BlockHeight_, BlockWidth_>, Filter_> :
234 public SSORPrecondBase<typename LAFEM::SparseMatrixBCSR<DT_, IT_, BlockHeight_, BlockWidth_>>
235 {
236 static_assert(BlockHeight_ == BlockWidth_, "only square blocks are supported!");
237 public:
239 typedef Filter_ FilterType;
240 typedef typename MatrixType::VectorTypeL VectorType;
241 typedef typename MatrixType::DataType DataType;
242 typedef typename MatrixType::IndexType IndexType;
243
244 protected:
245 const MatrixType& _matrix;
246 const FilterType& _filter;
247 DataType _omega;
248
249 void _apply_intern(const MatrixType & matrix, VectorType& vec_cor, const VectorType& vec_def)
250 {
251 // create pointers
252 auto* pout(vec_cor.elements());
253 const auto* pin(vec_def.elements());
254 const auto* pval(matrix.val());
255 const IndexType * pcol_ind(matrix.col_ind());
256 const IndexType * prow_ptr(matrix.row_ptr());
257 const IndexType n((IndexType(matrix.rows())));
258 typename MatrixType::ValueType inverse;
259
260 // __forward-insertion__
261 // iteration over all rows
262 for (Index i(0); i < n; ++i)
263 {
264 IndexType col;
265 typename VectorType::ValueType d(0);
266 // iteration over all elements on the left side of the main-diagonal
267 for (col = prow_ptr[i]; pcol_ind[col] < i; ++col)
268 {
269 d += pval[col] * pout[pcol_ind[col]];
270 }
271 //pout[i] = (pin[i] - _omega * d) / pval[col];
272 inverse.set_inverse(pval[col]);
273 pout[i] = inverse * (pin[i] - _omega * d);
274 }
275
276 // __backward-insertion__
277 // iteration over all rows
278 for (Index i(n); i > 0;)
279 {
280 --i;
281 IndexType col;
282 typename VectorType::ValueType d(0);
283 // iteration over all elements on the right side of the main-diagonal
284 for (col = prow_ptr[i+1] - IndexType(1); pcol_ind[col] > i; --col)
285 {
286 d += pval[col] * pout[pcol_ind[col]];
287 }
288 //pout[i] -= _omega * d / pval[col];
289 inverse.set_inverse(pval[col]);
290 pout[i] = pout[i] - (_omega * inverse * d);
291 }
292 }
293
294 public:
308 explicit SSORPrecondWithBackend(const MatrixType& matrix, const FilterType& filter, const DataType omega = DataType(1)) :
309 _matrix(matrix),
310 _filter(filter),
311 _omega(omega)
312 {
313 if (_matrix.columns() != _matrix.rows())
314 {
315 XABORTM("Matrix is not square!");
316 }
317 }
318
319 explicit SSORPrecondWithBackend(const String& /*section_name*/, const PropertyMap* section,
320 const MatrixType& matrix, const FilterType& filter) :
321 _matrix(matrix),
322 _filter(filter),
323 _omega(1)
324 {
325 if (_matrix.columns() != _matrix.rows())
326 {
327 XABORTM("Matrix is not square!");
328 }
329
330 // Check if we have set _omega
331 auto omega_p = section->query("omega");
332 if(omega_p.second)
333 {
334 set_omega(DataType(std::stod(omega_p.first)));
335 }
336 }
337
339 virtual String name() const override
340 {
341 return "SSOR";
342 }
343
351 virtual void set_omega(DataType omega) override
352 {
353 XASSERT(omega > DataType(0));
354 _omega = omega;
355 }
356
357 virtual void init_symbolic() override
358 {
359 }
360
361 virtual void done_symbolic() override
362 {
363 }
364
365 virtual Status apply(VectorType& vec_cor, const VectorType& vec_def) override
366 {
367 XASSERTM(_matrix.rows() == vec_cor.size(), "matrix / vector size mismatch!");
368 XASSERTM(_matrix.rows() == vec_def.size(), "matrix / vector size mismatch!");
369
370 TimeStamp ts_start;
371
372 // copy in-vector to out-vector
373 vec_cor.copy(vec_def);
374
375 _apply_intern(_matrix, vec_cor, vec_def);
376
377 this->_filter.filter_cor(vec_cor);
378
379 TimeStamp ts_stop;
380 Statistics::add_time_precon(ts_stop.elapsed(ts_start));
381 Statistics::add_flops(_matrix.template used_elements<LAFEM::Perspective::pod>() * 2 + 6 * vec_cor.template size<LAFEM::Perspective::pod>());
382
383 return Status::success;
384 }
385 }; // class SSORPrecondWithBackend<generic, SparseMatrixBCSR>
386
387#ifdef FEAT_HAVE_CUDA
404 template<typename Filter_>
405 class SSORPrecondWithBackend<PreferredBackend::cuda, LAFEM::SparseMatrixCSR<double, unsigned int>, Filter_> :
406 public SSORPrecondBase<LAFEM::SparseMatrixCSR<double, unsigned int>>
407 {
408 public:
409 typedef LAFEM::SparseMatrixCSR<double, unsigned int> MatrixType;
410 typedef Filter_ FilterType;
411 typedef typename MatrixType::VectorTypeL VectorType;
412 typedef typename MatrixType::DataType DataType;
413
414 protected:
415 const MatrixType& _matrix;
416 const FilterType& _filter;
417 double _omega;
418 // row ptr permutation, sorted by color(each color sorted by amount of rows), start/end index per row
419 int * _colored_row_ptr;
420 // amount of rows per color (sorted by amount of rows)
421 int * _rows_per_color;
422 // mapping of idx to native row number
423 int * _inverse_row_ptr;
424 // number of colors
425 int _ncolors;
426
427 public:
441 explicit SSORPrecondWithBackend(const MatrixType& matrix, const FilterType& filter, const DataType omega = DataType(1)) :
442 _matrix(matrix),
443 _filter(filter),
444 _omega(omega),
445 _colored_row_ptr(nullptr),
446 _rows_per_color(nullptr),
447 _inverse_row_ptr(nullptr),
448 _ncolors(0)
449 {
450 if (_matrix.columns() != _matrix.rows())
451 {
452 XABORTM("Matrix is not square!");
453 }
454 }
455
456 explicit SSORPrecondWithBackend(const String& /*section_name*/, const PropertyMap* section,
457 const MatrixType& matrix, const FilterType& filter) :
458 _matrix(matrix),
459 _filter(filter),
460 _omega(1),
461 _colored_row_ptr(nullptr),
462 _rows_per_color(nullptr),
463 _inverse_row_ptr(nullptr),
464 _ncolors(0)
465 {
466 if (_matrix.columns() != _matrix.rows())
467 {
468 XABORTM("Matrix is not square!");
469 }
470
471 // Check if we have set _omega
472 auto omega_p = section->query("omega");
473 if(omega_p.second)
474 {
475 set_omega(DataType(std::stod(omega_p.first)));
476 }
477 }
478
480 virtual String name() const override
481 {
482 return "SSOR";
483 }
484
492 virtual void set_omega(DataType omega) override
493 {
494 XASSERT(omega > DataType(0));
495 _omega = omega;
496 }
497
498 virtual void init_symbolic() override
499 {
500 Intern::cuda_sor_init_symbolic((int)_matrix.rows(), (int)_matrix.used_elements(), _matrix.val(), (const int*)_matrix.row_ptr(), (const int*)_matrix.col_ind(), _ncolors,
501 _colored_row_ptr, _rows_per_color, _inverse_row_ptr);
502 }
503
504 virtual void done_symbolic() override
505 {
506 Intern::cuda_sor_done_symbolic(_colored_row_ptr, _rows_per_color, _inverse_row_ptr);
507 }
508
509 virtual Status apply(VectorType& vec_cor, const VectorType& vec_def) override
510 {
511 XASSERTM(_matrix.rows() == vec_cor.size(), "matrix / vector size mismatch!");
512 XASSERTM(_matrix.rows() == vec_def.size(), "matrix / vector size mismatch!");
513
514 TimeStamp ts_start;
515
516 int status = Intern::cuda_ssor_forward_apply((int)vec_cor.size(), vec_cor.elements(), vec_def.elements(), (const double*)_matrix.val(), (const int*)_matrix.col_ind(), _ncolors, _omega, _colored_row_ptr, _rows_per_color, _inverse_row_ptr);
517 status |= Intern::cuda_ssor_backward_apply((int)vec_cor.size(), vec_cor.elements(), vec_def.elements(), (const double*)_matrix.val(), (const int*)_matrix.col_ind(), _ncolors, _omega, _colored_row_ptr, _rows_per_color, _inverse_row_ptr);
518
519 vec_cor.scale(vec_cor, _omega * (2.0 - _omega));
520
521 this->_filter.filter_cor(vec_cor);
522
523 TimeStamp ts_stop;
524 Statistics::add_time_precon(ts_stop.elapsed(ts_start));
525 Statistics::add_flops(_matrix.used_elements() *2 + 6 * vec_cor.size());
526
527 return (status == 0) ? Status::success : Status::aborted;
528 }
529 }; // class SSORPrecondWithBackend<cuda, SparseMatrixCSR>
530
531 template<typename Filter_, int BlockHeight_, int BlockWidth_>
532 class SSORPrecondWithBackend<PreferredBackend::cuda, LAFEM::SparseMatrixBCSR<double, unsigned int, BlockHeight_, BlockWidth_>, Filter_> :
533 public SSORPrecondBase<typename LAFEM::SparseMatrixBCSR<double, unsigned int, BlockHeight_, BlockWidth_>>
534 {
535 static_assert(BlockHeight_ == BlockWidth_, "only square blocks are supported!");
536 public:
537 typedef LAFEM::SparseMatrixBCSR<double, unsigned int, BlockHeight_, BlockWidth_> MatrixType;
538 typedef Filter_ FilterType;
539 typedef typename MatrixType::VectorTypeL VectorType;
540 typedef typename MatrixType::DataType DataType;
541
542 protected:
543 const MatrixType& _matrix;
544 const FilterType& _filter;
545 double _omega;
546 // row ptr permutation, sorted by color(each color sorted by amount of rows), start/end index per row
547 int * _colored_row_ptr;
548 // amount of rows per color (sorted by amount of rows)
549 int * _rows_per_color;
550 // mapping of idx to native row number
551 int * _inverse_row_ptr;
552 // number of colors
553 int _ncolors;
554
555 public:
569 explicit SSORPrecondWithBackend(const MatrixType& matrix, const FilterType& filter, const DataType omega = DataType(1)) :
570 _matrix(matrix),
571 _filter(filter),
572 _omega(omega),
573 _colored_row_ptr(nullptr),
574 _rows_per_color(nullptr),
575 _inverse_row_ptr(nullptr),
576 _ncolors(0)
577 {
578 if (_matrix.columns() != _matrix.rows())
579 {
580 XABORTM("Matrix is not square!");
581 }
582 }
583
584 explicit SSORPrecondWithBackend(const String& /*section_name*/, const PropertyMap* section,
585 const MatrixType& matrix, const FilterType& filter) :
586 _matrix(matrix),
587 _filter(filter),
588 _omega(1),
589 _colored_row_ptr(nullptr),
590 _rows_per_color(nullptr),
591 _inverse_row_ptr(nullptr),
592 _ncolors(0)
593 {
594 if (_matrix.columns() != _matrix.rows())
595 {
596 XABORTM("Matrix is not square!");
597 }
598
599 // Check if we have set _omega
600 auto omega_p = section->query("omega");
601 if(omega_p.second)
602 {
603 set_omega(DataType(std::stod(omega_p.first)));
604 }
605 }
606
608 virtual String name() const override
609 {
610 return "SSOR";
611 }
612
620 virtual void set_omega(DataType omega) override
621 {
622 XASSERT(omega > DataType(0));
623 _omega = omega;
624 }
625
626 virtual void init_symbolic() override
627 {
628 Intern::cuda_sor_init_symbolic((int)_matrix.rows(), (int)_matrix.used_elements(), _matrix.template val<LAFEM::Perspective::pod>(), (const int*)_matrix.row_ptr(), (const int*)_matrix.col_ind(), _ncolors,
629 _colored_row_ptr, _rows_per_color, _inverse_row_ptr);
630 }
631
632 virtual void done_symbolic() override
633 {
634 Intern::cuda_sor_done_symbolic(_colored_row_ptr, _rows_per_color, _inverse_row_ptr);
635 }
636
637 virtual Status apply(VectorType& vec_cor, const VectorType& vec_def) override
638 {
639 XASSERTM(_matrix.rows() == vec_cor.size(), "matrix / vector size mismatch!");
640 XASSERTM(_matrix.rows() == vec_def.size(), "matrix / vector size mismatch!");
641
642 TimeStamp ts_start;
643
644 int status = Intern::cuda_ssor_forward_bcsr_apply<BlockHeight_>((int)vec_cor.size(), vec_cor. template elements<LAFEM::Perspective::pod>(), vec_def.template elements<LAFEM::Perspective::pod>(), _matrix.template val<LAFEM::Perspective::pod>(), (const int*)_matrix.col_ind(), _ncolors, _omega, _colored_row_ptr, _rows_per_color, _inverse_row_ptr);
645 status |= Intern::cuda_ssor_backward_bcsr_apply<BlockHeight_>((int)vec_cor.size(), vec_cor.template elements<LAFEM::Perspective::pod>(), vec_def.template elements<LAFEM::Perspective::pod>(), _matrix.template val<LAFEM::Perspective::pod>(), (const int*)_matrix.col_ind(), _ncolors, _omega, _colored_row_ptr, _rows_per_color, _inverse_row_ptr);
646
647 vec_cor.scale(vec_cor, _omega * (2.0 - _omega));
648
649 this->_filter.filter_cor(vec_cor);
650
651 TimeStamp ts_stop;
652 Statistics::add_time_precon(ts_stop.elapsed(ts_start));
653 Statistics::add_flops(_matrix.template used_elements<LAFEM::Perspective::pod>() *2 + 6 * vec_cor.template size<LAFEM::Perspective::pod>());
654
655 return (status == 0) ? Status::success : Status::aborted;
656 }
657 }; // class SSORPrecondWithBackend<cuda, SparseMatrixBCSR>
658#endif //FEAT_HAVE_CUDA
659
661 template<PreferredBackend backend_, typename Matrix_, typename Filter_>
663 public SSORPrecondBase<Matrix_>
664 {
665 public:
666 template<typename DT_>
667 explicit SSORPrecondWithBackend(const Matrix_&, const Filter_&, const DT_)
668 {
669 }
670
671 explicit SSORPrecondWithBackend(const Matrix_&, const Filter_&)
672 {
673 }
674
675 explicit SSORPrecondWithBackend(const String&, const PropertyMap*, const Matrix_&, const Filter_&)
676 {
677 }
678
679 virtual Status apply(typename Matrix_::VectorTypeL &, const typename Matrix_::VectorTypeL &) override
680 {
681 XABORTM("not implemented yet!");
682 }
683
684 virtual String name() const override
685 {
686 XABORTM("not implemented yet!");
687 }
688
689 virtual void init_symbolic() override
690 {
691 XABORTM("not implemented yet!");
692 }
693
694 virtual void done_symbolic() override
695 {
696 XABORTM("not implemented yet!");
697 }
698
699 virtual void set_omega(typename Matrix_::DataType /*omega*/) override
700 {
701 XABORTM("not implemented yet!");
702 }
703 };
704
717 template<typename Matrix_, typename Filter_>
718 class SSORPrecond : public SolverBase<typename Matrix_::VectorTypeL>
719 {
720 private:
721 std::shared_ptr<SSORPrecondBase<Matrix_>> _impl;
722
723 public:
724 typedef Matrix_ MatrixType;
725 typedef Filter_ FilterType;
726 typedef typename MatrixType::VectorTypeL VectorType;
727 typedef typename MatrixType::DataType DataType;
728
731
732 public:
749 SSORPrecond(const PreferredBackend backend, const MatrixType& matrix, const FilterType& filter, DataType omega = DataType(1))
750 {
751 switch (backend)
752 {
754 _impl = std::make_shared<SSORPrecondWithBackend<PreferredBackend::cuda, Matrix_, Filter_>>(matrix, filter, omega);
755 break;
758 default:
759 _impl = std::make_shared<SSORPrecondWithBackend<PreferredBackend::generic, Matrix_, Filter_>>(matrix, filter, omega);
760 }
761 }
762
782 SSORPrecond(const PreferredBackend backend, const String& section_name, const PropertyMap* section, const MatrixType& matrix, const FilterType& filter, DataType omega = DataType(1)) :
783 BaseClass(section_name, section)
784 {
785 switch (backend)
786 {
788 _impl = std::make_shared<SSORPrecondWithBackend<PreferredBackend::cuda, Matrix_, Filter_>>(section_name, section, matrix, filter, omega);
789 break;
792 default:
793 _impl = std::make_shared<SSORPrecondWithBackend<PreferredBackend::generic, Matrix_, Filter_>>(section_name, section, matrix, filter, omega);
794 }
795 }
796
800 virtual ~SSORPrecond()
801 {
802 }
803
805 virtual String name() const override
806 {
807 return _impl->name();
808 }
809
817 virtual void set_omega(DataType omega)
818 {
819 _impl->set_omega(omega);
820 }
821
822 virtual Status apply(VectorType& vec_cor, const VectorType& vec_def) override
823 {
824 return _impl->apply(vec_cor, vec_def);
825 }
826
827 virtual void init_symbolic() override
828 {
829 _impl->init_symbolic();
830 }
831
832 virtual void done_symbolic() override
833 {
834 _impl->done_symbolic();
835 }
836 }; // class SSORPrecond
837
856 template<typename Matrix_, typename Filter_>
857 inline std::shared_ptr<SSORPrecond<Matrix_, Filter_>> new_ssor_precond(
858 const PreferredBackend backend, const Matrix_& matrix, const Filter_& filter,
859 const typename Matrix_::DataType omega = typename Matrix_::DataType(1))
860 {
861 return std::make_shared<SSORPrecond<Matrix_, Filter_>>
862 (backend, matrix, filter, omega);
863 }
864
886 template<typename Matrix_, typename Filter_>
887 inline std::shared_ptr<SSORPrecond<Matrix_, Filter_>> new_ssor_precond(
888 const String& section_name, const PropertyMap* section, PreferredBackend backend,
889 const Matrix_& matrix, const Filter_& filter)
890 {
891 return std::make_shared<SSORPrecond<Matrix_, Filter_>>
892 (backend, section_name, section, matrix, filter);
893 }
894 } // namespace Solver
895} // namespace FEAT
#define XABORTM(msg)
Abortion macro definition with custom message.
Definition: assertion.hpp:192
#define XASSERT(expr)
Assertion macro definition.
Definition: assertion.hpp:262
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Definition: assertion.hpp:263
FEAT Kernel base header.
CSR based blocked sparse matrix.
Intern::BCSRVectorHelper< DT_, IT_, BlockHeight_ >::VectorType VectorTypeL
Compatible L-vector type.
Index rows() const
Retrieve matrix row count.
IT_ * col_ind()
Retrieve column indices array.
IT_ * row_ptr()
Retrieve row start index array.
Index columns() const
Retrieve matrix column count.
auto val() const -> const typename Intern::BCSRPerspectiveHelper< DT_, BlockHeight_, BlockWidth_, perspective_ >::Type *
Retrieve non zero element array.
CSR based sparse matrix.
Index rows() const
Retrieve matrix row count.
Index columns() const
Retrieve matrix column count.
Index used_elements() const
Retrieve non zero element count.
Class for parser related errors.
Definition: exception.hpp:132
A class organizing a tree of key-value pairs.
std::pair< String, bool > query(String key_path) const
Queries a value by its key path.
Inheritances inside sor_precond.hpp.
SSOR preconditioner implementation.
virtual void done_symbolic() override
Symbolic finalization method.
SSORPrecond(const PreferredBackend backend, const MatrixType &matrix, const FilterType &filter, DataType omega=DataType(1))
Constructor.
SSORPrecond(const PreferredBackend backend, const String &section_name, const PropertyMap *section, const MatrixType &matrix, const FilterType &filter, DataType omega=DataType(1))
Constructor using a PropertyMap.
virtual ~SSORPrecond()
Empty virtual destructor.
virtual void init_symbolic() override
Symbolic initialization method.
virtual void set_omega(DataType omega)
Sets the damping parameter.
virtual String name() const override
Returns the name of the solver.
SolverBase< VectorType > BaseClass
Our base class.
SSORPrecondWithBackend(const MatrixType &matrix, const FilterType &filter, const DataType omega=DataType(1))
Constructor.
SSORPrecondWithBackend(const MatrixType &matrix, const FilterType &filter, const DataType omega=DataType(1))
Constructor.
Dummy class for not implemented specializations.
Polymorphic solver interface.
Definition: base.hpp:183
static void add_flops(Index flops)
Add an amount of flops to the global flop counter.
Definition: statistics.hpp:206
String class implementation.
Definition: string.hpp:46
Tiny Matrix class template.
CUDA_HOST_DEVICE Matrix & set_inverse(const Matrix< T_, m_, n_, sma_, sna_ > &a)
Sets this matrix to the inverse of another matrix.
std::shared_ptr< SSORPrecond< Matrix_, Filter_ > > new_ssor_precond(const PreferredBackend backend, const Matrix_ &matrix, const Filter_ &filter, const typename Matrix_::DataType omega=typename Matrix_::DataType(1))
Creates a new SSORPrecond solver object.
Status
Solver status return codes enumeration.
Definition: base.hpp:47
@ success
solving successful (convergence criterion fulfilled)
@ aborted
premature abort (solver aborted due to internal errors or preconditioner failure)
FEAT namespace.
Definition: adjactor.hpp:12
PreferredBackend
The backend that shall be used in all compute heavy calculations.
Definition: backend.hpp:124
std::uint64_t Index
Index data type.