7#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_REFINEDLAGRANGEBASIS_HH
8#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_REFINEDLAGRANGEBASIS_HH
12#include <dune/common/exceptions.hh>
13#include <dune/common/math.hh>
15#include <dune/localfunctions/refined.hh>
17#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
18#include <dune/functions/functionspacebases/leafprebasismappermixin.hh>
19#include <dune/functions/functionspacebases/nodes.hh>
21#include <dune/geometry/type.hh>
23#include <dune/grid/common/mcmgmapper.hh>
29template<
typename GV,
int k,
typename R>
30class RefinedLagrangeNode;
43template <
typename GV,
int k,
typename R =
double>
49 static const int dim = GV::dimension;
52 static_assert(k == 0 || k == 1);
55 static MCMGLayout dofLayout()
59 return [](GeometryType gt,
int) ->
size_t {
60 return (gt.dim() == dim) ? (1 << dim) : 0;
62 else if constexpr(k == 1)
64 return [](GeometryType gt,
int) ->
size_t {
65 return Dune::binomial(
int(k),
int(gt.dim()));
68 DUNE_THROW(Dune::NotImplemented,
69 "Refined basis not implemented for higher-order Lagrange (k>=2) elements.");
78 using Node = RefinedLagrangeNode<GV, k, R>;
87 :
Base(gv, dofLayout())
89 for (
auto gt : gv.indexSet().types(0)) {
91 DUNE_THROW(Dune::NotImplemented,
92 "Refined Lagrange basis only implemented for simplex grids.");
109 static constexpr unsigned int order()
117template <
typename GV,
int k,
typename R>
118class RefinedLagrangeNode
119 :
public LeafBasisNode
121 static constexpr int dim = GV::dimension;
124 static_assert(k == 0 || k == 1);
128 using Element =
typename GV::template Codim<0>::Entity;
131 using FiniteElement = std::conditional_t<(k==0),
132 Dune::RefinedP0LocalFiniteElement<typename GV::ctype,R,dim>,
133 Dune::RefinedP1LocalFiniteElement<typename GV::ctype,R,dim>>;
144 RefinedLagrangeNode ()
153 const Element& element ()
const
164 const FiniteElement& finiteElement ()
const
166 return finiteElement_;
170 void bind (
const Element& e)
173 this->setSize(finiteElement_.size());
180 static constexpr unsigned int order()
186 const FiniteElement finiteElement_;
187 const Element* element_;
192namespace BasisFactory {
201template <
int k,
typename R=
double>
204 return [](
const auto& gridView) {
225template <
typename GV,
int k,
typename R=
double>
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:50
A generic MixIn class for PreBasis with flat indices computed from a mapper.
Definition: leafprebasismappermixin.hh:62
GV GridView
Type of the associated GridView.
Definition: leafprebasismappermixin.hh:68
A pre-basis for a refined Lagrange bases.
Definition: refinedlagrangebasis.hh:46
static constexpr unsigned int order()
Polynomial order used in the local Lagrange finite-elements.
Definition: refinedlagrangebasis.hh:109
Node makeNode() const
Create tree node.
Definition: refinedlagrangebasis.hh:97
RefinedLagrangeNode< GV, k, R > Node
Type of the refined Lagrange tree node.
Definition: refinedlagrangebasis.hh:78
RefinedLagrangePreBasis(const GridView &gv)
Constructor for a given grid view object.
Definition: refinedlagrangebasis.hh:86
auto refinedLagrange()
Create a pre-basis factory that can create a RefinedLagrange pre-basis.
Definition: refinedlagrangebasis.hh:202
Definition: monomialset.hh:19