1#ifndef DUNE_FEM_SHAPEFUNCTIONSET_LOCALFUNCTIONS_HH
2#define DUNE_FEM_SHAPEFUNCTIONSET_LOCALFUNCTIONS_HH
12#include <dune/fem/common/coordinate.hh>
13#include <dune/fem/space/common/functionspace.hh>
24 template<
class LocalBasis >
25 class LocalFunctionsShapeFunctionSetTraits
28 typedef typename LocalBasis::Traits Traits;
31 typedef typename Traits::DomainType DomainType;
32 typedef typename DomainType::value_type DomainFieldType;
33 static const int dimDomain = DomainType::dimension;
35 typedef typename Traits::RangeType RangeType;
36 typedef typename RangeType::value_type RangeFieldType;
37 static const int dimRange = RangeType::dimension;
39 typedef FunctionSpace< DomainFieldType, RangeFieldType, dimDomain, dimRange >
FunctionSpaceType;
47 template<
class LocalBasis,
int pSetId = -1 >
48 class LocalFunctionsShapeFunctionSet
51 typedef LocalFunctionsShapeFunctionSet< LocalBasis, pSetId > ThisType;
53 typedef LocalFunctionsShapeFunctionSetTraits< LocalBasis > Traits;
62 static const int pointSetId = pSetId;
64 explicit LocalFunctionsShapeFunctionSet (
const LocalBasis &localBasis )
65 : localBasis_( localBasis )
67 values_.reserve(
size() );
68 jacobians_.reserve(
size() );
69 hessians_.resize( DomainType::dimension*(DomainType::dimension+1)/2. );
70 for (
unsigned int i=0;i<hessians_.size();++i)
71 hessians_[i].reserve(
size() );
74 int order ()
const {
return localBasis_.order(); }
76 std::size_t
size ()
const {
return localBasis_.size(); }
78 template<
class Po
int,
class Functor >
79 void evaluateEach (
const Point &x, Functor f )
const
81 localBasis_.evaluateFunction( coordinate( x ), values_ );
82 assert( values_.size() ==
size() );
83 callFunctor( values_, f );
86 template<
class Po
int,
class Functor >
87 void jacobianEach (
const Point &x, Functor f )
const
89 localBasis_.evaluateJacobian( coordinate( x ), jacobians_ );
90 assert( jacobians_.size() ==
size() );
91 callFunctor( jacobians_, f );
94 template<
class Po
int,
class Functor >
95 void hessianEach (
const Point &x, Functor f )
const
97 std::array<unsigned int, DomainType::dimension> multiIndex;
98 std::fill(multiIndex.begin(),multiIndex.end(),0);
100 for (
unsigned int i=0;i<DomainType::dimension;++i)
103 for (
unsigned int j=i;j<DomainType::dimension;++j)
106 localBasis_.partial(multiIndex,coordinate(x),hessians_[k]);
112 callFunctor( hessians_, f );
116 template<
class T,
class Functor >
117 static void callFunctor (
const std::vector< T > &v, Functor f )
119 typedef typename std::vector< T >::const_iterator Iterator;
121 for( Iterator it = v.begin(); it != v.end(); ++it )
124 template<
class T,
class Functor >
125 static void callFunctor (
const std::vector< std::vector<T> > &v, Functor f )
128 for (
unsigned int b=0;b<v[0].size();++b)
131 for (
unsigned int i=0;i<DomainType::dimension;++i)
133 for (
unsigned int j=i;j<DomainType::dimension;++j)
135 for (
unsigned int r=0;r<RangeType::dimension;++r)
137 h[r][i][j] = v[b][k][r];
138 h[r][j][i] = v[b][k][r];
147 const LocalBasis& localBasis_;
148 mutable std::vector< RangeType > values_;
149 mutable std::vector< JacobianRangeType > jacobians_;
150 mutable std::vector< std::vector< RangeType > > hessians_;
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
A few common exception classes.
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