DUNE-FEM (unstable)

operator.hh
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>
12#include <dune/fem/operator/common/mapping.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" );
149 assembleOperation_ = id;
150 assert( assembleCount_ == 0 );
151 AssembleOperation::begin( *this );
152 }
153 ++assembleCount_;
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:
174 std::type_index assembleOperation_ = std::type_index( typeid( void ) );
175 std::size_t assembleCount_ = 0;
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 >
203 using IsOperator = Impl::IsOperatorImpl< std::decay_t< T > >;
204
205 template< class T >
206 using IsLinearOperator = Impl::IsOperatorImpl< std::decay_t< T > >;
207
208 template< class T >
209 using IsAssembledOperator = Impl::IsAssembledOperatorImpl< std::decay_t< 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:
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
abstract matrix operator
Definition: operator.hh:133
virtual void flushAssembly()
commit intermediate states of linear operator assembly
Definition: operator.hh:136
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
A mapping from one vector space into another This class describes a general mapping from the domain v...
Definition: mapping.hh:47
DFieldType DomainFieldType
type of field the domain vector space, i.e. double
Definition: mapping.hh:66
RFieldType RangeFieldType
type of field the range vector space, i.e. double
Definition: mapping.hh:69
DType DomainType
domain vector space (for usage in derived classes) This can either be for example a discrete function...
Definition: mapping.hh:57
RType RangeType
range vector space (for usage in derived classes) This can either be for example a discrete function ...
Definition: mapping.hh:63
void operator()(const DomainType &arg, RangeType &dest) const
Application operator that applies all operators in the linear combination stack.
Definition: mapping.hh:112
Default exception if a function was called while the object is not in a valid state for that function...
Definition: exceptions.hh:281
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
Fem::Mapping< DFieldType, RFieldType, DType, RType > MappingType
type of mapping base class
Definition: operator.hh:243
A few common exception classes.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Dune namespace.
Definition: alignedallocator.hh:13
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 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 void operator()(const DomainFunctionType &u, RangeFunctionType &w) const =0
application operator
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
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 24, 22:29, 2024)