6#ifndef DUNE_PDELAB_FINITEELEMENT_QKDGLEGENDRE_HH
7#define DUNE_PDELAB_FINITEELEMENT_QKDGLEGENDRE_HH
18#include <dune/localfunctions/common/localbasis.hh>
19#include <dune/localfunctions/common/localfiniteelementtraits.hh>
20#include <dune/localfunctions/common/localkey.hh>
21#include <dune/localfunctions/common/localtoglobaladaptors.hh>
26 namespace LegendreStuff
31 template<
int k,
int n>
35 value=(k+1)*LegendreSize<k,n-1>::value
40 struct LegendreSize<0,1>
48 struct LegendreSize<k,1>
56 struct LegendreSize<0,n>
63 template<
int k,
int d>
67 for (
int j=0; j<d; j++)
76 template<
class D,
class R,
int k>
81 void p (D x, std::vector<R>& value)
const
86 for (
int n=2; n<=k; n++)
87 value[n] = ((2*n-1)*(2*x-1)*value[n-1]-(n-1)*value[n-2])/n;
91 R
p (
int i, D x)
const
93 std::vector<R> v(k+1);
99 void dp (D x, std::vector<R>&
derivative)
const
107 for (
int n=2; n<=k; n++)
109 value[n] = ((2*n-1)*(2*x-1)*value[n-1]-(n-1)*value[n-2])/n;
115 void pdp (D x, std::vector<R>& value, std::vector<R>&
derivative)
const
123 for (
int n=2; n<=k; n++)
125 value[n] = ((2*n-1)*(2*x-1)*value[n-1]-(n-1)*value[n-2])/n;
131 R dp (
int i, D x)
const
133 std::vector<R> v(k+1);
139 template<
class D,
class R>
140 class LegendrePolynomials1d<D,R,0>
144 void p (D x, std::vector<R>& value)
const
151 R
p (
int i, D x)
const
157 void dp (D x, std::vector<R>&
derivative)
const
164 R dp (
int i, D x)
const
170 void pdp (D x, std::vector<R>& value, std::vector<R>&
derivative)
const
179 template<
class D,
class R>
180 class LegendrePolynomials1d<D,R,1>
184 void p (D x, std::vector<R>& value)
const
192 R
p (
int i, D x)
const
194 return (1-i) + i*(2*x-1);
198 void dp (D x, std::vector<R>&
derivative)
const
206 R dp (
int i, D x)
const
208 return (1-i)*0 + i*(2);
212 void pdp (D x, std::vector<R>& value, std::vector<R>&
derivative)
const
235 template<
class D,
class R,
int k,
int d>
238 enum { n = LegendreSize<k,d>::value };
240 mutable std::vector<std::vector<R> > v;
241 mutable std::vector<std::vector<R> > a;
244 typedef LocalBasisTraits<D,d,Dune::FieldVector<D,d>,R,1,
Dune::FieldVector<R,1>,
Dune::FieldMatrix<R,1,d> >
Traits;
257 std::vector<typename Traits::RangeType>& value)
const
263 for (
size_t j=0; j<d; j++) poly.p(x[j],v[j]);
266 for (
size_t i=0; i<n; i++)
275 for (
int j=0; j<d; j++) value[i] *= v[j][alpha[j]];
282 std::vector<typename Traits::JacobianType>& value)
const
285 value.resize(
size());
288 for (
size_t j=0; j<d; j++) poly.pdp(x[j],v[j],a[j]);
291 for (
size_t i=0; i<n; i++)
297 for (
int j=0; j<d; j++)
300 value[i][0][j] = a[j][alpha[j]];
303 for (
int l=0; l<d; l++)
305 value[i][0][j] *= v[l][alpha[l]];
313 std::vector<typename Traits::RangeType>& out)
const {
315 if (totalOrder == 0) {
331 template<
class D,
class R,
int k,
int d>
334 enum { n = LegendreSize<k,d>::value };
345 template<
typename F,
typename C>
356 std::vector<R> diagonal(n);
357 for (
int i=0; i<n; i++) { out[i] = 0.0; diagonal[i] = 0.0; }
361 it=rule.begin(); it!=rule.end(); ++it)
366 for (
int i=0; i<d; i++) x[i] = it->position()[i];
370 std::vector<RangeType> phi(n);
374 for (
int i=0; i<n; i++) {
375 out[i] += y*phi[i]*it->weight();
376 diagonal[i] += phi[i]*phi[i]*it->weight();
379 for (
int i=0; i<n; i++) out[i] /= diagonal[i];
389 template<
int k,
int d>
392 enum { n = LegendreSize<k,d>::value };
398 for (std::size_t i=0; i<n; i++)
415 std::vector<LocalKey> li;
422 template<
class D,
class R,
int k,
int d>
431 enum { n = LegendreStuff::LegendreSize<k,d>::value };
440 : gt(GeometryTypes::
cube(d))
461 return interpolation;
485 LocalCoefficients coefficients;
486 LocalInterpolation interpolation;
496 template<
class Geometry,
class RF,
int k>
499 QkDGLegendreLocalFiniteElement<
500 typename Geometry::ctype, RF, k, Geometry::mydimension
510 static const LFE lfe;
517 template<
class Geometry,
class RF,
int k>
518 const typename QkDGLegendreFiniteElementFactory<Geometry, RF, k>::LFE
519 QkDGLegendreFiniteElementFactory<Geometry, RF, k>::lfe;
A dense n x m matrix.
Definition: fmatrix.hh:117
vector space out of a tensor product of fields.
Definition: fvector.hh:97
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
GridImp::ctype ctype
define type used for coordinates in grid module
Definition: geometry.hh:100
static constexpr int mydimension
geometry dimension
Definition: geometry.hh:94
Lagrange shape functions of order k on the reference cube.
Definition: qkdglegendre.hh:237
unsigned int size() const
number of shape functions
Definition: qkdglegendre.hh:250
void evaluateFunction(const typename Traits::DomainType &x, std::vector< typename Traits::RangeType > &value) const
Evaluate all shape functions.
Definition: qkdglegendre.hh:256
void evaluateJacobian(const typename Traits::DomainType &x, std::vector< typename Traits::JacobianType > &value) const
Evaluate Jacobian of all shape functions.
Definition: qkdglegendre.hh:281
void partial(const std::array< unsigned int, Traits::dimDomain > &order, const typename Traits::DomainType &in, std::vector< typename Traits::RangeType > &out) const
Evaluate partial derivative of all shape functions.
Definition: qkdglegendre.hh:311
unsigned int order() const
Polynomial order of the shape functions.
Definition: qkdglegendre.hh:323
Layout map for Q1 elements.
Definition: qkdglegendre.hh:391
DGLegendreLocalCoefficients()
Standard constructor.
Definition: qkdglegendre.hh:396
std::size_t size() const
number of coefficients
Definition: qkdglegendre.hh:403
const LocalKey & localKey(std::size_t i) const
get i'th index
Definition: qkdglegendre.hh:409
determine degrees of freedom
Definition: qkdglegendre.hh:333
void interpolate(const F &f, std::vector< C > &out) const
Local interpolation of a function.
Definition: qkdglegendre.hh:346
The 1d Legendre Polynomials (k=0,1 are specialized below)
Definition: qkdglegendre.hh:78
void p(D x, std::vector< R > &value) const
evaluate all polynomials at point x
Definition: qkdglegendre.hh:81
Describe position of one degree of freedom.
Definition: localkey.hh:24
Default exception for dummy implementations.
Definition: exceptions.hh:357
Factory for global-valued DGLegendre elements.
Definition: qkdglegendre.hh:504
QkDGLegendreFiniteElementFactory()
default constructor
Definition: qkdglegendre.hh:514
Definition: qkdglegendre.hh:424
const Traits::LocalCoefficientsType & localCoefficients() const
Definition: qkdglegendre.hh:452
LocalFiniteElementTraits< LocalBasis, LocalCoefficients, LocalInterpolation > Traits
Definition: qkdglegendre.hh:435
const Traits::LocalInterpolationType & localInterpolation() const
Definition: qkdglegendre.hh:459
GeometryType type() const
Definition: qkdglegendre.hh:473
std::size_t size() const
Definition: qkdglegendre.hh:466
const Traits::LocalBasisType & localBasis() const
Definition: qkdglegendre.hh:445
QkDGLegendreLocalFiniteElement()
Definition: qkdglegendre.hh:439
Abstract base class for quadrature rules.
Definition: quadraturerules.hh:214
static const QuadratureRule & rule(const GeometryType &t, int p, QuadratureType::Enum qt=QuadratureType::GaussLegendre)
select the appropriate QuadratureRule for GeometryType t and order p
Definition: quadraturerules.hh:326
Factory for ScalarLocalToGlobalFiniteElementAdaptor objects.
Definition: localtoglobaladaptors.hh:244
Definition of the DUNE_NO_DEPRECATED_* macros.
Implements a vector constructed from a given type representing a field and a compile-time given size.
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
TrigonometricFunction< K, -cosFactor, sinFactor > derivative(const TrigonometricFunction< K, sinFactor, cosFactor > &f)
Obtain derivative of TrigonometricFunction function.
Definition: trigonometricfunction.hh:43
constexpr GeometryType cube(unsigned int dim)
Returns a GeometryType representing a hypercube of dimension dim.
Definition: type.hh:462
constexpr T accumulate(Range &&range, T value, F &&f)
Accumulate values.
Definition: hybridutilities.hh:280
Dune namespace.
Definition: alignedallocator.hh:13
Type traits for LocalBasisVirtualInterface.
Definition: localbasis.hh:35
D DomainType
domain type
Definition: localbasis.hh:43
R RangeType
range type
Definition: localbasis.hh:52
traits helper struct
Definition: localfiniteelementtraits.hh:13
LB LocalBasisType
Definition: localfiniteelementtraits.hh:16
LC LocalCoefficientsType
Definition: localfiniteelementtraits.hh:20
LI LocalInterpolationType
Definition: localfiniteelementtraits.hh:24
A unique label for each type of element that can occur in a grid.