DUNE-FEM (unstable)

l2projection.hh
1#ifndef DUNE_FEM_OPERATOR_PROJECTION_LOCAL_L2PROJECTION_HH
2#define DUNE_FEM_OPERATOR_PROJECTION_LOCAL_L2PROJECTION_HH
3
4#include <cstddef>
5
6#include <type_traits>
7#include <utility>
8
11
12namespace Dune
13{
14
15 namespace Fem
16 {
17
18 // LocalL2Projection
19 // -----------------
20
27 template< class BasisFunctionSet, class Implementation >
29 {
30 public:
33
34 protected:
35#ifndef DOXYGEN
36
38
39#endif // #ifndef DOXYGEN
40
46 LocalL2Projection ( const LocalL2Projection & ) = default;
47
50
53
56
59 public:
66 {
67 CHECK_INTERFACE_IMPLEMENTATION( impl().basisFunctionSet() );
68 return impl().basisFunctionSet();
69 }
70
79 template< class LocalFunction, class LocalDofVector >
80 void operator() ( const LocalFunction &localFunction, LocalDofVector &localDofVector ) const
81 {
82 apply( localFunction, localDofVector );
83 }
84
93 template< class LocalFunction, class LocalDofVector >
94 void apply ( const LocalFunction &localFunction, LocalDofVector &localDofVector ) const
95 {
96 CHECK_INTERFACE_IMPLEMENTATION( impl().apply( localFunction, localDofVector ) );
97 impl().apply( localFunction, localDofVector );
98 }
99
102 protected:
103 const Implementation &impl () const
104 {
105 return static_cast< const Implementation & >( *this );
106 }
107 };
108
109
110
111 // DefaultLocalL2Projection
112 // ------------------------
113
114 template< class LocalRieszProjection, class Quadrature >
115 class DefaultLocalL2Projection
116 : public LocalL2Projection< typename LocalRieszProjection::BasisFunctionSetType, DefaultLocalL2Projection< LocalRieszProjection, Quadrature > >
117 {
118 typedef DefaultLocalL2Projection< LocalRieszProjection, Quadrature > ThisType;
119 typedef LocalL2Projection< typename LocalRieszProjection::BasisFunctionSetType, DefaultLocalL2Projection< LocalRieszProjection, Quadrature > > BaseType;
120
121 public:
123 typedef LocalRieszProjection LocalRieszProjectionType;
125 typedef typename BaseType::BasisFunctionSetType BasisFunctionSetType;
126
127 private:
128 typedef typename BasisFunctionSetType::RangeType RangeType;
129 typedef typename RangeType::value_type RangeFieldType;
130
131 public:
136 template< class... Args >
137 explicit DefaultLocalL2Projection ( Args &&... args )
138 : rieszProjection_( std::forward< Args >( args )... )
139 {}
140
147 DefaultLocalL2Projection ( const ThisType & ) = default;
148
149#ifndef DOXYGEN
150
151 DefaultLocalL2Projection ( ThisType &other )
152 : DefaultLocalL2Projection( static_cast< const ThisType & >( other ) )
153 {}
154
155#endif // #ifndef DOXYGEN
156
157 DefaultLocalL2Projection ( ThisType &&other )
158 : rieszProjection_( std::move( other.rieszProjection_ ) )
159 {}
160
161 DefaultLocalL2Projection &operator= ( const ThisType & ) = default;
162
163 DefaultLocalL2Projection &operator= ( ThisType &&other )
164 {
165 rieszProjection_ = std::move( other.rieszProjection_ );
166 return *this;
167 }
168
176 void unbind() {}
177
179 BasisFunctionSetType basisFunctionSet () const
180 {
181 return rieszProjection_.basisFunctionSet();
182 }
183
185 template< class LocalFunction, class LocalDofVector >
186 void apply ( const LocalFunction &localFunction, LocalDofVector &dofs ) const
187 {
188 static_assert( std::is_same< RangeType, typename LocalFunction::RangeType >::value,
189 "RangeType and LocalFunction::RangeType have to be the same type" );
190
191 const BasisFunctionSetType basisFunctionSet = this->basisFunctionSet();
192 const auto geometry = basisFunctionSet.entity().geometry();
193
194 f_.resize( basisFunctionSet.size() );
195 f_ = static_cast< RangeFieldType >( 0 );
196
197 Quadrature quadrature( geometry.type(), localFunction.order() + basisFunctionSet.order() );
198 const std::size_t nop = quadrature.nop();
199 for( std::size_t qp = 0; qp < nop; ++qp )
200 {
201 RangeType value;
202 localFunction.evaluate( quadrature[ qp ], value );
203 value *= quadrature.weight( qp )*geometry.integrationElement( quadrature.point( qp ) );
204 basisFunctionSet.axpy( quadrature[ qp ], value, f_ );
205 }
206
207 rieszProjection_.apply( f_, dofs );
208 }
209
210 private:
211 LocalRieszProjectionType rieszProjection_;
213 };
214
215 } // namespace Fem
216
217} // namespace Dune
218
219#endif // #ifndef DUNE_FEM_OPERATOR_PROJECTION_LOCAL_L2PROJECTION_HH
Provides check for implementation of interface methods when using static polymorphism,...
Interface class for basis function sets.
Definition: basisfunctionset.hh:32
FunctionSpaceType::RangeType RangeType
range type
Definition: basisfunctionset.hh:45
interface for local functions
Definition: localfunction.hh:77
please doc me
Definition: l2projection.hh:29
void operator()(const LocalFunction &localFunction, LocalDofVector &localDofVector) const
please doc me
Definition: l2projection.hh:80
LocalL2Projection(LocalL2Projection &&)
move constructor
Definition: l2projection.hh:49
void apply(const LocalFunction &localFunction, LocalDofVector &localDofVector) const
please doc me
Definition: l2projection.hh:94
BasisFunctionSet basisFunctionSet() const
return basis function set
Definition: l2projection.hh:65
LocalL2Projection(const LocalL2Projection &)=default
copy constructor
BasisFunctionSet BasisFunctionSetType
basis function set type
Definition: l2projection.hh:32
LocalL2Projection & operator=(const LocalL2Projection &)=default
assignment operator
This file implements a dense vector with a dynamic size.
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)