3#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_HIERARCHICALLAGRANGEBASIS_HH
4#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_HIERARCHICALLAGRANGEBASIS_HH
6#include <dune/common/exceptions.hh>
7#include <dune/localfunctions/hierarchical/hierarchicalp2.hh>
9#include <dune/functions/functionspacebases/nodes.hh>
10#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
11#include <dune/grid/common/mcmgmapper.hh>
32 template<
typename GV,
int k,
typename R=
double>
33 class HierarchicalLagrangeNode;
35 template<
typename GV,
int k,
typename R=
double>
36 class HierarchicalLagrangePreBasis;
47 template<
typename GV,
int k,
typename R>
50 static const int dim = GV::dimension;
61 using Node = HierarchicalLagrangeNode<GV, k, R>;
63 static constexpr size_type maxMultiIndexSize = 1;
64 static constexpr size_type minMultiIndexSize = 1;
65 static constexpr size_type multiIndexBufferSize = 1;
88 mcmgMapper_.update(gv);
102 return mcmgMapper_.size();
106 template<
class SizePrefix>
109 assert(prefix.size() == 0 || prefix.size() == 1);
110 return (prefix.size() == 0) ?
size() : 0;
126 return Dune::binomial(std::size_t(order() + (
unsigned int)GV::dimension),std::size_t(order()));
129 template<
typename It>
130 It indices(
const Node& node, It it)
const
132 for (
size_type i = 0, end = node.finiteElement().size() ; i < end ; ++it, ++i)
134 Dune::LocalKey localKey = node.finiteElement().localCoefficients().localKey(i);
135 const auto& element = node.element();
137 *it = {{ (
size_type)(mcmgMapper_.subIndex(element,localKey.subEntity(),localKey.codim())) }};
145 unsigned int order()
const
150 MultipleCodimMultipleGeomTypeMapper<GridView> mcmgMapper_;
157 static auto p2Layout()
159 return [](Dune::GeometryType type,
int gridDim)
165 if (type.isTriangle())
167 assert(type.isTetrahedron());
175 template<
typename GV,
int k,
typename R>
176 class HierarchicalLagrangeNode :
179 static const int dim = GV::dimension;
183 using size_type = std::size_t;
184 using Element =
typename GV::template Codim<0>::Entity;
185 using FiniteElement = HierarchicalP2LocalFiniteElement<typename GV::ctype,R,dim>;
187 HierarchicalLagrangeNode() :
193 const Element& element()
const
202 const FiniteElement& finiteElement()
const
204 return finiteElement_;
208 void bind(
const Element& e)
212 if (e.type() != finiteElement_.type())
213 DUNE_THROW(Dune::Exception,
214 "HierarchicalLagrange-elements do not exist for elements of type " << e.type());
216 this->setSize(finiteElement_.size());
221 unsigned int order()
const
226 const FiniteElement finiteElement_;
227 const Element* element_;
232 namespace BasisFactory {
242 template<std::
size_t k,
typename R=
double>
245 return [](
const auto& gridView) {
262 template<
typename GV,
int k,
typename R=
double>
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:46
A pre-basis for a hierarchical basis.
Definition: hierarchicallagrangebasis.hh:49
std::size_t size_type
Type used for indices and size information.
Definition: hierarchicallagrangebasis.hh:58
Node makeNode() const
Create tree node.
Definition: hierarchicallagrangebasis.hh:94
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition: hierarchicallagrangebasis.hh:123
void update(const GridView &gv)
Update the stored grid view & MultipleCodimMultipleGeomTypeMapper, to be called if the grid has chang...
Definition: hierarchicallagrangebasis.hh:85
HierarchicalLagrangeNode< GV, k, R > Node
Template mapping root tree path to type of created tree node.
Definition: hierarchicallagrangebasis.hh:61
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: hierarchicallagrangebasis.hh:114
GV GridView
The grid view that the FE basis is defined on.
Definition: hierarchicallagrangebasis.hh:55
HierarchicalLagrangePreBasis(const GridView &gv)
Constructor for a given grid view object with layout for second order.
Definition: hierarchicallagrangebasis.hh:71
size_type size(const SizePrefix prefix) const
Return number of possible values for next position in multi index.
Definition: hierarchicallagrangebasis.hh:107
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: hierarchicallagrangebasis.hh:79
size_type size() const
Same as size(prefix) with empty prefix.
Definition: hierarchicallagrangebasis.hh:100
void initializeIndices()
Initialize the global indices.
Definition: hierarchicallagrangebasis.hh:75
auto hierarchicalLagrange()
Create a pre-basis factory that can create a HierarchicalLagrange pre-basis.
Definition: hierarchicallagrangebasis.hh:243
Definition: polynomial.hh:10