dune-fem  2.8-git
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 <type_traits>
8 #include <utility>
9 
10 #include <dune/geometry/referenceelements.hh>
11 #include <dune/geometry/type.hh>
12 
14 
15 namespace Dune
16 {
17 
18  namespace Fem
19  {
20 
21  // FiniteVolumeBasisFunctionSet
22  // ----------------------------
23 
24  template< class Entity, class Range >
26  {
28  typedef Entity EntityType;
29 
31  typedef FunctionSpace< typename Entity::Geometry::ctype, typename Range::value_type,
32  Entity::Geometry::coorddimension, Range::dimension
34 
43 
45  typedef std::decay_t< decltype( Dune::ReferenceElements< typename EntityType::Geometry::ctype, EntityType::Geometry::coorddimension >::general( std::declval< const Dune::GeometryType & >() ) ) > ReferenceElementType;
46 
51  FiniteVolumeBasisFunctionSet () : entity_( nullptr ) {}
52 
54  : entity_( &entity )
55  {}
56 
64  static constexpr int order () { return 0; }
65 
67  static constexpr std::size_t size () { return RangeType::dimension; }
68 
70  template< class Quadrature, class Vector, class DofVector >
71  void axpy ( const Quadrature &quadrature, const Vector &values, DofVector &dofs ) const
72  {
73  const unsigned int nop = quadrature.nop();
74  for( unsigned int qp = 0; qp < nop; ++qp )
75  axpy( quadrature[ qp ], values[ qp ], dofs );
76  }
77 
79  template< class Quadrature, class VectorA, class VectorB, class DofVector >
80  void axpy ( const Quadrature &quadrature, const VectorA &valuesA, const VectorB &valuesB, DofVector &dofs ) const
81  {
82  const unsigned int nop = quadrature.nop();
83  for( unsigned int qp = 0; qp < nop; ++qp )
84  {
85  axpy( quadrature[ qp ], valuesA[ qp ], dofs );
86  axpy( quadrature[ qp ], valuesB[ qp ], dofs );
87  }
88  }
89 
91  template< class Point, class DofVector >
92  void axpy ( const Point &x, const RangeType &valueFactor, DofVector &dofs ) const
93  {
94  for( int i = 0; i < RangeType::dimension; ++i )
95  dofs[ i ] += valueFactor[ i ];
96  }
97 
99  template< class Point, class DofVector >
100  void axpy ( const Point &x, const JacobianRangeType &jacobianFactor, DofVector &dofs ) const
101  {}
102 
104  template< class Point, class DofVector >
105  void axpy ( const Point &x, const RangeType &valueFactor, const JacobianRangeType &jacobianFactor,
106  DofVector &dofs ) const
107  {
108  axpy( x, valueFactor, dofs );
109  }
110 
112  template< class Quadrature, class DofVector, class RangeArray >
113  void evaluateAll ( const Quadrature &quadrature, const DofVector &dofs, RangeArray &ranges ) const
114  {
115  const unsigned int nop = quadrature.nop();
116  for( unsigned int qp = 0; qp < nop; ++qp )
117  evaluateAll( quadrature[ qp ], dofs, ranges[ qp ] );
118  }
119 
121  template< class Point, class DofVector >
122  void evaluateAll ( const Point &x, const DofVector &dofs, RangeType &value ) const
123  {
124  for( int i = 0; i < RangeType::dimension; ++i )
125  value[ i ] = dofs[ i ];
126  }
127 
129  template< class Point, class RangeArray >
130  void evaluateAll ( const Point &x, RangeArray &values ) const
131  {
132  for( int i = 0; i < RangeType::dimension; ++i )
133  {
134  values[ i ] = RangeType( 0 );
135  values[ i ][ i ] = typename RangeType::field_type( 1 );
136  }
137  }
138 
140  template< class QuadratureType, class DofVector, class JacobianArray >
141  void jacobianAll ( const QuadratureType &quadrature, const DofVector &dofs, JacobianArray &jacobians ) const
142  {
143  const unsigned int nop = quadrature.nop();
144  for( unsigned int qp = 0; qp < nop; ++qp )
145  jacobianAll( quadrature[ qp ], dofs, jacobians[ qp ] );
146  }
147 
149  template< class Point, class DofVector >
150  void jacobianAll ( const Point &x, const DofVector &dofs, JacobianRangeType &jacobian ) const
151  {
152  jacobian = JacobianRangeType( 0 );
153  }
154 
156  template< class Point, class JacobianRangeArray >
157  void jacobianAll ( const Point &x, JacobianRangeArray &jacobians ) const
158  {
159  for( int i = 0; i < RangeType::dimension; ++i )
160  jacobians[ i ] = JacobianRangeType( 0 );
161  }
162 
164  template< class Point, class DofVector >
165  void hessianAll ( const Point &x, const DofVector &dofs, HessianRangeType &hessian ) const
166  {
167  hessian = HessianRangeType( typename HessianRangeType::value_type( 0 ) );
168  }
169 
171  template< class Point, class HessianRangeArray >
172  void hessianAll ( const Point &x, HessianRangeArray &hessians ) const
173  {
174  for( int i = 0; i < RangeType::dimension; ++i )
175  hessians[ i ] = HessianRangeType( typename HessianRangeType::value_type( 0 ) );
176  }
177 
179  const EntityType &entity () const
180  {
181  assert( entity_ );
182  return *entity_;
183  }
184 
186  auto referenceElement () const
187  -> decltype( Dune::ReferenceElements< typename EntityType::Geometry::ctype, EntityType::Geometry::coorddimension >::general( std::declval< const Dune::GeometryType & >() ) )
188  {
189  return Dune::ReferenceElements< typename EntityType::Geometry::ctype, EntityType::Geometry::coorddimension >::general( type() );
190  }
191 
193  Dune::GeometryType type () const { return entity().type(); }
194 
196  bool valid () const { return bool(entity_); }
197 
198  private:
199  const EntityType *entity_;
200  };
201 
204  } // namespace Fem
205 
206 } // namespace Dune
207 
208 #endif // #ifndef DUNE_FEM_SPACE_FINITEVOLUME_BASISFUNCTIONSET_HH
Definition: bindguard.hh:11
IteratorRange< typename DF::DofIteratorType > dofs(DF &df)
Iterates over all DOFs.
Definition: rangegenerators.hh:76
Definition: explicitfieldvector.hh:75
int nop() const
obtain the number of integration points
Definition: quadrature.hh:295
actual interface class for quadratures
Definition: quadrature.hh:405
A vector valued function space.
Definition: functionspace.hh:60
FunctionSpaceTraits::RangeType RangeType
Type of range vector (using type of range field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:71
FunctionSpaceTraits::LinearMappingType JacobianRangeType
Intrinsic type used for the jacobian values has a Dune::FieldMatrix type interface.
Definition: functionspaceinterface.hh:75
FunctionSpaceTraits::DomainType DomainType
Type of domain vector (using type of domain field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:67
Definition: finitevolume/basisfunctionset.hh:26
void hessianAll(const Point &x, const DofVector &dofs, HessianRangeType &hessian) const
Definition: finitevolume/basisfunctionset.hh:165
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:92
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:71
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:157
void evaluateAll(const Point &x, RangeArray &values) const
evaluate all basis functions and store the result in the ranges array
Definition: finitevolume/basisfunctionset.hh:130
FunctionSpaceType::DomainType DomainType
range type
Definition: finitevolume/basisfunctionset.hh:36
static constexpr std::size_t size()
return size of basis function set
Definition: finitevolume/basisfunctionset.hh:67
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:150
FunctionSpaceType::RangeType RangeType
range type
Definition: finitevolume/basisfunctionset.hh:38
FiniteVolumeBasisFunctionSet()
Definition: finitevolume/basisfunctionset.hh:51
bool valid() const
return true if entity pointer is set
Definition: finitevolume/basisfunctionset.hh:196
FunctionSpaceType::HessianRangeType HessianRangeType
hessian range type
Definition: finitevolume/basisfunctionset.hh:42
std::decay_t< decltype(Dune::ReferenceElements< typename EntityType::Geometry::ctype, EntityType::Geometry::coorddimension >::general(std::declval< const Dune::GeometryType & >))) > ReferenceElementType
type of reference element
Definition: finitevolume/basisfunctionset.hh:45
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:122
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:100
const EntityType & entity() const
return entity
Definition: finitevolume/basisfunctionset.hh:179
Dune::GeometryType type() const
Definition: finitevolume/basisfunctionset.hh:193
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:105
void hessianAll(const Point &x, HessianRangeArray &hessians) const
Definition: finitevolume/basisfunctionset.hh:172
FiniteVolumeBasisFunctionSet(const EntityType &entity)
Definition: finitevolume/basisfunctionset.hh:53
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:80
Entity EntityType
entity type
Definition: finitevolume/basisfunctionset.hh:28
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:141
static constexpr int order()
return order of basis function set
Definition: finitevolume/basisfunctionset.hh:64
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:113
FunctionSpaceType::JacobianRangeType JacobianRangeType
jacobian range type
Definition: finitevolume/basisfunctionset.hh:40
auto referenceElement() const -> decltype(Dune::ReferenceElements< typename EntityType::Geometry::ctype, EntityType::Geometry::coorddimension >::general(std::declval< const Dune::GeometryType & >()))
Definition: finitevolume/basisfunctionset.hh:186
FunctionSpace< typename Entity::Geometry::ctype, typename Range::value_type, Entity::Geometry::coorddimension, Range::dimension > FunctionSpaceType
function space type
Definition: finitevolume/basisfunctionset.hh:33