FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
matrix_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
9#include <kernel/solver/base.hpp>
10
11namespace FEAT
12{
13 namespace Solver
14 {
22 template<typename Matrix_, typename Filter_>
24 public SolverBase<typename Matrix_::VectorTypeL>
25 {
26 public:
27 typedef Matrix_ MatrixType;
28 typedef Filter_ FilterType;
29 typedef typename MatrixType::VectorTypeL VectorType;
30 typedef typename MatrixType::DataType DataType;
32
33 protected:
34 const MatrixType& _matrix;
35 const FilterType& _filter;
36
37 public:
47 explicit MatrixPrecond(const MatrixType& matrix, const FilterType& filter) :
48 _matrix(matrix),
49 _filter(filter)
50 {
51 }
52
68 explicit MatrixPrecond(const String& section_name, const PropertyMap* section,
69 const MatrixType& matrix, const FilterType& filter) :
70 BaseClass(section_name, section),
71 _matrix(matrix),
72 _filter(filter)
73 {
74 }
75
77 virtual String name() const override
78 {
79 return "MatrixPrecond";
80 }
81
82 virtual void init_symbolic() override
83 {
84 }
85
86 virtual void done_symbolic() override
87 {
88 }
89
90 virtual void init_numeric() override
91 {
92 }
93
94 virtual Status apply(VectorType& vec_cor, const VectorType& vec_def) override
95 {
96 _matrix.apply(vec_cor, vec_def);
97 this->_filter.filter_cor(vec_cor);
98 return Status::success;
99 }
100 }; // class MatrixPrecond<...>
101
114 template<typename Matrix_, typename Filter_>
115 inline std::shared_ptr<MatrixPrecond<Matrix_, Filter_>> new_matrix_precond(
116 const Matrix_& matrix, const Filter_& filter)
117 {
118 return std::make_shared<MatrixPrecond<Matrix_, Filter_>>(matrix, filter);
119 }
120
139 template<typename Matrix_, typename Filter_>
140 inline std::shared_ptr<MatrixPrecond<Matrix_, Filter_>> new_matrix_precond(
141 const String& section_name, const PropertyMap* section,
142 const Matrix_& matrix, const Filter_& filter)
143 {
144 return std::make_shared<MatrixPrecond<Matrix_, Filter_>>(section_name, section, matrix, filter);
145 }
146 } // namespace Solver
147} // namespace FEAT
A class organizing a tree of key-value pairs.
Matrix preconditioner implementation.
MatrixPrecond(const String &section_name, const PropertyMap *section, const MatrixType &matrix, const FilterType &filter)
Constructor.
MatrixPrecond(const MatrixType &matrix, const FilterType &filter)
Constructor.
virtual void init_numeric() override
Numeric initialization method.
virtual void init_symbolic() override
Symbolic initialization method.
virtual String name() const override
Returns the name of the solver.
virtual void done_symbolic() override
Symbolic finalization method.
Polymorphic solver interface.
Definition: base.hpp:183
String class implementation.
Definition: string.hpp:46
std::shared_ptr< MatrixPrecond< Matrix_, Filter_ > > new_matrix_precond(const Matrix_ &matrix, const Filter_ &filter)
Creates a new MatrixPrecond solver object.
Status
Solver status return codes enumeration.
Definition: base.hpp:47
@ success
solving successful (convergence criterion fulfilled)
FEAT namespace.
Definition: adjactor.hpp:12