dune-fem  2.4.1-rc
integrator.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_INTEGRATOR_HH
2 #define DUNE_FEM_INTEGRATOR_HH
3 
4 //- Dune includes
6 
7 namespace Dune
8 {
9 
10  namespace Fem
11  {
12 
27  template< class Quadrature >
28  class Integrator
29  {
30  public:
33 
35  typedef typename QuadratureType :: EntityType EntityType;
36 
37  protected:
38  typedef typename EntityType :: Geometry GeometryType;
39 
40  protected:
41  const int order_;
42 
43  public:
49  inline explicit Integrator ( unsigned int order )
50  : order_( order )
51  {}
52 
70  template< class Function >
71  inline void integrateAdd ( const EntityType &entity,
72  const Function &function,
73  typename Function :: RangeType &ret ) const
74  {
75  typedef typename Function :: RangeType RangeType;
76  typedef typename Function :: RangeFieldType RangeFieldType;
77  typedef typename Dune::FieldTraits< RangeFieldType >::real_type RealType;
78 
79  const GeometryType &geometry = entity.geometry();
80  const QuadratureType quadrature( entity, order_ );
81 
82  const unsigned int numQuadraturePoints = quadrature.nop();
83  for( unsigned int pt = 0; pt < numQuadraturePoints; ++pt )
84  {
85  // evaluate function in quadrature point
86  RangeType phi;
87  function.evaluate( quadrature[ pt ], phi );
88 
89  // calculate the weight of the quadrature point
90  const RealType weight
91  = geometry.integrationElement( quadrature.point( pt ) )
92  * quadrature.weight( pt );
93 
94  ret.axpy( weight, phi );
95  }
96  }
97 
114  template< class Function >
115  inline void integrate ( const EntityType &entity,
116  const Function &function,
117  typename Function :: RangeType &ret ) const
118  {
119  ret = 0;
120  integrateAdd( entity, function, ret );
121  }
122  };
123 
124  } // namespace Fem
125 
126 } // namespace Dune
127 
128 #endif // #ifndef DUNE_FEM_INTEGRATOR_HH
EntityType::Geometry GeometryType
Definition: integrator.hh:38
QuadratureType::EntityType EntityType
type of the entity
Definition: integrator.hh:35
int nop() const
obtain the number of integration points
Definition: quadrature.hh:226
const FieldType & weight(size_t i) const
obtain weight of i-th integration point
Definition: quadrature.hh:425
Integrator(unsigned int order)
constructor
Definition: integrator.hh:49
Quadrature QuadratureType
type of quadrature to use
Definition: integrator.hh:32
FunctionSpaceType::RangeType RangeType
range type
Definition: function.hh:68
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:71
Definition: coordinate.hh:4
const CoordinateType & point(size_t i) const
obtain coordinates of i-th integration point
Definition: quadrature.hh:242
integrator for arbitrary functions providing evaluate
Definition: integrator.hh:28
FunctionSpaceType::RangeFieldType RangeFieldType
field type of range
Definition: function.hh:64
Abstract class representing a function.
Definition: function.hh:43
void integrate(const EntityType &entity, const Function &function, typename Function::RangeType &ret) const
integrate a function over an entity
Definition: integrator.hh:115
const int order_
Definition: integrator.hh:41
actual interface class for quadratures
Definition: quadrature.hh:320