dune-fem  2.8-git
l2projection.hh
Go to the documentation of this file.
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 
9 #include <dune/common/dynvector.hh>
10 #include <dune/common/bartonnackmanifcheck.hh>
11 
12 namespace 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 
37  LocalL2Projection () {}
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 >
116  : public LocalL2Projection< typename LocalRieszProjection::BasisFunctionSetType, DefaultLocalL2Projection< LocalRieszProjection, Quadrature > >
117  {
120 
121  public:
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 
152  : DefaultLocalL2Projection( static_cast< const ThisType & >( other ) )
153  {}
154 
155 #endif // #ifndef DOXYGEN
156 
158  : rieszProjection_( std::move( other.rieszProjection_ ) )
159  {}
160 
162 
164  {
165  rieszProjection_ = std::move( other.rieszProjection_ );
166  return *this;
167  }
168 
176  void unbind() {}
177 
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 
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_;
212  mutable Dune::DynamicVector< RangeFieldType > f_;
213  };
214 
215  } // namespace Fem
216 
217 } // namespace Dune
218 
219 #endif // #ifndef DUNE_FEM_OPERATOR_PROJECTION_LOCAL_L2PROJECTION_HH
Definition: bindguard.hh:11
static GridFunctionView< GF > localFunction(const GF &gf)
Definition: gridfunctionview.hh:118
IteratorRange< typename DF::DofIteratorType > dofs(DF &df)
Iterates over all DOFs.
Definition: rangegenerators.hh:76
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 & operator=(const LocalL2Projection &)=default
assignment operator
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
const Implementation & impl() const
Definition: l2projection.hh:103
BasisFunctionSet BasisFunctionSetType
basis function set type
Definition: l2projection.hh:32
Definition: l2projection.hh:117
void apply(const LocalFunction &localFunction, LocalDofVector &dofs) const
please doc me
Definition: l2projection.hh:186
DefaultLocalL2Projection(const ThisType &)=default
DefaultLocalL2Projection(ThisType &&other)
Definition: l2projection.hh:157
LocalRieszProjection LocalRieszProjectionType
type of local Riesz type
Definition: l2projection.hh:123
void unbind()
Definition: l2projection.hh:176
DefaultLocalL2Projection(Args &&... args)
Definition: l2projection.hh:137
DefaultLocalL2Projection & operator=(const ThisType &)=default
BaseType::BasisFunctionSetType BasisFunctionSetType
basis function set type
Definition: l2projection.hh:125
BasisFunctionSetType basisFunctionSet() const
return basis function set
Definition: l2projection.hh:179
interface documentation of a local Riesz projection
Definition: localrieszprojection.hh:23
BasisFunctionSet basisFunctionSet() const
return basis function set
Definition: localrieszprojection.hh:58
void apply(const F &f, LocalDofVector &localDofVector) const
compute Riesz representation
Definition: localrieszprojection.hh:85
int nop() const
obtain the number of integration points
Definition: quadrature.hh:295
const CoordinateType & point(size_t i) const
obtain coordinates of i-th integration point
Definition: quadrature.hh:311
actual interface class for quadratures
Definition: quadrature.hh:405
const FieldType & weight(size_t i) const
obtain weight of i-th integration point
Definition: quadrature.hh:527
Interface class for basis function sets.
Definition: basisfunctionset/basisfunctionset.hh:31
void axpy(const Quadrature &quad, const Vector &values, DofVector &dofs) const
evaluate all basis function and multiply with given values and add to dofs
std::size_t size() const
return size of basis function set
const EntityType & entity() const
return entity
int order() const
return order of basis function set
FunctionSpaceType::RangeType RangeType
range type
Definition: basisfunctionset/basisfunctionset.hh:44