FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
diagonal_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 Vector_, typename Filter_>
24 public SolverBase<Vector_>
25 {
26 public:
28 typedef Vector_ VectorType;
29 typedef Filter_ FilterType;
30
31 protected:
32 const VectorType& _diag;
33 const FilterType& _filter;
34
35 public:
45 explicit DiagonalPrecond(const VectorType& diag, const FilterType& filter) :
46 _diag(diag),
47 _filter(filter)
48 {
49 }
50
51 explicit DiagonalPrecond(const String& section_name, const PropertyMap* section,
52 const VectorType& diag, const FilterType& filter) :
53 BaseClass(section_name, section),
54 _diag(diag),
55 _filter(filter)
56 {
57 }
58
60 virtual String name() const override
61 {
62 return "Diagonal";
63 }
64
65 virtual Status apply(VectorType& vec_cor, const VectorType& vec_def) override
66 {
67 vec_cor.component_product(_diag, vec_def);
68 this->_filter.filter_cor(vec_cor);
69 return Status::success;
70 }
71 }; // class DiagonalPrecond<...>
72
85 template<typename Vector_, typename Filter_>
86 inline std::shared_ptr<DiagonalPrecond<Vector_, Filter_>> new_diagonal_precond(
87 const Vector_& diag, const Filter_& filter)
88 {
89 return std::make_shared<DiagonalPrecond<Vector_, Filter_>>(diag, filter);
90 }
91
110 template<typename Vector_, typename Filter_>
111 inline std::shared_ptr<DiagonalPrecond<Vector_, Filter_>> new_diagonal_precond(
112 const String& section_name, const PropertyMap* section,
113 const Vector_& diag, const Filter_& filter)
114 {
115 return std::make_shared<DiagonalPrecond<Vector_, Filter_>>(section_name, section, diag, filter);
116 }
117 } // namespace Solver
118} // namespace FEAT
A class organizing a tree of key-value pairs.
Diagonal preconditioner implementation.
virtual String name() const override
Returns the name of the solver.
virtual Status apply(VectorType &vec_cor, const VectorType &vec_def) override
Solver application method.
DiagonalPrecond(const VectorType &diag, const FilterType &filter)
Constructor.
Polymorphic solver interface.
Definition: base.hpp:183
String class implementation.
Definition: string.hpp:47
std::shared_ptr< DiagonalPrecond< Vector_, Filter_ > > new_diagonal_precond(const Vector_ &diag, const Filter_ &filter)
Creates a new DiagonalPrecond solver object.
Status
Solver status return codes enumeration.
Definition: base.hpp:47
@ success
solving successful (convergence criterion fulfilled)
FEAT namespace.
Definition: adjactor.hpp:12