3#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LAGRANGEDGBASIS_HH
4#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LAGRANGEDGBASIS_HH
7#include <dune/common/exceptions.hh>
9#include <dune/functions/functionspacebases/nodes.hh>
10#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
11#include <dune/functions/functionspacebases/flatmultiindex.hh>
12#include <dune/functions/functionspacebases/lagrangebasis.hh>
33template<
typename GV,
int k>
34using LagrangeDGNode = LagrangeNode<GV, k>;
36template<
typename GV,
int k,
class MI>
37class LagrangeDGPreBasis
39 static const int dim = GV::dimension;
45 using size_type = std::size_t;
49 const static int dofsPerEdge = k+1;
50 const static int dofsPerTriangle = (k+1)*(k+2)/2;
51 const static int dofsPerQuad = (k+1)*(k+1);
52 const static int dofsPerTetrahedron = (k+1)*(k+2)*(k+3)/6;
53 const static int dofsPerPrism = (k+1)*(k+1)*(k+2)/2;
54 const static int dofsPerHexahedron = (k+1)*(k+1)*(k+1);
55 const static int dofsPerPyramid = (k+1)*(k+2)*(2*k+3)/6;
58 using Node = LagrangeDGNode<GV, k>;
61 using IndexSet = Impl::DefaultNodeIndexSet<LagrangeDGPreBasis>;
64 using MultiIndex = MI;
66 using SizePrefix = Dune::ReservedVector<size_type, 1>;
69 LagrangeDGPreBasis(
const GridView& gv) :
74 void initializeIndices()
84 quadrilateralOffset_ = dofsPerTriangle * gridView_.size(Dune::GeometryTypes::triangle);
89 prismOffset_ = dofsPerTetrahedron * gridView_.size(Dune::GeometryTypes::tetrahedron);
91 hexahedronOffset_ = prismOffset_ + dofsPerPrism * gridView_.size(Dune::GeometryTypes::prism);
93 pyramidOffset_ = hexahedronOffset_ + dofsPerHexahedron * gridView_.size(Dune::GeometryTypes::hexahedron);
101 const GridView& gridView()
const
106 void update(
const GridView& gv)
114 Node makeNode()
const
126 [[deprecated(
"Warning: The IndexSet typedef and the makeIndexSet method are deprecated. "\
127 "As a replacement use the indices() method of the PreBasis directly.")]]
128 IndexSet makeIndexSet()
const
130 return IndexSet{*
this};
133 size_type size()
const
138 return dofsPerEdge*gridView_.size(0);
141 return dofsPerTriangle*gridView_.size(Dune::GeometryTypes::triangle) + dofsPerQuad*gridView_.size(Dune::GeometryTypes::quadrilateral);
145 return dofsPerTetrahedron*gridView_.size(Dune::GeometryTypes::tetrahedron)
146 + dofsPerPyramid*gridView_.size(Dune::GeometryTypes::pyramid)
147 + dofsPerPrism*gridView_.size(Dune::GeometryTypes::prism)
148 + dofsPerHexahedron*gridView_.size(Dune::GeometryTypes::hexahedron);
151 DUNE_THROW(Dune::NotImplemented,
"No size method for " << dim <<
"d grids available yet!");
155 size_type size(
const SizePrefix prefix)
const
157 assert(prefix.size() == 0 || prefix.size() == 1);
158 return (prefix.size() == 0) ? size() : 0;
162 size_type dimension()
const
167 size_type maxNodeSize()
const
169 return StaticPower<(k+1),GV::dimension>
::power;
172 template<
typename It>
173 It indices(
const Node& node, It it)
const
175 const auto& gridIndexSet = gridView().indexSet();
176 const auto& element = node.element();
178 for (size_type i = 0, end = node.size() ; i < end ; ++i, ++it)
184 *it = {dofsPerEdge*gridIndexSet.subIndex(element,0,0) + i};
189 if (element.type().isTriangle())
191 *it = {dofsPerTriangle*gridIndexSet.subIndex(element,0,0) + i};
194 else if (element.type().isQuadrilateral())
196 *it = { quadrilateralOffset_ + dofsPerQuad*gridIndexSet.subIndex(element,0,0) + i};
200 DUNE_THROW(Dune::NotImplemented,
"2d elements have to be triangles or quadrilaterals");
204 if (element.type().isTetrahedron())
206 *it = {dofsPerTetrahedron*gridIndexSet.subIndex(element,0,0) + i};
209 else if (element.type().isPrism())
211 *it = { prismOffset_ + dofsPerPrism*gridIndexSet.subIndex(element,0,0) + i};
214 else if (element.type().isHexahedron())
216 *it = { hexahedronOffset_ + dofsPerHexahedron*gridIndexSet.subIndex(element,0,0) + i};
219 else if (element.type().isPyramid())
221 *it = { pyramidOffset_ + dofsPerPyramid*gridIndexSet.subIndex(element,0,0) + i};
225 DUNE_THROW(Dune::NotImplemented,
"3d elements have to be tetrahedrons, prisms, hexahedrons or pyramids");
228 DUNE_THROW(Dune::NotImplemented,
"No index method for " << dim <<
"d grids available yet!");
237 size_t quadrilateralOffset_;
238 size_t pyramidOffset_;
240 size_t hexahedronOffset_;
245namespace BasisFactory {
249template<std::
size_t k>
250class LagrangeDGPreBasisFactory
253 static const std::size_t requiredMultiIndexSize = 1;
255 template<
class MultiIndex,
class Gr
idView>
256 auto makePreBasis(
const GridView& gridView)
const
258 return LagrangeDGPreBasis<GridView, k, MultiIndex>(gridView);
274template<std::
size_t k>
277 return Imp::LagrangeDGPreBasisFactory<k>();
295template<
typename GV,
int k>
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:47
auto power(ChildPreBasisFactory &&childPreBasisFactory, const IndexMergingStrategy &ims)
Create a pre-basis factory that can build a PowerPreBasis.
Definition: powerbasis.hh:425
auto lagrangeDG()
Create a pre-basis factory that can create a LagrangeDG pre-basis.
Definition: lagrangedgbasis.hh:275
Definition: polynomial.hh:10