3 #ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_REFINEDLAGRANGEBASIS_HH
4 #define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_REFINEDLAGRANGEBASIS_HH
8 #include <dune/common/exceptions.hh>
9 #include <dune/common/math.hh>
11 #include <dune/localfunctions/refined.hh>
13 #include <dune/functions/functionspacebases/defaultglobalbasis.hh>
14 #include <dune/functions/functionspacebases/leafprebasismappermixin.hh>
15 #include <dune/functions/functionspacebases/nodes.hh>
17 #include <dune/geometry/type.hh>
19 #include <dune/grid/common/mcmgmapper.hh>
25 template<
typename GV,
int k,
typename R>
26 class RefinedLagrangeNode;
39 template <
typename GV,
int k,
typename R =
double>
45 static const int dim = GV::dimension;
48 static_assert(k == 0 || k == 1);
51 static MCMGLayout dofLayout()
55 return [](GeometryType gt, int) ->
size_t {
56 return (gt.dim() == dim) ? (1 << dim) : 0;
58 else if constexpr(k == 1)
60 return [](GeometryType gt, int) ->
size_t {
61 return Dune::binomial(
int(k),
int(gt.dim()));
64 DUNE_THROW(Dune::NotImplemented,
65 "Refined basis not implemented for higher-order Lagrange (k>=2) elements.");
74 using Node = RefinedLagrangeNode<GV, k, R>;
83 :
Base(gv, dofLayout())
85 for (
auto gt : gv.indexSet().types(0)) {
87 DUNE_THROW(Dune::NotImplemented,
88 "Refined Lagrange basis only implemented for simplex grids.");
105 static constexpr
unsigned int order()
113 template <
typename GV,
int k,
typename R>
114 class RefinedLagrangeNode
115 :
public LeafBasisNode
117 static constexpr
int dim = GV::dimension;
120 static_assert(k == 0 || k == 1);
124 using Element =
typename GV::template Codim<0>::Entity;
127 using FiniteElement = std::conditional_t<(k==0),
128 Dune::RefinedP0LocalFiniteElement<typename GV::ctype,R,dim>,
129 Dune::RefinedP1LocalFiniteElement<typename GV::ctype,R,dim>>;
140 RefinedLagrangeNode ()
149 const Element& element ()
const
160 const FiniteElement& finiteElement ()
const
162 return finiteElement_;
166 void bind (
const Element& e)
169 this->setSize(finiteElement_.size());
176 static constexpr
unsigned int order()
182 const FiniteElement finiteElement_;
183 const Element* element_;
188 namespace BasisFactory {
197 template <
int k,
typename R=
double>
200 return [](
const auto& gridView) {
221 template <
typename GV,
int k,
typename R=
double>
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:46
A generic MixIn class for PreBasis with flat indices computed from a mapper.
Definition: leafprebasismappermixin.hh:58
GV GridView
Type of the associated GridView.
Definition: leafprebasismappermixin.hh:64
A pre-basis for a refined Lagrange bases.
Definition: refinedlagrangebasis.hh:42
static constexpr unsigned int order()
Polynomial order used in the local Lagrange finite-elements.
Definition: refinedlagrangebasis.hh:105
Node makeNode() const
Create tree node.
Definition: refinedlagrangebasis.hh:93
RefinedLagrangeNode< GV, k, R > Node
Type of the refined Lagrange tree node.
Definition: refinedlagrangebasis.hh:74
RefinedLagrangePreBasis(const GridView &gv)
Constructor for a given grid view object.
Definition: refinedlagrangebasis.hh:82
auto refinedLagrange()
Create a pre-basis factory that can create a RefinedLagrange pre-basis.
Definition: refinedlagrangebasis.hh:198
Definition: polynomial.hh:13