dune-fem  2.4.1-rc
finitevolume/basisfunctionset.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_SPACE_FINITEVOLUME_BASISFUNCTIONSET_HH
2 #define DUNE_FEM_SPACE_FINITEVOLUME_BASISFUNCTIONSET_HH
3 
4 #include <cassert>
5 #include <cstddef>
6 
7 #include <dune/common/std/constexpr.hh>
8 
9 #include <dune/geometry/referenceelements.hh>
10 #include <dune/geometry/type.hh>
11 
13 
14 namespace Dune
15 {
16 
17  namespace Fem
18  {
19 
20  // FiniteVolumeBasisFunctionSet
21  // ----------------------------
22 
23  template< class Entity, class Range >
25  {
27  typedef Entity EntityType;
28 
30  typedef FunctionSpace< typename Entity::Geometry::ctype, typename Range::value_type,
31  Entity::Geometry::coorddimension, Range::dimension
33 
42 
44  typedef Dune::ReferenceElement< typename DomainType::value_type, DomainType::dimension > ReferenceElementType;
45 
50  FiniteVolumeBasisFunctionSet () : entity_( nullptr ) {}
51 
52  explicit FiniteVolumeBasisFunctionSet ( const EntityType &entity )
53  : entity_( &entity )
54  {}
55 
63  static DUNE_CONSTEXPR int order () { return 0; }
64 
66  static DUNE_CONSTEXPR std::size_t size () { return RangeType::dimension; }
67 
69  template< class Quadrature, class Vector, class DofVector >
70  void axpy ( const Quadrature &quadrature, const Vector &values, DofVector &dofs ) const
71  {
72  const unsigned int nop = quadrature.nop();
73  for( unsigned int qp = 0; qp < nop; ++qp )
74  axpy( quadrature[ qp ], values[ qp ], dofs );
75  }
76 
78  template< class Quadrature, class VectorA, class VectorB, class DofVector >
79  void axpy ( const Quadrature &quadrature, const VectorA &valuesA, const VectorB &valuesB, DofVector &dofs ) const
80  {
81  const unsigned int nop = quadrature.nop();
82  for( unsigned int qp = 0; qp < nop; ++qp )
83  {
84  axpy( quadrature[ qp ], valuesA[ qp ], dofs );
85  axpy( quadrature[ qp ], valuesB[ qp ], dofs );
86  }
87  }
88 
90  template< class Point, class DofVector >
91  void axpy ( const Point &x, const RangeType &valueFactor, DofVector &dofs ) const
92  {
93  for( int i = 0; i < RangeType::dimension; ++i )
94  dofs[ i ] += valueFactor[ i ];
95  }
96 
98  template< class Point, class DofVector >
99  void axpy ( const Point &x, const JacobianRangeType &jacobianFactor, DofVector &dofs ) const
100  {}
101 
103  template< class Point, class DofVector >
104  void axpy ( const Point &x, const RangeType &valueFactor, const JacobianRangeType &jacobianFactor,
105  DofVector &dofs ) const
106  {
107  axpy( x, valueFactor, dofs );
108  }
109 
111  template< class Quadrature, class DofVector, class RangeArray >
112  void evaluateAll ( const Quadrature &quadrature, const DofVector &dofs, RangeArray &ranges ) const
113  {
114  const unsigned int nop = quadrature.nop();
115  for( unsigned int qp = 0; qp < nop; ++qp )
116  evaluateAll( quadrature[ qp ], dofs, ranges[ qp ] );
117  }
118 
120  template< class Point, class DofVector >
121  void evaluateAll ( const Point &x, const DofVector &dofs, RangeType &value ) const
122  {
123  for( int i = 0; i < RangeType::dimension; ++i )
124  value[ i ] = dofs[ i ];
125  }
126 
128  template< class Point, class RangeArray >
129  void evaluateAll ( const Point &x, RangeArray &values ) const
130  {
131  for( int i = 0; i < RangeType::dimension; ++i )
132  {
133  values[ i ] = RangeType( 0 );
134  values[ i ][ i ] = typename RangeType::field_type( 1 );
135  }
136  }
137 
139  template< class QuadratureType, class DofVector, class JacobianArray >
140  void jacobianAll ( const QuadratureType &quadrature, const DofVector &dofs, JacobianArray &jacobians ) const
141  {
142  const unsigned int nop = quadrature.nop();
143  for( unsigned int qp = 0; qp < nop; ++qp )
144  jacobianAll( quadrature[ qp ], dofs, jacobians[ qp ] );
145  }
146 
148  template< class Point, class DofVector >
149  void jacobianAll ( const Point &x, const DofVector &dofs, JacobianRangeType &jacobian ) const
150  {
151  jacobian = JacobianRangeType( 0 );
152  }
153 
155  template< class Point, class JacobianRangeArray >
156  void jacobianAll ( const Point &x, JacobianRangeArray &jacobians ) const
157  {
158  for( int i = 0; i < RangeType::dimension; ++i )
159  jacobians[ i ] = JacobianRangeType( 0 );
160  }
161 
163  template< class Point, class DofVector >
164  void hessianAll ( const Point &x, const DofVector &dofs, HessianRangeType &hessian ) const
165  {
166  hessian = HessianRangeType( typename HessianRangeType::value_type( 0 ) );
167  }
168 
170  template< class Point, class HessianRangeArray >
171  void hessianAll ( const Point &x, HessianRangeArray &hessians ) const
172  {
173  for( int i = 0; i < RangeType::dimension; ++i )
174  hessians[ i ] = HessianRangeType( typename HessianRangeType::value_type( 0 ) );
175  }
176 
178  const EntityType &entity () const
179  {
180  assert( entity_ );
181  return *entity_;
182  }
183 
185  const ReferenceElementType &referenceElement () const
186  {
187  return Dune::ReferenceElements< typename EntityType::Geometry::ctype, EntityType::Geometry::coorddimension >::general( type() );
188  }
189 
191  Dune::GeometryType type () const { return entity().type(); }
192 
193  private:
194  const EntityType *entity_;
195  };
196 
199  } // namespace Fem
200 
201 } // namespace Dune
202 
203 #endif // #ifndef DUNE_FEM_SPACE_FINITEVOLUME_BASISFUNCTIONSET_HH
Definition: finitevolume/basisfunctionset.hh:24
FiniteVolumeBasisFunctionSet(const EntityType &entity)
Definition: finitevolume/basisfunctionset.hh:52
void axpy(const Quadrature &quadrature, const Vector &values, DofVector &dofs) const
evaluate all basis function and multiply with given values and add to dofs
Definition: finitevolume/basisfunctionset.hh:70
void evaluateAll(const Point &x, const DofVector &dofs, RangeType &value) const
evaluate all basis functions and store the result in the ranges array
Definition: finitevolume/basisfunctionset.hh:121
int nop() const
obtain the number of integration points
Definition: quadrature.hh:226
FunctionSpaceType::DomainType DomainType
range type
Definition: finitevolume/basisfunctionset.hh:35
const ReferenceElementType & referenceElement() const
Definition: finitevolume/basisfunctionset.hh:185
FunctionSpace< typename Entity::Geometry::ctype, typename Range::value_type, Entity::Geometry::coorddimension, Range::dimension > FunctionSpaceType
function space type
Definition: finitevolume/basisfunctionset.hh:32
static DUNE_CONSTEXPR std::size_t size()
return size of basis function set
Definition: finitevolume/basisfunctionset.hh:66
A vector valued function space.
Definition: functionspace.hh:16
void jacobianAll(const Point &x, const DofVector &dofs, JacobianRangeType &jacobian) const
evaluate the jacobian of all basis functions and store the result in the jacobians array ...
Definition: finitevolume/basisfunctionset.hh:149
FiniteVolumeBasisFunctionSet()
Definition: finitevolume/basisfunctionset.hh:50
VectorSpaceTraits< DomainField, RangeField, dimD, dimR >::LinearMappingType JacobianRangeType
Intrinsic type used for the jacobian values has a Dune::FieldMatrix type interface.
Definition: functionspaceinterface.hh:74
void hessianAll(const Point &x, const DofVector &dofs, HessianRangeType &hessian) const
Definition: finitevolume/basisfunctionset.hh:164
FieldVector< FieldMatrix< RangeFieldType, dimDomain, dimDomain >, dimRange > HessianRangeType
Intrinsic type used for the hessian values has a Dune::FieldMatrix type interface.
Definition: functionspaceinterface.hh:78
const EntityType & entity() const
return entity
Definition: finitevolume/basisfunctionset.hh:178
FunctionSpaceType::RangeType RangeType
range type
Definition: finitevolume/basisfunctionset.hh:37
void axpy(const Point &x, const JacobianRangeType &jacobianFactor, DofVector &dofs) const
evaluate all basis function and multiply with given values and add to dofs
Definition: finitevolume/basisfunctionset.hh:99
void hessianAll(const Point &x, HessianRangeArray &hessians) const
Definition: finitevolume/basisfunctionset.hh:171
void axpy(const Quadrature &quadrature, const VectorA &valuesA, const VectorB &valuesB, DofVector &dofs) const
evaluate all basis function and multiply with given values and add to dofs
Definition: finitevolume/basisfunctionset.hh:79
void jacobianAll(const QuadratureType &quadrature, const DofVector &dofs, JacobianArray &jacobians) const
evaluate the jacobian of all basis functions and store the result in the jacobians array ...
Definition: finitevolume/basisfunctionset.hh:140
Dune::ReferenceElement< typename DomainType::value_type, DomainType::dimension > ReferenceElementType
type of reference element
Definition: finitevolume/basisfunctionset.hh:44
void jacobianAll(const Point &x, JacobianRangeArray &jacobians) const
evaluate the jacobian of all basis functions and store the result in the jacobians array ...
Definition: finitevolume/basisfunctionset.hh:156
Definition: coordinate.hh:4
Dune::GeometryType type() const
Definition: finitevolume/basisfunctionset.hh:191
VectorSpaceTraits< DomainField, RangeField, dimD, dimR >::DomainType DomainType
Type of domain vector (using type of domain field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:66
void axpy(const Point &x, const RangeType &valueFactor, DofVector &dofs) const
evaluate all basis function and multiply with given values and add to dofs
Definition: finitevolume/basisfunctionset.hh:91
void evaluateAll(const Quadrature &quadrature, const DofVector &dofs, RangeArray &ranges) const
evaluate all basis functions and store the result in the ranges array
Definition: finitevolume/basisfunctionset.hh:112
FunctionSpaceType::HessianRangeType HessianRangeType
hessian range type
Definition: finitevolume/basisfunctionset.hh:41
VectorSpaceTraits< DomainField, RangeField, dimD, dimR >::RangeType RangeType
Type of range vector (using type of range field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:70
void evaluateAll(const Point &x, RangeArray &values) const
evaluate all basis functions and store the result in the ranges array
Definition: finitevolume/basisfunctionset.hh:129
static DUNE_CONSTEXPR int order()
return order of basis function set
Definition: finitevolume/basisfunctionset.hh:63
void axpy(const Point &x, const RangeType &valueFactor, const JacobianRangeType &jacobianFactor, DofVector &dofs) const
evaluate all basis function and multiply with given values and add to dofs
Definition: finitevolume/basisfunctionset.hh:104
Entity EntityType
entity type
Definition: finitevolume/basisfunctionset.hh:27
FunctionSpaceType::JacobianRangeType JacobianRangeType
jacobian range type
Definition: finitevolume/basisfunctionset.hh:39
actual interface class for quadratures
Definition: quadrature.hh:320