DUNE-FEM (unstable)

basisfunctionset.hh
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
13#include <dune/fem/space/common/functionspace.hh>
14
15namespace Dune
16{
17
18 namespace Fem
19 {
20
21 // FiniteVolumeBasisFunctionSet
22 // ----------------------------
23
24 template< class Entity, class Range >
25 struct FiniteVolumeBasisFunctionSet
26 {
28 typedef Entity EntityType;
29
31 typedef FunctionSpace< typename Entity::Geometry::ctype, typename Range::value_type,
32 Entity::Geometry::coorddimension, Range::dimension
34
36 typedef typename FunctionSpaceType::DomainType DomainType;
38 typedef typename FunctionSpaceType::RangeType RangeType;
40 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
42 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
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
53 explicit FiniteVolumeBasisFunctionSet ( const EntityType &entity )
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 axpyImpl( 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 axpyImpl( valuesA[ qp ], dofs );
86 axpyImpl( 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 axpyImpl( valueFactor, dofs );
95 }
96
97 protected:
99 template< class DofVector >
100 void axpyImpl ( const RangeType &valueFactor, DofVector &dofs ) const
101 {
102 for( int i = 0; i < RangeType::dimension; ++i )
103 dofs[ i ] += valueFactor[ i ];
104 }
105
107 template< class DofVector >
108 void axpyImpl ( const JacobianRangeType &jacobianFactor, DofVector &dofs ) const
109 {}
110
111 public:
113 template< class Point, class DofVector >
114 void axpy ( const Point &x, const JacobianRangeType &jacobianFactor, DofVector &dofs ) const
115 {}
116
118 template< class Point, class DofVector >
119 void axpy ( const Point &x, const RangeType &valueFactor, const JacobianRangeType &jacobianFactor,
120 DofVector &dofs ) const
121 {
122 axpy( x, valueFactor, dofs );
123 }
124
126 template< class Quadrature, class DofVector, class RangeArray >
127 void evaluateAll ( const Quadrature &quadrature, const DofVector &dofs, RangeArray &ranges ) const
128 {
129 const unsigned int nop = quadrature.nop();
130 for( unsigned int qp = 0; qp < nop; ++qp )
131 evaluateAll( quadrature[ qp ], dofs, ranges[ qp ] );
132 }
133
135 template< class Point, class DofVector >
136 void evaluateAll ( const Point &x, const DofVector &dofs, RangeType &value ) const
137 {
138 for( int i = 0; i < RangeType::dimension; ++i )
139 value[ i ] = dofs[ i ];
140 }
141
143 template< class Point, class RangeArray >
144 void evaluateAll ( const Point &x, RangeArray &values ) const
145 {
146 for( int i = 0; i < RangeType::dimension; ++i )
147 {
148 values[ i ] = RangeType( 0 );
149 values[ i ][ i ] = typename RangeType::field_type( 1 );
150 }
151 }
152
154 template< class QuadratureType, class DofVector, class JacobianArray >
155 void jacobianAll ( const QuadratureType &quadrature, const DofVector &dofs, JacobianArray &jacobians ) const
156 {
157 const unsigned int nop = quadrature.nop();
158 for( unsigned int qp = 0; qp < nop; ++qp )
159 jacobianAll( quadrature[ qp ], dofs, jacobians[ qp ] );
160 }
161
163 template< class Point, class DofVector >
164 void jacobianAll ( const Point &x, const DofVector &dofs, JacobianRangeType &jacobian ) const
165 {
166 jacobian = JacobianRangeType( 0 );
167 }
168
170 template< class Point, class JacobianRangeArray >
171 void jacobianAll ( const Point &x, JacobianRangeArray &jacobians ) const
172 {
173 for( int i = 0; i < RangeType::dimension; ++i )
174 jacobians[ i ] = JacobianRangeType( 0 );
175 }
176
178 template< class QuadratureType, class DofVector, class HessianArray >
179 void hessianAll ( const QuadratureType &quadrature, const DofVector &dofs, HessianArray &hessians ) const
180 {
181 assert( hessians.size() >= quadrature.nop() );
182 const unsigned int nop = quadrature.nop();
183 for( unsigned int qp = 0; qp < nop; ++qp )
184 hessians[qp] = HessianRangeType( typename HessianRangeType::value_type( 0 ) );
185 }
186
188 template< class Point, class DofVector >
189 void hessianAll ( const Point &x, const DofVector &dofs, HessianRangeType &hessian ) const
190 {
191 hessian = HessianRangeType( typename HessianRangeType::value_type( 0 ) );
192 }
193
195 template< class Point, class HessianRangeArray >
196 void hessianAll ( const Point &x, HessianRangeArray &hessians ) const
197 {
198 for( int i = 0; i < RangeType::dimension; ++i )
199 hessians[ i ] = HessianRangeType( typename HessianRangeType::value_type( 0 ) );
200 }
201
203 const EntityType &entity () const
204 {
205 assert( entity_ );
206 return *entity_;
207 }
208
210 auto referenceElement () const
211 -> decltype( Dune::ReferenceElements< typename EntityType::Geometry::ctype, EntityType::Geometry::coorddimension >::general( std::declval< const Dune::GeometryType & >() ) )
212 {
214 }
215
217 Dune::GeometryType type () const { return entity().type(); }
218
220 bool valid () const { return bool(entity_); }
221
222 private:
223 const EntityType *entity_;
224 };
225
228 } // namespace Fem
229
230} // namespace Dune
231
232#endif // #ifndef DUNE_FEM_SPACE_FINITEVOLUME_BASISFUNCTIONSET_HH
Definition: explicitfieldvector.hh:75
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
A vector valued function space.
Definition: functionspace.hh:60
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
unspecified value type referenceElement(T &&... t)
Returns a reference element for the objects t....
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
STL namespace.
static const ReferenceElement & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:156
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)