DUNE-FEM (unstable)

preconditionedinverseoperator.hh
1#ifndef DUNE_FEM_SOLVER_PRECONDITIONEDINVERSEOPERATOR_HH
2#define DUNE_FEM_SOLVER_PRECONDITIONEDINVERSEOPERATOR_HH
3
4#include <limits>
5#include <memory>
6
7#include <dune/fem/operator/common/operator.hh>
8
9namespace Dune
10{
11
12 namespace Fem
13 {
14
15 // PreconditionedInverseOperator
16 // -----------------------------
17
18 template< class Preconditioner, class InverseOperator >
19 class PreconditionedInverseOperator
20 : public Operator< typename Preconditioner::RangeFunctionType >
21 {
22 typedef PreconditionedInverseOperator< Preconditioner, InverseOperator > ThisType;
23 typedef Operator< typename Preconditioner::RangeFunctionType > BaseType;
24
25 public:
26 typedef typename BaseType::DomainFunctionType DomainFunctionType;
27 typedef typename BaseType::DomainFunctionType RangeFunctionType;
28
29 typedef typename InverseOperator::OperatorType OperatorType;
30
31 PreconditionedInverseOperator ( double redEps, double absLimit, unsigned int maxIterations, bool verbose )
32 : inverseOperator_( redEps, absLimit, maxIterations, verbose )
33 {}
34
35 PreconditionedInverseOperator ( double redEps, double absLimit,
36 unsigned int maxIterations = std::numeric_limits< unsigned int >::max() )
37 : inverseOperator_( redEps, absLimit, maxIterations )
38 {}
39
40 PreconditionedInverseOperator ( const OperatorType &op, double redEps, double absLimit,
41 unsigned int maxIterations, bool verbose )
42 : inverseOperator_( redEps, absLimit, maxIterations, verbose )
43 {
44 bind( op );
45 }
46
47 PreconditionedInverseOperator ( const OperatorType &op, double redEps, double absLimit,
48 unsigned int maxIterations = std::numeric_limits< unsigned int >::max() )
49 : inverseOperator_( redEps, absLimit, maxIterations )
50 {
51 bind( op );
52 }
53
54 void bind ( const OperatorType &op )
55 {
56 preconditioner_.reset( new Preconditioner( op ) );
57 asssert( preconditioner_ );
58 inverseOperator_.bind( op, *preconditioner_ );
59 }
60 void unbind() { inverseOperator_.unbind(); preconditioner_.reset(); }
61
62 void operator() ( const DomainFunctionType &u, RangeFunctionType &w ) const
63 {
64 assert( preconditioner_ );
65 inverseOperator_( u, w );
66 }
67
68 unsigned int iterations () const { return inverseOperator_.iterations(); }
69 void setMaxIterations ( unsigned int maxIterations ) const { inverseOperator_.setMaxIterations( maxIterations ); }
70
71 private:
72 InverseOperator inverseOperator_;
73 std::unique_ptr< Preconditioner > preconditioner_;
74 };
75
76 } // namespace Fem
77
78} // namespace Dune
79
80#endif // #ifndef DUNE_FEM_SOLVER_PRECONDITIONEDINVERSEOPERATOR_HH
constexpr auto max
Function object that returns the greater of the given values.
Definition: hybridutilities.hh:484
Dune namespace.
Definition: alignedallocator.hh:13
DomainFunction DomainFunctionType
type of discrete function in the operator's domain
Definition: operator.hh:36
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)