DUNE-FEM (unstable)

localerror.hh
1#ifndef DUNE_FEM_MARKING_LOCALERROR_HH
2#define DUNE_FEM_MARKING_LOCALERROR_HH
3
5
6#include <dune/fem/function/localfunction/const.hh>
7#include <dune/fem/space/common/functionspace.hh>
8
9namespace Dune
10{
11
12 namespace Fem
13 {
14
15 // LocalFunctionalError
16 // --------------------
17
18 template< class ErrorFunctional >
19 class LocalFunctionalError
20 {
21 typedef LocalFunctionalError< ErrorFunctional > ThisType;
22
23 static_assert( ErrorFunctional::dimRange == 1, "Error functionals must have dimRange == 1." );
24
25 public:
26 typedef ErrorFunctional ErrorFunctionalType;
27
28 typedef typename ErrorFunctionalType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
29 typedef typename ErrorFunctionalType::GridPartType GridPartType;
30
31 typedef typename DiscreteFunctionSpaceType::DomainType DomainType;
32 typedef typename DiscreteFunctionSpaceType::RangeType RangeType;
33 typedef typename DiscreteFunctionSpaceType::RangeFieldType RangeFieldType;
34
35 typedef typename GridPartType::template Codim< 0 >::EntityType ElementType;
36
37 typedef ConstLocalFunction< ErrorFunctionalType > LocalErrorFunctionalType;
38
39 private:
40 struct LocalOne
41 {
42 typedef typename GridPartType::template Codim< 0 >::EntityType EntityType;
43
45
46 static const int dimDomain = FunctionSpaceType::dimDomain;
47 static const int dimRange = FunctionSpaceType::dimRange;
48
49 typedef typename FunctionSpaceType::DomainType DomainType;
50 typedef typename FunctionSpaceType::RangeType RangeType;
51 typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;
52
53 LocalOne ( const EntityType &entity, int order ) : entity_( entity ), order_( order ) {}
54
55 template< class Point >
56 void evaluate ( const Point &x, RangeType &value ) const
57 {
58 value[ 0 ] = 1;
59 }
60
61 template< class Quadrature, class Values >
62 void evaluateQuadrature ( const Quadrature &quadrature, Values &values ) const
63 {
64 for( const auto qp : quadrature )
65 evaluate( qp, values[ qp.index() ] );
66 }
67
68 int order () const { return order_; }
69
70 const EntityType &entity () const { return entity_; }
71
72 private:
73 const EntityType &entity_;
74 int order_;
75 };
76
77 public:
78 explicit LocalFunctionalError ( const ErrorFunctionalType &errorFunctional )
79 : localErrorFunctional_( errorFunctional )
80 {
81 localIndicator_.reserve( space().blockMapper().maxNumDofs() * DiscreteFunctionSpaceType::localBlockSize );
82 }
83
84 RangeFieldType operator() ( const ElementType &element ) const
85 {
86 localErrorFunctional_.init( element );
87 localIndicator_.resize( localErrorFunctional_.basisFunctionSet().size() );
88
89 const auto &interpolation = space().interpolation( element );
90 interpolation( LocalOne( element, localErrorFunctional_.order() ), localIndicator_ );
91
92 return localErrorFunctional_.localDofVector() * localIndicator_;
93 }
94
95 const DiscreteFunctionSpaceType &space () const { return localErrorFunctional_.discreteFunction().space(); }
96
97 private:
98 LocalErrorFunctionalType localErrorFunctional_;
100 };
101
102 } // namespace Fem
103
104} // namespace Dune
105
106#endif // #ifndef DUNE_FEM_MARKING_LOCALERROR_HH
Traits::FunctionSpaceType FunctionSpaceType
type of function space
Definition: discretefunctionspace.hh:194
FunctionSpaceTraits::RangeType RangeType
Type of range vector (using type of range field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:71
@ dimDomain
dimension of domain vector space
Definition: functionspaceinterface.hh:46
@ dimRange
dimension of range vector space
Definition: functionspaceinterface.hh:48
FunctionSpaceTraits::DomainType DomainType
Type of domain vector (using type of domain field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:67
FunctionSpaceTraits::RangeFieldType RangeFieldType
Intrinsic type used for values in the range field (usually a double)
Definition: functionspaceinterface.hh:63
A vector valued function space.
Definition: functionspace.hh:60
This file implements a dense vector with a dynamic size.
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)