dune-fem 2.12-git
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
9
10#include <dune/fem/version.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
64 virtual bool nonlinear () const { return true; }
65 };
66
87 template< class DomainFunction, class RangeFunction = DomainFunction >
89 : public virtual Operator<DomainFunction, RangeFunction>
90 {
92 virtual bool symmetric() const
93 {
94 return false;
95 }
97 virtual bool positiveDefinite() const
98 {
99 return false;
100 }
101
102 /* \copydoc Dune::Fem::Operator::nonlinear */
103 virtual bool nonlinear () const
104 {
105 return false;
106 }
107 };
108
130 template< class DomainFunction, class RangeFunction = DomainFunction >
132 : public virtual LinearOperator<DomainFunction, RangeFunction>
133 {
134 public:
136 virtual void flushAssembly() {}
137
141 template< class AssembleOperation >
143 {
144 const std::type_index id( typeid( AssembleOperation ) );
145 if( assembleOperation_ != id )
146 {
147 if( assembleOperation_ != std::type_index( typeid( void ) ) )
148 DUNE_THROW( InvalidStateException, "Another assemble operation in progress" );
150 assert( assembleCount_ == 0 );
151 AssembleOperation::begin( *this );
152 }
154 }
155
159 template< class AssembleOperation >
161 {
162 const std::type_index id( typeid( AssembleOperation ) );
163 if( assembleOperation_ != id )
164 DUNE_THROW( InvalidStateException, "Assemble operation not in progress" );
165 assert( assembleCount_ > 0 );
166 if( --assembleCount_ == 0 )
167 {
168 AssembleOperation::end( *this );
169 assembleOperation_ = std::type_index( typeid( void ) );
170 }
171 }
172
173 protected:
176 };
177
178
179 // Is*Operator
180 // -----------
181
182 namespace Impl
183 {
184
185 template< class T >
186 using DomainFunctionType_t = typename T::DomainFunctionType;
187
188 template< class T >
189 using RangeFunctionType_t = typename T::RangeFunctionType;
190
191 template< class T >
192 using IsOperatorImpl = std::is_base_of< ::Dune::Fem::Operator< DomainFunctionType_t< T >, RangeFunctionType_t< T > >, T >;
193
194 template< class T >
195 using IsLinearOperatorImpl = std::is_base_of< ::Dune::Fem::LinearOperator< DomainFunctionType_t< T >, RangeFunctionType_t< T > >, T >;
196
197 template< class T >
198 using IsAssembledOperatorImpl = std::is_base_of< ::Dune::Fem::AssembledOperator< DomainFunctionType_t< T >, RangeFunctionType_t< T > >, T >;
199
200 } // namespace Impl
201
202 template< class T >
204
205 template< class T >
207
208 template< class T >
210
211 } // namespace Fem
212
213
214
233 template <typename DFieldType, typename RFieldType,
234 typename DType , typename RType>
236 : public Fem::Mapping < DFieldType, RFieldType, DType, RType >,
237 public virtual Fem::Operator< DType, RType >
238 {
240
241 protected:
243 typedef Fem::Mapping <DFieldType,RFieldType,DType,RType> MappingType;
244
245 public:
246 //- remember template parameters for derived classes
247 typedef DType DomainType;
248 typedef RType RangeType;
249 typedef DFieldType DomainFieldType;
250 typedef RFieldType RangeFieldType;
251
252 using BaseType::operator();
253 using BaseType::finalize;
255
256 protected:
263 virtual void apply (const DomainType& arg, RangeType& dest) const
264 {
265 this->operator() (arg, dest);
266 }
267 }; // class Operator
268
270
271} // namespace Dune
272
273#endif // #ifndef DUNE_FEM_OPERATOR_HH
int id()
virtual void operator()()=0
#define DUNE_THROW(E,...)
A mapping from one vector space into another This class describes a general mapping from the domain v...
Definition mapping.hh:47
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
virtual bool nonlinear() const
Definition operator.hh:64
RangeFunction::RangeFieldType RangeFieldType
field type of the operator's range
Definition operator.hh:43
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:90
virtual bool nonlinear() const
Definition operator.hh:103
virtual bool symmetric() const
Definition operator.hh:92
virtual bool positiveDefinite() const
Definition operator.hh:97
abstract matrix operator
Definition operator.hh:133
virtual void flushAssembly()
commit intermediate states of linear operator assembly
Definition operator.hh:136
std::type_index assembleOperation_
Definition operator.hh:174
std::size_t assembleCount_
Definition operator.hh:175
void beginAssemble()
Initiate the assemble of values using the LocalContribution concept.
Definition operator.hh:142
void endAssemble()
Finalize the assemble of values using the LocalContribution concept.
Definition operator.hh:160
An abstract operator Interface class for Operators. Operators are applied to Functions and the result...
Definition operator.hh:238
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:263
RType RangeType
Definition operator.hh:248
Fem::Mapping< DFieldType, RFieldType, DType, RType > MappingType
type of mapping base class
Definition operator.hh:243
RFieldType RangeFieldType
Definition operator.hh:250
DFieldType DomainFieldType
Definition operator.hh:249
DType DomainType
Definition operator.hh:247