DUNE-FEM (unstable)

integrator.hh
1 #ifndef DUNE_FEM_INTEGRATOR_HH
2 #define DUNE_FEM_INTEGRATOR_HH
3 
4 #include <dune/fem/quadrature/quadrature.hh>
5 
6 namespace Dune
7 {
8 
9  namespace Fem
10  {
11 
26  template< class Quadrature >
27  class Integrator
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  const auto& geometry = entity.geometry();
77  for( const auto& qp : quadrature )
78  {
79  // evaluate function in quadrature point
80  RangeType phi;
81  function.evaluate( qp, phi );
82 
83  // calculate the weight of the quadrature point
84  const RealType weight = geometry.integrationElement( qp.position() ) * qp.weight();
85 
86  ret.axpy( weight, phi );
87  }
88  }
89 
106  template< class Function >
107  void integrate ( const EntityType &entity,
108  const Function &function,
109  typename Function :: RangeType &ret ) const
110  {
111  ret = 0;
112  integrateAdd( entity, function, ret );
113  }
114  };
115 
116  } // namespace Fem
117 
118 } // namespace Dune
119 
120 #endif // #ifndef DUNE_FEM_INTEGRATOR_HH
Abstract class representing a function.
Definition: function.hh:50
FunctionSpaceType ::RangeType RangeType
range type
Definition: function.hh:68
FunctionSpaceType ::RangeFieldType RangeFieldType
field type of range
Definition: function.hh:64
integrator for arbitrary functions providing evaluate
Definition: integrator.hh:28
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:107
QuadratureType ::EntityType EntityType
type of the entity
Definition: integrator.hh:34
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:401
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 16, 22:29, 2024)