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 EntityType::Geometry Geometry;
287 typedef typename ScalarBasisFunctionSetType::ReferenceElementType ReferenceElementType;
290 typedef typename ScalarBasisFunctionSetType::FunctionSpaceType ScalarFunctionSpaceType;
291 static const int dimRange = Range::dimension;
318 : scalarBasisFunctionSet_( scalarBasisFunctionSet ),
319 dofAlignment_( scalarBasisFunctionSet_ )
322 int order ()
const {
return scalarBasisFunctionSet().order(); }
324 std::size_t size ()
const {
return dimRange*scalarBasisFunctionSet().size(); }
326 const ReferenceElementType &
referenceElement ()
const {
return scalarBasisFunctionSet().referenceElement(); }
329 template<
class Po
int,
class DofVector >
330 void axpy (
const Point &x,
const RangeType &valueFactor, DofVector &dofs )
const
332 axpy< EvaluateAll >( x, valueFactor, dofs );
335 template<
class Po
int,
class DofVector >
336 void axpy (
const Point &x,
const JacobianRangeType &jacobianFactor, DofVector &dofs )
const
338 axpy< JacobianAll >( x, jacobianFactor, dofs );
341 template<
class Po
int,
class DofVector >
342 void axpy (
const Point &x,
const HessianRangeType &hessianFactor, DofVector &dofs )
const
344 axpyH( x, hessianFactor, dofs );
347 template<
class Po
int,
class DofVector >
348 void axpy (
const Point &x,
const RangeType &valueFactor,
const JacobianRangeType &jacobianFactor,
349 DofVector &dofs )
const
351 axpy( x, valueFactor, dofs );
352 axpy( x, jacobianFactor, dofs );
355 template<
class Quadrature,
class Vector,
class DofVector >
356 void axpy (
const Quadrature &quad,
const Vector &values, DofVector & dofs )
const
358 const unsigned int nop = quad.
nop();
359 for(
unsigned int qp = 0; qp < nop ; ++qp )
360 axpy( quad[ qp ], values[ qp ], dofs );
363 template<
class Quadrature,
class VectorA,
class VectorB,
class DofVector >
364 void axpy (
const Quadrature &quad,
const VectorA &valuesA,
const VectorB &valuesB, DofVector & dofs )
const
366 const unsigned int nop = quad.
nop();
367 for(
unsigned int qp = 0; qp < nop ; ++qp )
369 axpy( quad[ qp ], valuesA[ qp ], dofs );
370 axpy( quad[ qp ], valuesB[ qp ], dofs );
374 template<
class Po
int,
class DofVector >
375 void evaluateAll (
const Point &x,
const DofVector &dofs, RangeType &value )
const
377 evaluateAll< EvaluateAll >( x, dofs, value );
380 template<
class Po
int,
class RangeArray >
381 void evaluateAll (
const Point &x, RangeArray &values )
const
383 evaluateAll< EvaluateAll >( x, values );
386 template<
class Quadrature,
class DofVector,
class RangeArray >
387 void evaluateAll (
const Quadrature &quad,
const DofVector &dofs, RangeArray &ranges )
const
389 const unsigned int nop = quad.
nop();
390 for(
unsigned int qp = 0; qp < nop ; ++qp )
391 evaluateAll( quad[ qp ], dofs, ranges[ qp ] );
394 template<
class Po
int,
class DofVector >
395 void jacobianAll (
const Point &x,
const DofVector &dofs, JacobianRangeType &jacobian )
const
397 evaluateAll< JacobianAll >( x, dofs, jacobian );
400 template<
class Po
int,
class JacobianRangeArray >
401 void jacobianAll (
const Point &x, JacobianRangeArray &jacobians )
const
403 evaluateAll< JacobianAll >( x, jacobians );
406 template<
class Quadrature,
class DofVector,
class JacobianArray >
407 void jacobianAll (
const Quadrature &quad,
const DofVector &dofs, JacobianArray &jacobians )
const
409 const unsigned int nop = quad.
nop();
410 for(
unsigned int qp = 0; qp < nop ; ++qp )
411 jacobianAll( quad[ qp ], dofs, jacobians[ qp ] );
414 template<
class Po
int,
class DofVector >
415 void hessianAll (
const Point &x,
const DofVector &dofs,
HessianRangeType &hessian )
const
417 evaluateAll< HessianAll >( x, dofs, hessian );
420 template<
class Po
int,
class HessianRangeArray >
421 void hessianAll (
const Point &x, HessianRangeArray &hessians )
const
423 evaluateAll< HessianAll >( x, hessians );
426 template<
class Quadrature,
class DofVector,
class HessianArray >
427 void hessianAll (
const Quadrature &quad,
const DofVector &dofs, HessianArray &hessians )
const
429 const unsigned int nop = quad.
nop();
430 for(
unsigned int qp = 0; qp < nop ; ++qp )
431 hessianAll( quad[ qp ], dofs, hessians[ qp ] );
434 const EntityType &entity ()
const {
return scalarBasisFunctionSet().entity(); }
435 const Geometry& geometry ()
const {
return scalarBasisFunctionSet().geometry(); }
436 bool valid ()
const {
return scalarBasisFunctionSet().valid(); }
440 const ScalarBasisFunctionSetType &scalarBasisFunctionSet ()
const
442 return scalarBasisFunctionSet_;
446 template<
class Evaluate,
class Po
int,
class DofVector >
447 void axpy (
const Point &x,
const typename Evaluate::Vector &factor, DofVector &dofs )
const
449 const std::size_t size = scalarBasisFunctionSet().size();
450 std::vector< typename Evaluate::Scalar > scalars( size );
451 Evaluate::apply( scalarBasisFunctionSet(), x, scalars );
453 for(
int r = 0; r < dimRange; ++r )
455 for( std::size_t i = 0; i < size; ++i )
457 const GlobalDofType globalDof = dofAlignment_.
globalDof( LocalDofType( r, i ) );
458 dofs[ globalDof ] += factor[ r ] * scalars[ i ][ 0 ];
462 template<
class Po
int,
class DofVector >
463 void axpyH (
const Point &x,
const HessianRangeType &factor, DofVector &dofs )
const
465 const std::size_t size = scalarBasisFunctionSet().size();
466 std::vector< typename HessianAll::Scalar > scalars( size );
467 HessianAll::apply( scalarBasisFunctionSet(), x, scalars );
469 const int xSize = DomainType::dimension;
470 for(
int r = 0; r < dimRange; ++r )
472 for( std::size_t i = 0; i < size; ++i )
474 const GlobalDofType globalDof = dofAlignment_.
globalDof( LocalDofType( r, i ) );
475 for (
int j = 0; j < xSize; ++j )
476 dofs[ globalDof ] += factor[ r ][ j ] * scalars[ i ][ 0 ][ j ];
481 template<
class Evaluate,
class Po
int,
class DofVector >
482 void evaluateAll (
const Point &x,
const DofVector &dofs,
typename Evaluate::Vector &vector )
const
485 for(
int r = 0; r < dimRange; ++r )
488 Evaluate::apply( scalarBasisFunctionSet(), x, subDofs, scalar );
489 vector[ r ] = scalar[ 0 ];
493 template<
class Evaluate,
class Po
int,
class VectorArray >
494 void evaluateAll (
const Point &x, VectorArray &vectorials )
const
496 const std::size_t size = scalarBasisFunctionSet().size();
497 std::vector< typename Evaluate::Scalar > scalars( size );
498 Evaluate::apply( scalarBasisFunctionSet(), x, scalars );
500 typedef typename Evaluate::Vector Vector;
502 for(
int r = 0; r < dimRange; ++r )
504 for( std::size_t i = 0; i < size; ++i )
506 const GlobalDofType globalDof = dofAlignment_.
globalDof( LocalDofType( r, i ) );
507 Vector &vector = vectorials[ globalDof ];
508 vector = Vector(
typename Vector::value_type( 0 ) );
509 vector[ r ] = scalars[ i ][ 0 ];
514 ScalarBasisFunctionSetType scalarBasisFunctionSet_;
523 template<
class ScalarBasisFunctionSet,
class Range,
template<
class,
class >
class DofAlignment >
526 typedef typename ScalarFunctionSpaceType::RangeType
Scalar;
527 typedef RangeType Vector;
529 template<
class Po
int,
class SubDofVector >
530 static void apply (
const ScalarBasisFunctionSetType &scalarBasisFunctionSet,
533 scalarBasisFunctionSet.evaluateAll( x, dofs, scalar );
536 template<
class Po
int,
class ScalarArray >
537 static void apply (
const ScalarBasisFunctionSetType &scalarBasisFunctionSet,
538 const Point &x, ScalarArray &scalars )
540 scalarBasisFunctionSet.evaluateAll( x, scalars );
549 template<
class ScalarBasisFunctionSet,
class Range,
template<
class,
class >
class DofAlignment >
550 struct VectorialBasisFunctionSet< ScalarBasisFunctionSet, Range, DofAlignment >::JacobianAll
552 typedef typename ScalarFunctionSpaceType::JacobianRangeType
Scalar;
553 typedef JacobianRangeType Vector;
555 template<
class Po
int,
class SubDofVector >
556 static void apply (
const ScalarBasisFunctionSetType &scalarBasisFunctionSet,
557 const Point &x,
const SubDofVector &dofs,
Scalar &scalar )
559 scalarBasisFunctionSet.jacobianAll( x, dofs, scalar );
562 template<
class Po
int,
class ScalarArray >
563 static void apply (
const ScalarBasisFunctionSetType &scalarBasisFunctionSet,
564 const Point &x, ScalarArray &scalars )
566 scalarBasisFunctionSet.jacobianAll( x, scalars );
575 template<
class ScalarBasisFunctionSet,
class Range,
template<
class,
class >
class DofAlignment >
576 struct VectorialBasisFunctionSet< ScalarBasisFunctionSet, Range, DofAlignment >::HessianAll
578 typedef typename ScalarFunctionSpaceType::HessianRangeType
Scalar;
579 typedef HessianRangeType Vector;
581 template<
class Po
int,
class SubDofVector >
582 static void apply (
const ScalarBasisFunctionSetType &scalarBasisFunctionSet,
583 const Point &x,
const SubDofVector &dofs,
Scalar &scalar )
585 scalarBasisFunctionSet.hessianAll( x, dofs, scalar );
588 template<
class Po
int,
class ScalarArray >
589 static void apply (
const ScalarBasisFunctionSetType &scalarBasisFunctionSet,
590 const Point &x, ScalarArray &scalars )
592 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
actual interface class for integration point lists
Definition: quadrature.hh:158
int nop() const
obtain the number of integration points
Definition: quadrature.hh:312
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
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....
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.