DUNE-FEM (unstable)

interpolation.hh
1#ifndef DUNE_FEM_SPACE_DISCONTINUOUSGALERKIN_INTERPOLATION_HH
2#define DUNE_FEM_SPACE_DISCONTINUOUSGALERKIN_INTERPOLATION_HH
3
4#include <type_traits>
5#include <utility>
6
8
9#include <dune/fem/quadrature/cachingquadrature.hh>
10#include <dune/fem/quadrature/agglomerationquadrature.hh>
11
12#include <dune/fem/operator/projection/local/l2projection.hh>
13#include <dune/fem/operator/projection/local/riesz.hh>
14
15namespace Dune
16{
17
18 namespace Fem
19 {
20
21 // Internal forward declaration
22 // ----------------------------
23
24 template< class GridPart, class BasisFunctionSet,
25 class Quadrature = CachingQuadrature< GridPart, BasisFunctionSet::EntityType::codimension > >
26 class DiscontinuousGalerkinLocalL2Projection;
27
28 template< class GridPart, class BasisFunctionSet,
29 class Quadrature = CachingQuadrature< GridPart, BasisFunctionSet::EntityType::codimension > >
30 class LocalOrthonormalL2Projection;
31
32
33 // LocalOrthonormalL2Projection
34 // ----------------------------
35
37 template< class GridPart, class BasisFunctionSet, class Quadrature >
39 : public LocalL2Projection< BasisFunctionSet, LocalOrthonormalL2Projection< GridPart, BasisFunctionSet, Quadrature > >
40 {
43
44 public:
49
50 private:
51 typedef GridPart GridPartType;
52 typedef typename GridPartType::GridType GridType;
53 typedef typename BasisFunctionSetType :: RangeType RangeType;
54
55 public:
61 : basisFunctionSet_( basisFunctionSet )
62 {}
63
65 : basisFunctionSet_( std::forward< BasisFunctionSetType >( basisFunctionSet ) )
66 {}
67
74 LocalOrthonormalL2Projection ( const ThisType & ) = default;
75
76 LocalOrthonormalL2Projection ( ThisType &&other ) = default;
77
78 ThisType &operator= ( const ThisType & ) = default;
79
80 ThisType &operator= ( ThisType &&other ) = default;
81
90 {
91 return basisFunctionSet_;
92 }
93
95 template< class LocalFunction, class LocalDofVector >
96 void apply ( const LocalFunction &localFunction, LocalDofVector &localDofVector ) const
97 {
98 // get entity and geometry
99 const EntityType &entity = localFunction.entity();
100
101 if( entity.type().isNone() )
102 {
103 typedef ElementQuadrature< GridPartType, EntityType::codimension > ElementQuadratureType;
104 ElementQuadratureType quadrature( entity, localFunction.order() + basisFunctionSet().order() );
105 computeL2Projection( entity, quadrature, localFunction, localDofVector );
106 }
107 else
108 {
109 // create quadrature with appropriate order
110 Quadrature quadrature( entity, localFunction.order() + basisFunctionSet().order() );
111 computeL2Projection( entity, quadrature, localFunction, localDofVector );
112 }
113 }
114
117 protected:
118 template <class QuadImpl, class LocalFunction, class LocalDofVector >
119 void computeL2Projection( const EntityType& entity,
120 const QuadImpl& quadrature,
121 const LocalFunction &localFunction, LocalDofVector &localDofVector ) const
122 {
123 // set all dofs to zero
124 localDofVector.clear();
125
126 const int nop = quadrature.nop();
127 // adjust size of values
128 values_.resize( nop );
129
130 // evaluate local function for all quadrature points
131 localFunction.evaluateQuadrature( quadrature, values_ );
132
133 // apply weight only (for orthonormal basis set integration element and
134 // mass matrix can be ignored even if geometry is non-affine)
135 for(auto qp : quadrature )
136 values_[ qp.index() ] *= qp.weight();
137
138 // add values to local dof vector
139 basisFunctionSet().axpy( quadrature, values_, localDofVector );
140 }
141
142 BasisFunctionSetType basisFunctionSet_;
143 mutable std::vector< RangeType > values_;
144 };
145
146
147 // DiscontinuousGalerkinLocalL2Projection
148 // --------------------------------------
149
150 template< class GridPart, class BasisFunctionSet, class Quadrature >
151 class DiscontinuousGalerkinLocalL2Projection
152 : public LocalL2Projection< BasisFunctionSet, DiscontinuousGalerkinLocalL2Projection< GridPart, BasisFunctionSet, Quadrature > >
153 {
154 typedef DiscontinuousGalerkinLocalL2Projection< GridPart, BasisFunctionSet, Quadrature > ThisType;
155 typedef LocalL2Projection< BasisFunctionSet, DiscontinuousGalerkinLocalL2Projection< GridPart, BasisFunctionSet, Quadrature > > BaseType;
156
157 public:
159 typedef typename BaseType::BasisFunctionSetType BasisFunctionSetType;
160
161 private:
162 typedef GridPart GridPartType;
163 typedef typename GridPartType::GridType GridType;
164 static const bool cartesian = Dune::Capabilities::isCartesian< GridType >::v;
165
166 typedef typename std::conditional< cartesian,
167 OrthonormalLocalRieszProjection< BasisFunctionSetType >,
168 DenseLocalRieszProjection< BasisFunctionSetType, Quadrature >
169 >::type LocalRieszProjectionType;
170
171 typedef DefaultLocalL2Projection< LocalRieszProjectionType, Quadrature > Implementation;
172
173 public:
178 explicit DiscontinuousGalerkinLocalL2Projection ( const BasisFunctionSetType &basisFunctionSet )
179 : impl_( LocalRieszProjectionType( basisFunctionSet ) )
180 {}
181
182 explicit DiscontinuousGalerkinLocalL2Projection ( BasisFunctionSetType &&basisFunctionSet )
183 : impl_( LocalRieszProjectionType( std::forward< BasisFunctionSetType >( basisFunctionSet ) ) )
184 {}
185
192 DiscontinuousGalerkinLocalL2Projection ( const ThisType & ) = default;
193
194 DiscontinuousGalerkinLocalL2Projection ( ThisType &&other )
195 : impl_( std::move( other.impl_ ) )
196 {}
197
198 ThisType &operator= ( const ThisType & ) = default;
199
200 ThisType &operator= ( ThisType &&other )
201 {
202 impl_ = std::move( other.impl_ );
203 return *this;
204 }
205
213 BasisFunctionSet basisFunctionSet () const
214 {
215 return impl_.basisFunctionSet();
216 }
217
219 template< class LocalFunction, class LocalDofVector >
220 void apply ( const LocalFunction &localFunction, LocalDofVector &localDofVector ) const
221 {
222 impl_( localFunction, localDofVector );
223 }
224
225 void unbind() {}
226
229 private:
230 Implementation impl_;
231 };
232
233 } // namespace Fem
234
235} // namespace Dune
236
237#endif // #ifndef DUNE_FEM_SPACE_DISCONTINUOUSGALERKIN_INTERPOLATION_HH
Wrapper class for entities.
Definition: entity.hh:66
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:146
Interface class for basis function sets.
Definition: basisfunctionset.hh:32
void axpy(const Quadrature &quad, const Vector &values, DofVector &dofs) const
evaluate all basis function and multiply with given values and add to dofs
Entity EntityType
entity type
Definition: basisfunctionset.hh:35
FunctionSpaceType::RangeType RangeType
range type
Definition: basisfunctionset.hh:45
actual interface class for integration point lists
Definition: quadrature.hh:158
interface for local functions
Definition: localfunction.hh:77
void evaluateQuadrature(const QuadratureType &quad, Vectors &... vec) const
evaluate all basisfunctions for all quadrature points and store the results in the result vector
Definition: localfunction.hh:393
const EntityType & entity() const
obtain the entity, this local function lives on
Definition: localfunction.hh:305
int order() const
obtain the order of this local function
Definition: localfunction.hh:293
please doc me
Definition: l2projection.hh:29
specialization of local L2 projection for orthonormal DG spaces
Definition: interpolation.hh:40
void apply(const LocalFunction &localFunction, LocalDofVector &localDofVector) const
please doc me
Definition: interpolation.hh:96
BasisFunctionSetType::EntityType EntityType
Definition: interpolation.hh:48
BaseType::BasisFunctionSetType BasisFunctionSetType
basis function set type
Definition: interpolation.hh:46
const BasisFunctionSet & basisFunctionSet() const
return basis function set
Definition: interpolation.hh:89
constexpr bool isNone() const
Return true if entity is a singular of any dimension.
Definition: type.hh:355
actual interface class for quadratures
A set of traits classes to store static information about grid implementation.
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Specialize with 'true' if the grid is a Cartesian grid. Cartesian grids satisfy the following propert...
Definition: capabilities.hh:48
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)