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/flatmultiindex.hh>
11#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
12#include <dune/grid/common/mcmgmapper.hh>
33 template<
typename GV,
int k,
typename R=
double>
34 class HierarchicalLagrangeNode;
36 template<
typename GV,
int k,
class MI,
typename R=
double>
37 class HierarchicalLagrangePreBasis;
49 template<
typename GV,
int k,
class MI,
typename R>
52 static const int dim = GV::dimension;
63 using Node = HierarchicalLagrangeNode<GV, k, R>;
66 using IndexSet = Impl::DefaultNodeIndexSet<HierarchicalLagrangePreBasis>;
95 mcmgMapper_.update(gv);
120 return mcmgMapper_.size();
126 assert(prefix.size() == 0 || prefix.size() == 1);
127 return (prefix.size() == 0) ?
size() : 0;
143 return Dune::binomial(std::size_t(order() + (
unsigned int)GV::dimension),std::size_t(order()));
146 template<
typename It>
147 It indices(
const Node& node, It it)
const
149 for (
size_type i = 0, end = node.finiteElement().size() ; i < end ; ++it, ++i)
151 Dune::LocalKey localKey = node.finiteElement().localCoefficients().localKey(i);
152 const auto& element = node.element();
154 *it = {{ (
size_type)(mcmgMapper_.subIndex(element,localKey.subEntity(),localKey.codim())) }};
162 unsigned int order()
const
167 MultipleCodimMultipleGeomTypeMapper<GridView> mcmgMapper_;
174 static auto p2Layout()
176 return [](Dune::GeometryType type,
int gridDim)
182 if (type.isTriangle())
184 assert(type.isTetrahedron());
192 template<
typename GV,
int k,
typename R>
193 class HierarchicalLagrangeNode :
196 static const int dim = GV::dimension;
200 using size_type = std::size_t;
201 using Element =
typename GV::template Codim<0>::Entity;
202 using FiniteElement = HierarchicalP2LocalFiniteElement<typename GV::ctype,R,dim>;
204 HierarchicalLagrangeNode() :
210 const Element& element()
const
219 const FiniteElement& finiteElement()
const
221 return finiteElement_;
225 void bind(
const Element& e)
229 if (e.type() != finiteElement_.type())
230 DUNE_THROW(Dune::Exception,
231 "HierarchicalLagrange-elements do not exist for elements of type " << e.type());
233 this->setSize(finiteElement_.size());
238 unsigned int order()
const
243 const FiniteElement finiteElement_;
244 const Element* element_;
249 namespace BasisFactory {
253 template<
int k,
typename R=
double>
254 class HierarchicalLagrangePreBasisFactory
258 static const std::size_t requiredMultiIndexSize = 1;
260 template<
class MultiIndex,
class Gr
idView>
261 auto makePreBasis(
const GridView& gridView)
const
263 return HierarchicalLagrangePreBasis<GridView, k, MultiIndex, R>(gridView);
278 template<std::
size_t k,
typename R=
double>
281 return Impl::HierarchicalLagrangePreBasisFactory<k,R>();
296 template<
typename GV,
int k,
typename R=
double>
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:47
A pre-basis for a hierarchical basis.
Definition: hierarchicallagrangebasis.hh:51
size_type size() const
Same as size(prefix) with empty prefix.
Definition: hierarchicallagrangebasis.hh:118
MI MultiIndex
Type used for global numbering of the basis vectors.
Definition: hierarchicallagrangebasis.hh:69
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: hierarchicallagrangebasis.hh:86
Impl::DefaultNodeIndexSet< HierarchicalLagrangePreBasis > IndexSet
Type of created tree node index set.
Definition: hierarchicallagrangebasis.hh:66
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition: hierarchicallagrangebasis.hh:140
size_type size(const SizePrefix prefix) const
Return number of possible values for next position in multi index.
Definition: hierarchicallagrangebasis.hh:124
Node makeNode() const
Create tree node.
Definition: hierarchicallagrangebasis.hh:101
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: hierarchicallagrangebasis.hh:131
HierarchicalLagrangePreBasis(const GridView &gv)
Constructor for a given grid view object with layout for second order.
Definition: hierarchicallagrangebasis.hh:78
Dune::ReservedVector< size_type, 1 > SizePrefix
Type used for prefixes handed to the size() method.
Definition: hierarchicallagrangebasis.hh:72
GV GridView
The grid view that the FE basis is defined on.
Definition: hierarchicallagrangebasis.hh:57
IndexSet makeIndexSet() const
Create tree node index set.
Definition: hierarchicallagrangebasis.hh:112
void initializeIndices()
Initialize the global indices.
Definition: hierarchicallagrangebasis.hh:82
std::size_t size_type
Type used for indices and size information.
Definition: hierarchicallagrangebasis.hh:60
void update(const GridView &gv)
Update the stored grid view & MultipleCodimMultipleGeomTypeMapper, to be called if the grid has chang...
Definition: hierarchicallagrangebasis.hh:92
HierarchicalLagrangeNode< GV, k, R > Node
Template mapping root tree path to type of created tree node.
Definition: hierarchicallagrangebasis.hh:63
auto hierarchicalLagrange()
Create a pre-basis factory that can create a HierarchicalLagrange pre-basis.
Definition: hierarchicallagrangebasis.hh:279
Definition: polynomial.hh:10