4 #ifndef DUNE_PDELAB_FINITEELEMENT_QKDGLOBATTO_HH 5 #define DUNE_PDELAB_FINITEELEMENT_QKDGLOBATTO_HH 9 #include <dune/localfunctions/common/localbasis.hh> 10 #include <dune/localfunctions/common/localkey.hh> 11 #include <dune/localfunctions/common/localfiniteelementtraits.hh> 12 #include <dune/localfunctions/common/localtoglobaladaptors.hh> 20 template<
class D,
class R,
int k>
31 for (
int order=1; order<=40; order++)
33 const Dune::QuadratureRule<D,1>& rule = Dune::QuadratureRules<D,1>::rule(Dune::GeometryType::cube,order,Dune::QuadratureType::GaussLobatto);
36 matched_order = order;
37 matched_size = rule.size();
42 if (matched_order<0) DUNE_THROW(Dune::Exception,
"could not find Gauss Lobatto rule of appropriate size");
43 const Dune::QuadratureRule<D,1>& rule = Dune::QuadratureRules<D,1>::rule(Dune::GeometryType::cube,matched_order,Dune::QuadratureType::GaussLobatto);
45 for (
typename Dune::QuadratureRule<D,1>::const_iterator it=rule.begin(); it!=rule.end(); ++it)
48 size_t member=count%2;
50 if (member==1) newj=group;
else newj=k-group;
51 xi_gl[newj] = it->position()[0];
52 w_gl[newj] = it->weight();
55 for (
int j=0; j<matched_size/2; j++)
59 xi_gl[j] = xi_gl[k-j];
73 R
p (
int i, D
x)
const 76 for (
int j=0; j<=k; j++)
77 if (j!=i) result *= (
x-xi_gl[j])/(xi_gl[i]-xi_gl[j]);
82 R
dp (
int i, D
x)
const 86 for (
int j=0; j<=k; j++)
89 R prod( 1.0/(xi_gl[i]-xi_gl[j]) );
90 for (
int l=0; l<=k; l++)
91 if (l!=i && l!=j) prod *= (
x-xi_gl[l])/(xi_gl[i]-xi_gl[l]);
122 template<
class D,
class R,
int k,
int d>
129 typedef LocalBasisTraits<D,d,Dune::FieldVector<D,d>,R,1,Dune::FieldVector<R,1>,Dune::FieldMatrix<R,1,d> >
Traits;
139 std::vector<typename Traits::RangeType>& out)
const 142 for (
size_t i=0; i<
size(); i++)
145 Dune::FieldVector<int,d> alpha(multiindex<k,d>(i));
151 for (
int j=0; j<d; j++)
152 out[i] *= poly.
p(alpha[j],in[j]);
159 std::vector<typename Traits::JacobianType>& out)
const 164 for (
size_t i=0; i<
size(); i++)
167 Dune::FieldVector<int,d> alpha(multiindex<k,d>(i));
170 for (
int j=0; j<d; j++)
174 out[i][0][j] = poly.
dp(alpha[j],in[j]);
177 for (
int l=0; l<d; l++)
179 out[i][0][j] *= poly.
p(alpha[l],in[l]);
185 void partial(
const std::array<unsigned int, Traits::dimDomain>& DUNE_UNUSED(
order),
186 const typename Traits::DomainType& DUNE_UNUSED(in),
187 std::vector<typename Traits::RangeType>& DUNE_UNUSED(out))
const {
188 auto totalOrder = std::accumulate(
order.begin(),
order.end(), 0);
189 if (totalOrder == 0) {
192 DUNE_THROW(NotImplemented,
"Desired derivative order is not implemented");
204 template<
int k,
int d,
class LB>
212 template<
typename F,
typename C>
215 typename LB::Traits::DomainType x;
216 typename LB::Traits::RangeType y;
223 Dune::FieldVector<int,d> alpha(multiindex<k,d>(i));
226 for (
int j=0; j<d; j++)
227 x[j] = poly.
x(alpha[j]);
229 f.evaluate(x,y); out[i] = y;
235 template<
int d,
class LB>
240 template<
typename F,
typename C>
243 typename LB::Traits::DomainType x(0.5);
244 typename LB::Traits::RangeType y;
255 template<
class D,
class R,
int k,
int d>
268 typedef LocalFiniteElementTraits<LocalBasis,LocalCoefficients,LocalInterpolation>
Traits;
273 : gt(GeometryTypes::cube(d))
294 return interpolation;
318 LocalCoefficients coefficients;
319 LocalInterpolation interpolation;
329 template<
class Geometry,
class RF,
int k>
331 public ScalarLocalToGlobalFiniteElementAdaptorFactory<
332 QkDGGLLocalFiniteElement<
333 typename Geometry::ctype, RF, k, Geometry::mydimension
339 typename Geometry::ctype, RF, k, Geometry::mydimension
341 typedef ScalarLocalToGlobalFiniteElementAdaptorFactory<LFE, Geometry> Base;
343 static const LFE lfe;
350 template<
class Geometry,
class RF,
int k>
351 const typename QkDGGLFiniteElementFactory<Geometry, RF, k>::LFE
352 QkDGGLFiniteElementFactory<Geometry, RF, k>::lfe;
356 #endif // DUNE_PDELAB_FINITEELEMENT_QKDGLOBATTO_HH Definition: qkdglobatto.hh:256
static const unsigned int value
Definition: gridfunctionspace/tags.hh:139
Lagrange shape functions of order k on the reference cube.
Definition: qkdglobatto.hh:123
const Traits::LocalCoefficientsType & localCoefficients() const
Definition: qkdglobatto.hh:285
LocalBasisTraits< D, d, Dune::FieldVector< D, d >, R, 1, Dune::FieldVector< R, 1 >, Dune::FieldMatrix< R, 1, d > > Traits
Definition: qkdglobatto.hh:129
QkDGGLFiniteElementFactory()
default constructor
Definition: qkdglobatto.hh:347
R x(int i) const
Definition: qkdglobatto.hh:98
LocalFiniteElementTraits< LocalBasis, LocalCoefficients, LocalInterpolation > Traits
Definition: qkdglobatto.hh:268
const Traits::LocalBasisType & localBasis() const
Definition: qkdglobatto.hh:278
Layout map for Q1 elements.
Definition: qkdglagrange.hh:229
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
void evaluateJacobian(const typename Traits::DomainType &in, std::vector< typename Traits::JacobianType > &out) const
Evaluate Jacobian of all shape functions.
Definition: qkdglobatto.hh:158
std::size_t size() const
Definition: qkdglobatto.hh:299
R dp(int i, D x) const
Definition: qkdglobatto.hh:82
void partial(const std::array< unsigned int, Traits::dimDomain > &DUNE_UNUSED(order), const typename Traits::DomainType &DUNE_UNUSED(in), std::vector< typename Traits::RangeType > &DUNE_UNUSED(out)) const
Evaluate partial derivative of all shape functions.
Definition: qkdglobatto.hh:185
unsigned int size() const
number of shape functions
Definition: qkdglobatto.hh:132
Definition: qkdglobatto.hh:264
GaussLobattoLagrangePolynomials()
Definition: qkdglobatto.hh:27
R p(int i, D x) const
Definition: qkdglobatto.hh:73
unsigned int order() const
Polynomial order of the shape functions.
Definition: qkdglobatto.hh:197
R w(int i) const
Definition: qkdglobatto.hh:104
Lagrange polynomials at Gauss-Lobatto points.
Definition: qkdglobatto.hh:21
Factory for global-valued QkDG elements.
Definition: qkdglobatto.hh:330
GeometryType type() const
Definition: qkdglobatto.hh:306
const Traits::LocalInterpolationType & localInterpolation() const
Definition: qkdglobatto.hh:292
void interpolate(const F &f, std::vector< C > &out) const
Local interpolation of a function.
Definition: qkdglobatto.hh:241
void evaluateFunction(const typename Traits::DomainType &in, std::vector< typename Traits::RangeType > &out) const
Evaluate all shape functions.
Definition: qkdglobatto.hh:138
Definition: qkdglagrange.hh:23
Definition: qkdglobatto.hh:205
QkDGGLLocalFiniteElement()
Definition: qkdglobatto.hh:272
QkDGGLLocalFiniteElement * clone() const
Definition: qkdglobatto.hh:311
void interpolate(const F &f, std::vector< C > &out) const
Local interpolation of a function.
Definition: qkdglobatto.hh:213