3#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LAGRANGEDGBASIS_HH
4#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LAGRANGEDGBASIS_HH
10#include <dune/functions/functionspacebases/nodes.hh>
11#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
12#include <dune/functions/functionspacebases/lagrangebasis.hh>
13#include <dune/functions/functionspacebases/leafprebasismixin.hh>
34template<
typename GV,
int k>
35using LagrangeDGNode = LagrangeNode<GV, k>;
37template<
typename GV,
int k>
38class LagrangeDGPreBasis :
39 public LeafPreBasisMixin< LagrangeDGPreBasis<GV,k> >
41 static const int dim = GV::dimension;
47 using size_type = std::size_t;
51 const static int dofsPerEdge = k+1;
52 const static int dofsPerTriangle = (k+1)*(k+2)/2;
53 const static int dofsPerQuad = (k+1)*(k+1);
54 const static int dofsPerTetrahedron = (k+1)*(k+2)*(k+3)/6;
55 const static int dofsPerPrism = (k+1)*(k+1)*(k+2)/2;
56 const static int dofsPerHexahedron = (k+1)*(k+1)*(k+1);
57 const static int dofsPerPyramid = (k+1)*(k+2)*(2*k+3)/6;
60 using Node = LagrangeDGNode<GV, k>;
63 LagrangeDGPreBasis(
const GridView& gv) :
68 void initializeIndices()
95 const GridView& gridView()
const
100 void update(
const GridView& gv)
108 Node makeNode()
const
113 size_type dimension()
const
118 return dofsPerEdge*gridView_.size(0);
134 size_type maxNodeSize()
const
139 template<
typename It>
140 It indices(
const Node& node, It it)
const
142 const auto& gridIndexSet = gridView().indexSet();
143 const auto& element = node.element();
145 size_type offset = 0;
146 if constexpr (dim==1)
147 offset = dofsPerEdge*gridIndexSet.subIndex(element,0,0);
148 else if constexpr (dim==2)
150 if (element.type().isTriangle())
151 offset = dofsPerTriangle*gridIndexSet.subIndex(element,0,0);
152 else if (element.type().isQuadrilateral())
153 offset = quadrilateralOffset_ + dofsPerQuad*gridIndexSet.subIndex(element,0,0);
157 else if constexpr (dim==3)
159 if (element.type().isTetrahedron())
160 offset = dofsPerTetrahedron*gridIndexSet.subIndex(element,0,0);
161 else if (element.type().isPrism())
162 offset = prismOffset_ + dofsPerPrism*gridIndexSet.subIndex(element,0,0);
163 else if (element.type().isHexahedron())
164 offset = hexahedronOffset_ + dofsPerHexahedron*gridIndexSet.subIndex(element,0,0);
165 else if (element.type().isPyramid())
166 offset = pyramidOffset_ + dofsPerPyramid*gridIndexSet.subIndex(element,0,0);
172 for (size_type i = 0, end = node.size() ; i < end ; ++i, ++it)
178 unsigned int order()
const
186 size_t quadrilateralOffset_;
187 size_t pyramidOffset_;
189 size_t hexahedronOffset_;
194namespace BasisFactory {
203template<std::
size_t k>
206 return [](
const auto& gridView) {
207 return LagrangeDGPreBasis<std::decay_t<
decltype(gridView)>, k>(gridView);
226template<
typename GV,
int k>
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:46
Default exception for dummy implementations.
Definition: exceptions.hh:263
A few common exception classes.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
auto lagrangeDG()
Create a pre-basis factory that can create a LagrangeDG pre-basis.
Definition: lagrangedgbasis.hh:204
constexpr GeometryType prism
GeometryType representing a 3D prism.
Definition: type.hh:528
constexpr GeometryType triangle
GeometryType representing a triangle.
Definition: type.hh:504
constexpr GeometryType quadrilateral
GeometryType representing a quadrilateral (a square).
Definition: type.hh:510
constexpr GeometryType hexahedron
GeometryType representing a hexahedron.
Definition: type.hh:534
constexpr GeometryType pyramid
GeometryType representing a 3D pyramid.
Definition: type.hh:522
constexpr GeometryType tetrahedron
GeometryType representing a tetrahedron.
Definition: type.hh:516
Some useful basic math stuff.
Dune namespace.
Definition: alignedallocator.hh:13
constexpr Base power(Base m, Exponent p)
Power method for integer exponents.
Definition: math.hh:75