dune-fem 2.8.0
Loading...
Searching...
No Matches
operator.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_OPERATOR_HH
2#define DUNE_FEM_OPERATOR_HH
3
4#include <cassert>
5#include <typeindex>
6#include <cassert>
7
8#include <dune/common/exceptions.hh>
9
10#include <dune/fem/version.hh>
11#include <dune/common/exceptions.hh>
13
14namespace Dune
15{
16
17 namespace Fem
18 {
19
32 template< class DomainFunction, class RangeFunction = DomainFunction >
33 struct Operator
34 {
36 typedef DomainFunction DomainFunctionType;
38 typedef RangeFunction RangeFunctionType;
39
41 typedef typename DomainFunction::RangeFieldType DomainFieldType;
43 typedef typename RangeFunction::RangeFieldType RangeFieldType;
44
45 virtual ~Operator ()
46 {}
47
55 virtual void operator() ( const DomainFunctionType &u, RangeFunctionType &w ) const = 0;
56
61 virtual void finalize () {}
62 };
63
84 template< class DomainFunction, class RangeFunction = DomainFunction >
86 : public virtual Operator<DomainFunction, RangeFunction>
87 {
89 virtual bool symmetric() const
90 {
91 return false;
92 }
94 virtual bool positiveDefinite() const
95 {
96 return false;
97 }
98 };
99
121 template< class DomainFunction, class RangeFunction = DomainFunction >
123 : public virtual LinearOperator<DomainFunction, RangeFunction>
124 {
125 public:
127 virtual void flushAssembly() {}
128
132 template< class AssembleOperation >
134 {
135 const std::type_index id( typeid( AssembleOperation ) );
136 if( assembleOperation_ != id )
137 {
138 if( assembleOperation_ != std::type_index( typeid( void ) ) )
139 DUNE_THROW( InvalidStateException, "Another assemble operation in progress" );
141 assert( assembleCount_ == 0 );
142 AssembleOperation::begin( *this );
143 }
145 }
146
150 template< class AssembleOperation >
152 {
153 const std::type_index id( typeid( AssembleOperation ) );
154 if( assembleOperation_ != id )
155 DUNE_THROW( InvalidStateException, "Assemble operation not in progress" );
156 assert( assembleCount_ > 0 );
157 if( --assembleCount_ == 0 )
158 {
159 AssembleOperation::end( *this );
160 assembleOperation_ = std::type_index( typeid( void ) );
161 }
162 }
163
164 protected:
165 std::type_index assembleOperation_ = std::type_index( typeid( void ) );
166 std::size_t assembleCount_ = 0;
167 };
168
169
170 // Is*Operator
171 // -----------
172
173 namespace Impl
174 {
175
176 template< class T >
177 using DomainFunctionType_t = typename T::DomainFunctionType;
178
179 template< class T >
180 using RangeFunctionType_t = typename T::RangeFunctionType;
181
182 template< class T >
183 using IsOperatorImpl = std::is_base_of< ::Dune::Fem::Operator< DomainFunctionType_t< T >, RangeFunctionType_t< T > >, T >;
184
185 template< class T >
186 using IsLinearOperatorImpl = std::is_base_of< ::Dune::Fem::LinearOperator< DomainFunctionType_t< T >, RangeFunctionType_t< T > >, T >;
187
188 template< class T >
189 using IsAssembledOperatorImpl = std::is_base_of< ::Dune::Fem::AssembledOperator< DomainFunctionType_t< T >, RangeFunctionType_t< T > >, T >;
190
191 } // namespace Impl
192
193 template< class T >
194 using IsOperator = Impl::IsOperatorImpl< std::decay_t< T > >;
195
196 template< class T >
197 using IsLinearOperator = Impl::IsOperatorImpl< std::decay_t< T > >;
198
199 template< class T >
200 using IsAssembledOperator = Impl::IsAssembledOperatorImpl< std::decay_t< T > >;
201
202 } // namespace Fem
203
204
205
224 template <typename DFieldType, typename RFieldType,
225 typename DType , typename RType>
227 : public Fem::Mapping < DFieldType, RFieldType, DType, RType >,
228 public virtual Fem::Operator< DType, RType >
229 {
231
232 protected:
234 typedef Fem::Mapping <DFieldType,RFieldType,DType,RType> MappingType;
235
236 public:
237 //- remember template parameters for derived classes
238 typedef DType DomainType;
239 typedef RType RangeType;
240 typedef DFieldType DomainFieldType;
241 typedef RFieldType RangeFieldType;
242
243 using BaseType::operator();
244 using BaseType::finalize;
245
246 protected:
253 virtual void apply (const DomainType& arg, RangeType& dest) const
254 {
255 this->operator() (arg, dest);
256 }
257 }; // class Operator
258
260
261} // namespace Dune
262
263#endif // #ifndef DUNE_FEM_OPERATOR_HH
Definition: bindguard.hh:11
Impl::IsOperatorImpl< std::decay_t< T > > IsLinearOperator
Definition: operator.hh:197
Impl::IsOperatorImpl< std::decay_t< T > > IsOperator
Definition: operator.hh:194
Impl::IsAssembledOperatorImpl< std::decay_t< T > > IsAssembledOperator
Definition: operator.hh:200
A mapping from one vector space into another This class describes a general mapping from the domain v...
Definition: mapping.hh:47
void operator()(const DomainType &arg, RangeType &dest) const
Application operator that applies all operators in the linear combination stack.
Definition: mapping.hh:112
abstract operator
Definition: operator.hh:34
virtual void finalize()
finalization of operator
Definition: operator.hh:61
DomainFunction DomainFunctionType
type of discrete function in the operator's domain
Definition: operator.hh:36
RangeFunction::RangeFieldType RangeFieldType
field type of the operator's range
Definition: operator.hh:43
virtual void operator()(const DomainFunctionType &u, RangeFunctionType &w) const =0
application operator
virtual ~Operator()
Definition: operator.hh:45
DomainFunction::RangeFieldType DomainFieldType
field type of the operator's domain
Definition: operator.hh:41
RangeFunction RangeFunctionType
type of discrete function in the operator's range
Definition: operator.hh:38
abstract affine-linear operator
Definition: operator.hh:87
virtual bool symmetric() const
Definition: operator.hh:89
virtual bool positiveDefinite() const
Definition: operator.hh:94
abstract matrix operator
Definition: operator.hh:124
virtual void flushAssembly()
commit intermediate states of linear operator assembly
Definition: operator.hh:127
std::type_index assembleOperation_
Definition: operator.hh:165
std::size_t assembleCount_
Definition: operator.hh:166
void beginAssemble()
Initiate the assemble of values using the LocalContribution concept.
Definition: operator.hh:133
void endAssemble()
Finalize the assemble of values using the LocalContribution concept.
Definition: operator.hh:151
An abstract operator Interface class for Operators. Operators are applied to Functions and the result...
Definition: operator.hh:229
virtual void apply(const DomainType &arg, RangeType &dest) const
The method apply calls the application operator. The method has to be implemented here,...
Definition: operator.hh:253
RType RangeType
Definition: operator.hh:239
Fem::Mapping< DFieldType, RFieldType, DType, RType > MappingType
type of mapping base class
Definition: operator.hh:234
RFieldType RangeFieldType
Definition: operator.hh:241
DFieldType DomainFieldType
Definition: operator.hh:240
DType DomainType
Definition: operator.hh:238