7#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LAGRANGEDGBASIS_HH
8#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LAGRANGEDGBASIS_HH
14#include <dune/functions/functionspacebases/nodes.hh>
15#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
16#include <dune/functions/functionspacebases/lagrangebasis.hh>
17#include <dune/functions/functionspacebases/leafprebasismixin.hh>
38template<
typename GV,
int k>
39using LagrangeDGNode = LagrangeNode<GV, k>;
41template<
typename GV,
int k>
42class LagrangeDGPreBasis :
43 public LeafPreBasisMixin< LagrangeDGPreBasis<GV,k> >
45 static const int dim = GV::dimension;
51 using size_type = std::size_t;
55 const static int dofsPerEdge = k+1;
56 const static int dofsPerTriangle = (k+1)*(k+2)/2;
57 const static int dofsPerQuad = (k+1)*(k+1);
58 const static int dofsPerTetrahedron = (k+1)*(k+2)*(k+3)/6;
59 const static int dofsPerPrism = (k+1)*(k+1)*(k+2)/2;
60 const static int dofsPerHexahedron = (k+1)*(k+1)*(k+1);
61 const static int dofsPerPyramid = (k+1)*(k+2)*(2*k+3)/6;
64 using Node = LagrangeDGNode<GV, k>;
67 LagrangeDGPreBasis(
const GridView& gv) :
72 void initializeIndices()
99 const GridView& gridView()
const
104 void update(
const GridView& gv)
112 Node makeNode()
const
117 size_type dimension()
const
122 return dofsPerEdge*gridView_.size(0);
138 size_type maxNodeSize()
const
143 template<
typename It>
144 It indices(
const Node& node, It it)
const
146 const auto& gridIndexSet = gridView().indexSet();
147 const auto& element = node.element();
149 size_type offset = 0;
150 if constexpr (dim==1)
151 offset = dofsPerEdge*gridIndexSet.subIndex(element,0,0);
152 else if constexpr (dim==2)
154 if (element.type().isTriangle())
155 offset = dofsPerTriangle*gridIndexSet.subIndex(element,0,0);
156 else if (element.type().isQuadrilateral())
157 offset = quadrilateralOffset_ + dofsPerQuad*gridIndexSet.subIndex(element,0,0);
161 else if constexpr (dim==3)
163 if (element.type().isTetrahedron())
164 offset = dofsPerTetrahedron*gridIndexSet.subIndex(element,0,0);
165 else if (element.type().isPrism())
166 offset = prismOffset_ + dofsPerPrism*gridIndexSet.subIndex(element,0,0);
167 else if (element.type().isHexahedron())
168 offset = hexahedronOffset_ + dofsPerHexahedron*gridIndexSet.subIndex(element,0,0);
169 else if (element.type().isPyramid())
170 offset = pyramidOffset_ + dofsPerPyramid*gridIndexSet.subIndex(element,0,0);
176 for (size_type i = 0, end = node.size() ; i < end ; ++i, ++it)
182 unsigned int order()
const
190 size_t quadrilateralOffset_;
191 size_t pyramidOffset_;
193 size_t hexahedronOffset_;
198namespace BasisFactory {
207template<std::
size_t k>
210 return [](
const auto& gridView) {
211 return LagrangeDGPreBasis<std::decay_t<
decltype(gridView)>, k>(gridView);
230template<
typename GV,
int k>
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:50
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:208
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