1 #ifndef DUNE_FEM_SPACE_SHAPEFUNCTIONSET_LEGENDRE_HH 2 #define DUNE_FEM_SPACE_SHAPEFUNCTIONSET_LEGENDRE_HH 30 template<
class FunctionSpace >
63 template<
class MultiIndex >
69 auto first = begin( multiIndex );
70 auto last = end( multiIndex );
71 assert( std::distance( first, last ) == dimDomain );
72 std::copy( first, last, multiIndex_.begin() );
80 return *std::max_element( multiIndex_.begin(), multiIndex_.end() );
84 const std::array< int, FunctionSpaceType::dimDomain > &
orders () const noexcept
90 void evaluate (
const DomainType &x, RangeType &value )
const noexcept
93 for(
int i = 0; i < dimDomain; ++i )
101 for(
int k = 0; k < dimDomain; ++k )
105 for(
int i = 0; i < dimDomain; ++i )
106 jacobian[ 0 ][ i ] *= ( k == i ) ? dphi : phi;
114 for(
int k = 0; k < dimDomain; ++k )
118 for(
int i = 0; i < dimDomain; ++i )
121 for(
int j = i+1; j < dimDomain; ++j )
123 RangeFieldType tmp = ( k == i || k == j ) ? dphi : phi;
132 std::array< int, dimDomain > multiIndex_;
139 namespace __LegendreShapeFunctionSet
145 template<
class FunctionSpace >
151 typedef std::array< int, dimDomain > MultiIndex;
154 explicit DefaultFactory (
int order )
158 int order ()
const noexcept {
return order_; }
160 std::size_t size ()
const noexcept
162 std::size_t size = 1;
163 for(
int i = 0; i < dimDomain; ++i )
168 template<
class InputIterator >
169 void operator() ( InputIterator first )
const noexcept
171 auto function = [&first](
const MultiIndex &multiIndex )
173 *first = ShapeFunctionType( multiIndex );
177 MultiIndex multiIndex;
178 fill( multiIndex,
function, &multiIndex[ 0 ], dimDomain,
order() );
182 template<
class Function >
183 static void fill ( MultiIndex &multiIndex,
Function function,
184 int *begin, std::size_t n,
int order )
188 for( *begin = 0; *begin <=
order; *begin += 1 )
189 fill( multiIndex,
function, begin+1, n-1, order );
192 function( multiIndex );
200 #endif // #ifndef DOXYGEN 215 template<
class FunctionSpace >
269 template<
class Factory >
271 : shapeFunctions_( factory.size() ),
272 order_( factory.
order() )
274 factory( shapeFunctions_.begin() );
280 int order () const noexcept {
return order_; }
283 std::size_t
size () const noexcept {
return shapeFunctions_.size(); }
286 template<
class Po
int,
class Functor >
291 for(
const ShapeFunctionType &shapeFunction : shapeFunctions_ )
293 shapeFunction.evaluate(
coordinate( x ), value );
294 functor( i++, value );
299 template<
class Po
int,
class Functor >
304 for(
const ShapeFunctionType &shapeFunction : shapeFunctions_ )
306 shapeFunction.jacobian(
coordinate( x ), jacobian );
307 functor( i++, jacobian );
312 template<
class Po
int,
class Functor >
313 void hessianEach (
const Point &x, Functor functor )
const noexcept
317 for(
const ShapeFunctionType &shapeFunction : shapeFunctions_ )
319 shapeFunction.hessian(
coordinate( x ), hessian );
320 functor( i++, hessian );
342 template<
class FunctionSpace >
353 bool operator() (
const ShapeFunctionType &lhs,
const ShapeFunctionType &rhs ) noexcept
355 if( lhs.order() != rhs.order() )
356 return lhs.order() < rhs.order();
359 const auto &a = lhs.orders();
360 const auto &b = rhs.orders();
361 return std::lexicographical_compare( a.begin(), a.end(), b.begin(), b.end() );
376 std::sort( shapeFunctions_.begin(), shapeFunctions_.end(), Compare() );
382 using BaseType::shapeFunctions_;
389 #endif // #ifndef DUNE_FEM_SPACE_SHAPEFUNCTIONSET_LEGENDRE_HH LegendreShapeFunction()=default
const std::array< int, FunctionSpaceType::dimDomain > & orders() const noexcept
return monomial orders of this function
Definition: shapefunctionset/legendre.hh:84
VectorSpaceTraits< DomainField, RangeField, dimD, dimR >::RangeFieldType RangeFieldType
Intrinsic type used for values in the range field (usually a double)
Definition: functionspaceinterface.hh:62
FunctionSpaceType::RangeFieldType RangeFieldType
field type of range
Definition: shapefunctionset/legendre.hh:42
A vector valued function space.
Definition: functionspace.hh:16
FunctionSpaceType::RangeType RangeType
range type
Definition: shapefunctionset/legendre.hh:47
FunctionSpaceType::HessianRangeType HessianRangeType
hessian range type
Definition: shapefunctionset/legendre.hh:232
VectorSpaceTraits< DomainField, RangeField, dimD, dimR >::LinearMappingType JacobianRangeType
Intrinsic type used for the jacobian values has a Dune::FieldMatrix type interface.
Definition: functionspaceinterface.hh:74
FunctionSpaceType::DomainType DomainType
domain type
Definition: shapefunctionset/legendre.hh:45
FunctionSpaceType::RangeType RangeType
range type
Definition: shapefunctionset/legendre.hh:228
FieldVector< FieldMatrix< RangeFieldType, dimDomain, dimDomain >, dimRange > HessianRangeType
Intrinsic type used for the hessian values has a Dune::FieldMatrix type interface.
Definition: functionspaceinterface.hh:78
BaseType::ShapeFunctionType ShapeFunctionType
Definition: shapefunctionset/legendre.hh:349
a Dune::Fem::ShapeFunctionSet of Legendre ansatz polynomials
Definition: shapefunctionset/legendre.hh:216
LegendreShapeFunctionSet(int order)
initialize with polynomial order
Definition: shapefunctionset/legendre.hh:246
void jacobianEach(const Point &x, Functor functor) const noexcept
evalute jacobian of each shape function
Definition: shapefunctionset/legendre.hh:300
HierarchicLegendreShapeFunctionSet(int order)
Definition: shapefunctionset/legendre.hh:373
dimension of domain vector space
Definition: functionspaceinterface.hh:45
void hessian(const DomainType &x, HessianRangeType &hessian) const noexcept
evaluate the hessian of the function
Definition: shapefunctionset/legendre.hh:111
FunctionSpace FunctionSpaceType
function space type
Definition: shapefunctionset/legendre.hh:223
dimension of range vector space
Definition: functionspaceinterface.hh:47
void evaluate(const DomainType &x, RangeType &value) const noexcept
evaluate the function
Definition: shapefunctionset/legendre.hh:90
FunctionSpaceType::DomainType DomainType
domain type
Definition: shapefunctionset/legendre.hh:226
FunctionSpaceType::HessianRangeType HessianRangeType
hessian type
Definition: shapefunctionset/legendre.hh:51
void evaluateEach(const Point &x, Functor functor) const noexcept
evalute each shape function
Definition: shapefunctionset/legendre.hh:287
VectorSpaceTraits< DomainField, RangeField, dimD, dimR >::DomainFieldType DomainFieldType
Intrinsic type used for values in the domain field (usually a double)
Definition: functionspaceinterface.hh:59
void hessianEach(const Point &x, Functor functor) const noexcept
evalute hessian of each shape function
Definition: shapefunctionset/legendre.hh:313
static double jacobian(const int num, const double x)
Definition: legendrepolynomials.hh:34
FunctionSpaceType::JacobianRangeType JacobianRangeType
jacobian range type
Definition: shapefunctionset/legendre.hh:230
void jacobian(const DomainType &x, JacobianRangeType &jacobian) const noexcept
evaluate the Jacobian of the function
Definition: shapefunctionset/legendre.hh:98
Definition: coordinate.hh:4
LegendreShapeFunction< FunctionSpace > ShapeFunctionType
Definition: shapefunctionset/legendre.hh:219
VectorSpaceTraits< DomainField, RangeField, dimD, dimR >::DomainType DomainType
Type of domain vector (using type of domain field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:66
implementation of a single scalar-valued Legendre shape function
Definition: shapefunctionset/legendre.hh:31
LegendreShapeFunctionSet(const Factory &factory)
initialize from user-defined factory object
Definition: shapefunctionset/legendre.hh:270
FunctionSpaceType::DomainFieldType DomainFieldType
field type of domain
Definition: shapefunctionset/legendre.hh:40
std::vector< ShapeFunctionType > shapeFunctions_
Definition: shapefunctionset/legendre.hh:325
static double hessian(const int num, const double x)
Definition: legendrepolynomials.hh:48
Definition: shapefunctionset/legendre.hh:351
Abstract class representing a function.
Definition: function.hh:43
int order_
Definition: shapefunctionset/legendre.hh:326
VectorSpaceTraits< DomainField, RangeField, dimD, dimR >::RangeType RangeType
Type of range vector (using type of range field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:70
std::size_t size() const noexcept
return number of shape functions
Definition: shapefunctionset/legendre.hh:283
int order() const noexcept
return polynomial order of this function
Definition: shapefunctionset/legendre.hh:78
FunctionSpaceType::JacobianRangeType JacobianRangeType
jacobian type
Definition: shapefunctionset/legendre.hh:49
static double evaluate(const int num, const double x)
Definition: legendrepolynomials.hh:24
int order() const noexcept
return order of shape functions
Definition: shapefunctionset/legendre.hh:280
please doc me
Definition: shapefunctionset/legendre.hh:343
static const Point & coordinate(const Point &x)
Definition: coordinate.hh:11
LegendreShapeFunction(const MultiIndex &multiIndex)
Definition: shapefunctionset/legendre.hh:64
FunctionSpace FunctionSpaceType
type of function space this function belongs to
Definition: shapefunctionset/legendre.hh:33