Dune Core Modules (2.6.0)

operators.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_ISTL_OPERATORS_HH
4#define DUNE_ISTL_OPERATORS_HH
5
6#include <cmath>
7#include <complex>
8#include <iostream>
9#include <iomanip>
10#include <string>
11
13
14#include "solvercategory.hh"
15
16
17namespace Dune {
18
41 //=====================================================================
42 // Abstract operator interface
43 //=====================================================================
44
45
63 template<class X, class Y>
65 public:
67 typedef X domain_type;
69 typedef Y range_type;
71 typedef typename X::field_type field_type;
72
77 virtual void apply (const X& x, Y& y) const = 0;
78
80 virtual void applyscaleadd (field_type alpha, const X& x, Y& y) const = 0;
81
83 virtual ~LinearOperator () {}
84
87#if DUNE_ISTL_SUPPORT_OLD_CATEGORY_INTERFACE
88 {
89 DUNE_THROW(Dune::Exception,"It is necessary to implement the category method in a derived classes, in the future this method will pure virtual.");
90 };
91#else
92 = 0;
93#endif
94 };
95
96
105 template<class M, class X, class Y>
107 public:
109 typedef M matrix_type;
110 typedef X domain_type;
111 typedef Y range_type;
112 typedef typename X::field_type field_type;
113
115 virtual const M& getmat () const = 0;
116
119 };
120
121
122
123 //=====================================================================
124 // Implementation for ISTL-matrix based operator
125 //=====================================================================
126
132 template<class M, class X, class Y>
134 {
135 public:
137 typedef M matrix_type;
138 typedef X domain_type;
139 typedef Y range_type;
140 typedef typename X::field_type field_type;
141
143 explicit MatrixAdapter (const M& A) : _A_(A) {}
144
146 virtual void apply (const X& x, Y& y) const
147 {
148 _A_.mv(x,y);
149 }
150
152 virtual void applyscaleadd (field_type alpha, const X& x, Y& y) const
153 {
154 _A_.usmv(alpha,x,y);
155 }
156
158 virtual const M& getmat () const
159 {
160 return _A_;
161 }
162
165 {
167 }
168
169 private:
170 const M& _A_;
171 };
172
175} // end namespace
176
177#endif
A linear operator exporting itself in matrix form.
Definition: operators.hh:106
virtual const M & getmat() const =0
get matrix via *
M matrix_type
export types, usually they come from the derived class
Definition: operators.hh:109
virtual ~AssembledLinearOperator()
every abstract base class has a virtual destructor
Definition: operators.hh:118
Base class for Dune-Exceptions.
Definition: exceptions.hh:94
A linear operator.
Definition: operators.hh:64
virtual ~LinearOperator()
every abstract base class has a virtual destructor
Definition: operators.hh:83
X::field_type field_type
The field type of the operator.
Definition: operators.hh:71
virtual void applyscaleadd(field_type alpha, const X &x, Y &y) const =0
apply operator to x, scale and add:
virtual SolverCategory::Category category() const =0
Category of the linear operator (see SolverCategory::Category)
Y range_type
The type of the range of the operator.
Definition: operators.hh:69
virtual void apply(const X &x, Y &y) const =0
apply operator to x: The input vector is consistent and the output must also be consistent on the in...
X domain_type
The type of the domain of the operator.
Definition: operators.hh:67
Adapter to turn a matrix into a linear operator.
Definition: operators.hh:134
virtual const M & getmat() const
get matrix via *
Definition: operators.hh:158
virtual void applyscaleadd(field_type alpha, const X &x, Y &y) const
apply operator to x, scale and add:
Definition: operators.hh:152
MatrixAdapter(const M &A)
constructor: just store a reference to a matrix
Definition: operators.hh:143
virtual SolverCategory::Category category() const
Category of the solver (see SolverCategory::Category)
Definition: operators.hh:164
virtual void apply(const X &x, Y &y) const
apply operator to x:
Definition: operators.hh:146
M matrix_type
export types
Definition: operators.hh:137
A few common exception classes.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
Dune namespace.
Definition: alignedallocator.hh:10
Category
Definition: solvercategory.hh:21
@ sequential
Category for sequential solvers.
Definition: solvercategory.hh:23
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 26, 23:30, 2024)