7#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LAGRANGEDGBASIS_HH
8#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LAGRANGEDGBASIS_HH
11#include <dune/common/exceptions.hh>
12#include <dune/common/math.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()
82 quadrilateralOffset_ = dofsPerTriangle * gridView_.size(Dune::GeometryTypes::triangle);
87 prismOffset_ = dofsPerTetrahedron * gridView_.size(Dune::GeometryTypes::tetrahedron);
89 hexahedronOffset_ = prismOffset_ + dofsPerPrism * gridView_.size(Dune::GeometryTypes::prism);
91 pyramidOffset_ = hexahedronOffset_ + dofsPerHexahedron * gridView_.size(Dune::GeometryTypes::hexahedron);
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);
125 return dofsPerTriangle*gridView_.size(Dune::GeometryTypes::triangle) + dofsPerQuad*gridView_.size(Dune::GeometryTypes::quadrilateral);
129 return dofsPerTetrahedron*gridView_.size(Dune::GeometryTypes::tetrahedron)
130 + dofsPerPyramid*gridView_.size(Dune::GeometryTypes::pyramid)
131 + dofsPerPrism*gridView_.size(Dune::GeometryTypes::prism)
132 + dofsPerHexahedron*gridView_.size(Dune::GeometryTypes::hexahedron);
135 DUNE_THROW(Dune::NotImplemented,
"No size method for " << dim <<
"d grids available yet!");
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);
159 DUNE_THROW(Dune::NotImplemented,
"2d elements have to be triangles or quadrilaterals");
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);
172 DUNE_THROW(Dune::NotImplemented,
"3d elements have to be tetrahedrons, prisms, hexahedrons or pyramids");
175 DUNE_THROW(Dune::NotImplemented,
"No index method for " << dim <<
"d grids available yet!");
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
auto power(ChildPreBasisFactory &&childPreBasisFactory, std::size_t k, const IndexMergingStrategy &)
Create a pre-basis factory that can build a PowerPreBasis.
Definition: dynamicpowerbasis.hh:409
auto lagrangeDG()
Create a pre-basis factory that can create a LagrangeDG pre-basis.
Definition: lagrangedgbasis.hh:208
Definition: polynomial.hh:17