1#ifndef DUNE_FEM_BASISFUNCTIONSET_VECTORIAL_HH
2#define DUNE_FEM_BASISFUNCTIONSET_VECTORIAL_HH
8#include <dune/geometry/referenceelements.hh>
11#include <dune/fem/space/basisfunctionset/functor.hh>
12#include <dune/fem/space/common/functionspace.hh>
32 template<
class Implementation >
74 const Implementation &impl ()
const
76 return static_cast< const Implementation &
>( *this );
93 template<
class ScalarBasisFunctionSet,
class Range >
95 :
public DofAlignment< HorizontalDofAlignment< ScalarBasisFunctionSet, Range > >
107 : scalarSize_( scalarBasisFunctionSet.size() )
123 std::size_t scalarSize_;
138 template<
class ScalarBasisFunctionSet,
class Range >
140 :
public DofAlignment< VerticalDofAlignment< ScalarBasisFunctionSet, Range > >
145 static const int dimRange = Range::dimension;
178 template<
class DofVector,
class DofAlignment >
182 template<
class DofVector,
class ScalarBasisFunctionSet,
class Range >
187 typedef typename Range::value_type RangeFieldType;
190 typedef typename DofAlignmentType::LocalDofType LocalDofType;
193 typedef typename std::conditional<
194 std::is_const< DofVector > :: value,
195 const RangeFieldType,
196 RangeFieldType > :: type DofType;
199 typedef RangeFieldType value_type;
201 SubDofVector( DofVector &dofs,
int coordinate,
const DofAlignmentType &dofAlignment )
202 : dofs_( &(dofs[ dofAlignment.globalDof( LocalDofType( coordinate, 0 ) ) ] ) )
205 DofType &operator[] ( std::size_t i )
212 RangeFieldType operator[] ( std::size_t i )
const
222 template<
class DofVector,
class ScalarBasisFunctionSet,
class Range >
223 class SubDofVector< DofVector, VerticalDofAlignment< ScalarBasisFunctionSet, Range > >
225 typedef SubDofVector< DofVector, VerticalDofAlignment< ScalarBasisFunctionSet, Range > > ThisType;
227 typedef typename Range::value_type RangeFieldType;
229 typedef VerticalDofAlignment< ScalarBasisFunctionSet, Range > DofAlignmentType;
230 typedef typename DofAlignmentType::LocalDofType LocalDofType;
233 typedef typename std::conditional<
234 std::is_const< DofVector > :: value,
235 const RangeFieldType,
236 RangeFieldType > :: type DofType;
239 typedef RangeFieldType value_type;
241 SubDofVector( DofVector &dofs,
int coordinate,
const DofAlignmentType &dofAlignment )
243 coordinate_( coordinate ),
244 dofAlignment_( dofAlignment )
247 DofType &operator[] ( std::size_t i )
249 return dofs_[ dofAlignment_.globalDof( LocalDofType( coordinate_, i ) ) ];
254 RangeFieldType operator[] ( std::size_t i )
const
256 return dofs_[ dofAlignment_.globalDof( LocalDofType( coordinate_, i ) ) ];
262 DofAlignmentType dofAlignment_;
277 template<
class ScalarBasisFunctionSet,
class Range,
template<
class,
class >
class DofAlignment = VerticalDofAlignment >
283 typedef ScalarBasisFunctionSet ScalarBasisFunctionSetType;
285 typedef typename ScalarBasisFunctionSetType::EntityType EntityType;
286 typedef typename ScalarBasisFunctionSetType::ReferenceElementType ReferenceElementType;
289 typedef typename ScalarBasisFunctionSetType::FunctionSpaceType ScalarFunctionSpaceType;
290 static const int dimRange = Range::dimension;
317 : scalarBasisFunctionSet_( scalarBasisFunctionSet ),
318 dofAlignment_( scalarBasisFunctionSet_ )
321 int order ()
const {
return scalarBasisFunctionSet().order(); }
323 std::size_t size ()
const {
return dimRange*scalarBasisFunctionSet().size(); }
325 const ReferenceElementType &
referenceElement ()
const {
return scalarBasisFunctionSet().referenceElement(); }
327 template<
class Po
int,
class DofVector >
328 void axpy (
const Point &x,
const RangeType &valueFactor, DofVector &dofs )
const
330 axpy< EvaluateAll >( x, valueFactor, dofs );
333 template<
class Po
int,
class DofVector >
334 void axpy (
const Point &x,
const JacobianRangeType &jacobianFactor, DofVector &dofs )
const
336 axpy< JacobianAll >( x, jacobianFactor, dofs );
339 template<
class Po
int,
class DofVector >
340 void axpy (
const Point &x,
const HessianRangeType &hessianFactor, DofVector &dofs )
const
342 axpyH( x, hessianFactor, dofs );
345 template<
class Po
int,
class DofVector >
346 void axpy (
const Point &x,
const RangeType &valueFactor,
const JacobianRangeType &jacobianFactor,
347 DofVector &dofs )
const
349 axpy( x, valueFactor, dofs );
350 axpy( x, jacobianFactor, dofs );
353 template<
class Quadrature,
class Vector,
class DofVector >
354 void axpy (
const Quadrature &quad,
const Vector &values, DofVector & dofs )
const
356 const unsigned int nop = quad.
nop();
357 for(
unsigned int qp = 0; qp < nop ; ++qp )
358 axpy( quad[ qp ], values[ qp ], dofs );
361 template<
class Quadrature,
class VectorA,
class VectorB,
class DofVector >
362 void axpy (
const Quadrature &quad,
const VectorA &valuesA,
const VectorB &valuesB, DofVector & dofs )
const
364 const unsigned int nop = quad.
nop();
365 for(
unsigned int qp = 0; qp < nop ; ++qp )
367 axpy( quad[ qp ], valuesA[ qp ], dofs );
368 axpy( quad[ qp ], valuesB[ qp ], dofs );
372 template<
class Po
int,
class DofVector >
373 void evaluateAll (
const Point &x,
const DofVector &dofs, RangeType &value )
const
375 evaluateAll< EvaluateAll >( x, dofs, value );
378 template<
class Po
int,
class RangeArray >
379 void evaluateAll (
const Point &x, RangeArray &values )
const
381 evaluateAll< EvaluateAll >( x, values );
384 template<
class Quadrature,
class DofVector,
class RangeArray >
385 void evaluateAll (
const Quadrature &quad,
const DofVector &dofs, RangeArray &ranges )
const
387 const unsigned int nop = quad.
nop();
388 for(
unsigned int qp = 0; qp < nop ; ++qp )
389 evaluateAll( quad[ qp ], dofs, ranges[ qp ] );
392 template<
class Po
int,
class DofVector >
393 void jacobianAll (
const Point &x,
const DofVector &dofs, JacobianRangeType &jacobian )
const
395 evaluateAll< JacobianAll >( x, dofs, jacobian );
398 template<
class Po
int,
class JacobianRangeArray >
399 void jacobianAll (
const Point &x, JacobianRangeArray &jacobians )
const
401 evaluateAll< JacobianAll >( x, jacobians );
404 template<
class Quadrature,
class DofVector,
class JacobianArray >
405 void jacobianAll (
const Quadrature &quad,
const DofVector &dofs, JacobianArray &jacobians )
const
407 const unsigned int nop = quad.
nop();
408 for(
unsigned int qp = 0; qp < nop ; ++qp )
409 jacobianAll( quad[ qp ], dofs, jacobians[ qp ] );
412 template<
class Po
int,
class DofVector >
413 void hessianAll (
const Point &x,
const DofVector &dofs,
HessianRangeType &hessian )
const
415 evaluateAll< HessianAll >( x, dofs, hessian );
418 template<
class Po
int,
class HessianRangeArray >
419 void hessianAll (
const Point &x, HessianRangeArray &hessians )
const
421 evaluateAll< HessianAll >( x, hessians );
424 template<
class Quadrature,
class DofVector,
class HessianArray >
425 void hessianAll (
const Quadrature &quad,
const DofVector &dofs, HessianArray &hessians )
const
427 const unsigned int nop = quad.
nop();
428 for(
unsigned int qp = 0; qp < nop ; ++qp )
429 hessianAll( quad[ qp ], dofs, hessians[ qp ] );
432 const EntityType &entity ()
const {
return scalarBasisFunctionSet().entity(); }
433 bool valid ()
const {
return scalarBasisFunctionSet().valid(); }
437 const ScalarBasisFunctionSetType &scalarBasisFunctionSet ()
const
439 return scalarBasisFunctionSet_;
443 template<
class Evaluate,
class Po
int,
class DofVector >
444 void axpy (
const Point &x,
const typename Evaluate::Vector &factor, DofVector &dofs )
const
446 const std::size_t size = scalarBasisFunctionSet().size();
447 std::vector< typename Evaluate::Scalar > scalars( size );
448 Evaluate::apply( scalarBasisFunctionSet(), x, scalars );
450 for(
int r = 0; r < dimRange; ++r )
452 for( std::size_t i = 0; i < size; ++i )
454 const GlobalDofType globalDof = dofAlignment_.
globalDof( LocalDofType( r, i ) );
455 dofs[ globalDof ] += factor[ r ] * scalars[ i ][ 0 ];
459 template<
class Po
int,
class DofVector >
460 void axpyH (
const Point &x,
const HessianRangeType &factor, DofVector &dofs )
const
462 const std::size_t size = scalarBasisFunctionSet().size();
463 std::vector< typename HessianAll::Scalar > scalars( size );
464 HessianAll::apply( scalarBasisFunctionSet(), x, scalars );
466 const int xSize = DomainType::dimension;
467 for(
int r = 0; r < dimRange; ++r )
469 for( std::size_t i = 0; i < size; ++i )
471 const GlobalDofType globalDof = dofAlignment_.
globalDof( LocalDofType( r, i ) );
472 for (
int j = 0; j < xSize; ++j )
473 dofs[ globalDof ] += factor[ r ][ j ] * scalars[ i ][ 0 ][ j ];
478 template<
class Evaluate,
class Po
int,
class DofVector >
479 void evaluateAll (
const Point &x,
const DofVector &dofs,
typename Evaluate::Vector &vector )
const
482 for(
int r = 0; r < dimRange; ++r )
485 Evaluate::apply( scalarBasisFunctionSet(), x, subDofs, scalar );
486 vector[ r ] = scalar[ 0 ];
490 template<
class Evaluate,
class Po
int,
class VectorArray >
491 void evaluateAll (
const Point &x, VectorArray &vectorials )
const
493 const std::size_t size = scalarBasisFunctionSet().size();
494 std::vector< typename Evaluate::Scalar > scalars( size );
495 Evaluate::apply( scalarBasisFunctionSet(), x, scalars );
497 typedef typename Evaluate::Vector Vector;
499 for(
int r = 0; r < dimRange; ++r )
501 for( std::size_t i = 0; i < size; ++i )
503 const GlobalDofType globalDof = dofAlignment_.
globalDof( LocalDofType( r, i ) );
504 Vector &vector = vectorials[ globalDof ];
505 vector = Vector(
typename Vector::value_type( 0 ) );
506 vector[ r ] = scalars[ i ][ 0 ];
511 ScalarBasisFunctionSetType scalarBasisFunctionSet_;
520 template<
class ScalarBasisFunctionSet,
class Range,
template<
class,
class >
class DofAlignment >
523 typedef typename ScalarFunctionSpaceType::RangeType
Scalar;
524 typedef RangeType Vector;
526 template<
class Po
int,
class SubDofVector >
527 static void apply (
const ScalarBasisFunctionSetType &scalarBasisFunctionSet,
530 scalarBasisFunctionSet.evaluateAll( x, dofs, scalar );
533 template<
class Po
int,
class ScalarArray >
534 static void apply (
const ScalarBasisFunctionSetType &scalarBasisFunctionSet,
535 const Point &x, ScalarArray &scalars )
537 scalarBasisFunctionSet.evaluateAll( x, scalars );
546 template<
class ScalarBasisFunctionSet,
class Range,
template<
class,
class >
class DofAlignment >
547 struct VectorialBasisFunctionSet< ScalarBasisFunctionSet, Range, DofAlignment >::JacobianAll
549 typedef typename ScalarFunctionSpaceType::JacobianRangeType
Scalar;
550 typedef JacobianRangeType Vector;
552 template<
class Po
int,
class SubDofVector >
553 static void apply (
const ScalarBasisFunctionSetType &scalarBasisFunctionSet,
554 const Point &x,
const SubDofVector &dofs,
Scalar &scalar )
556 scalarBasisFunctionSet.jacobianAll( x, dofs, scalar );
559 template<
class Po
int,
class ScalarArray >
560 static void apply (
const ScalarBasisFunctionSetType &scalarBasisFunctionSet,
561 const Point &x, ScalarArray &scalars )
563 scalarBasisFunctionSet.jacobianAll( x, scalars );
572 template<
class ScalarBasisFunctionSet,
class Range,
template<
class,
class >
class DofAlignment >
573 struct VectorialBasisFunctionSet< ScalarBasisFunctionSet, Range, DofAlignment >::HessianAll
575 typedef typename ScalarFunctionSpaceType::HessianRangeType
Scalar;
576 typedef HessianRangeType Vector;
578 template<
class Po
int,
class SubDofVector >
579 static void apply (
const ScalarBasisFunctionSetType &scalarBasisFunctionSet,
580 const Point &x,
const SubDofVector &dofs,
Scalar &scalar )
582 scalarBasisFunctionSet.hessianAll( x, dofs, scalar );
585 template<
class Po
int,
class ScalarArray >
586 static void apply (
const ScalarBasisFunctionSetType &scalarBasisFunctionSet,
587 const Point &x, ScalarArray &scalars )
589 scalarBasisFunctionSet.hessianAll( x, scalars );
Interface documentation for Dof alignment classes used in VectorialBasisFunctionSet.
Definition: vectorial.hh:34
std::size_t GlobalDofType
global Dof type
Definition: vectorial.hh:37
LocalDofType localDof(const GlobalDofType &globalDof) const
map global to local Dof
Definition: vectorial.hh:68
std::pair< int, std::size_t > LocalDofType
local Dof type consists of coordinate number and Dof number in scalar basis function set
Definition: vectorial.hh:41
GlobalDofType globalDof(const LocalDofType &localDof) const
map local to global Dof
Definition: vectorial.hh:55
Definition: explicitfieldvector.hh:75
FunctionSpaceTraits::DomainFieldType DomainFieldType
Intrinsic type used for values in the domain field (usually a double)
Definition: functionspaceinterface.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
FunctionSpaceTraits::RangeFieldType RangeFieldType
Intrinsic type used for values in the range field (usually a double)
Definition: functionspaceinterface.hh:63
Implementation of DofAlignment.
Definition: vectorial.hh:96
GlobalDofType globalDof(const LocalDofType &localDof) const
map local to global Dof
Definition: vectorial.hh:111
LocalDofType localDof(const GlobalDofType &globalDof) const
map global to local Dof
Definition: vectorial.hh:117
int nop() const
obtain the number of integration points
Definition: quadrature.hh:291
actual interface class for quadratures
Definition: quadrature.hh:401
Extract Sub dof vector for single coordinate.
Definition: vectorial.hh:179
Builds a vectorial basis function set from given scalar basis function set.
Definition: vectorial.hh:279
Implementation of DofAlignment.
Definition: vectorial.hh:141
LocalDofType localDof(const GlobalDofType &globalDof) const
map global to local Dof
Definition: vectorial.hh:162
GlobalDofType globalDof(const LocalDofType &localDof) const
map local to global Dof
Definition: vectorial.hh:156
unspecified value type referenceElement(T &&... t)
Returns a reference element for the objects t....
typename Overloads::ScalarType< std::decay_t< V > >::type Scalar
Element type of some SIMD type.
Definition: interface.hh:235
Dune namespace.
Definition: alignedallocator.hh:13
convert functions space to space with new dim range
Definition: functionspace.hh:250
A unique label for each type of element that can occur in a grid.