dune-fem 2.8.0
Loading...
Searching...
No Matches
integrator.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_INTEGRATOR_HH
2#define DUNE_FEM_INTEGRATOR_HH
3
5
6namespace Dune
7{
8
9 namespace Fem
10 {
11
26 template< class Quadrature >
28 {
29 public:
32
34 typedef typename QuadratureType :: EntityType EntityType;
35
36 protected:
37 const int order_;
38
39 public:
45 explicit Integrator ( unsigned int order )
46 : order_( order )
47 {}
48
66 template< class Function >
67 void integrateAdd ( const EntityType &entity,
68 const Function &function,
69 typename Function :: RangeType &ret ) const
70 {
71 typedef typename Function :: RangeType RangeType;
72 typedef typename Function :: RangeFieldType RangeFieldType;
73 typedef typename Dune::FieldTraits< RangeFieldType >::real_type RealType;
74
75 const QuadratureType quadrature( entity, order_ );
76 for( const auto& qp : quadrature )
77 {
78 // evaluate function in quadrature point
79 RangeType phi;
80 function.evaluate( qp, phi );
81
82 // calculate the weight of the quadrature point
83 const RealType weight = entity.geometry().integrationElement( qp.position() ) * qp.weight();
84
85 ret.axpy( weight, phi );
86 }
87 }
88
105 template< class Function >
106 void integrate ( const EntityType &entity,
107 const Function &function,
108 typename Function :: RangeType &ret ) const
109 {
110 ret = 0;
111 integrateAdd( entity, function, ret );
112 }
113 };
114
115 } // namespace Fem
116
117} // namespace Dune
118
119#endif // #ifndef DUNE_FEM_INTEGRATOR_HH
Definition: bindguard.hh:11
Abstract class representing a function.
Definition: common/function.hh:50
void evaluate(const DomainType &x, RangeType &value) const
evaluate the function
Definition: common/function.hh:107
integrator for arbitrary functions providing evaluate
Definition: integrator.hh:28
QuadratureType::EntityType EntityType
type of the entity
Definition: integrator.hh:34
const int order_
Definition: integrator.hh:37
Quadrature QuadratureType
type of quadrature to use
Definition: integrator.hh:31
Integrator(unsigned int order)
constructor
Definition: integrator.hh:45
void integrate(const EntityType &entity, const Function &function, typename Function ::RangeType &ret) const
integrate a function over an entity
Definition: integrator.hh:106
void integrateAdd(const EntityType &entity, const Function &function, typename Function ::RangeType &ret) const
add the integral over an entity to a variable
Definition: integrator.hh:67
actual interface class for quadratures
Definition: quadrature.hh:405