Dune-Functions 2.12-git
Loading...
Searching...
No Matches
lagrangedgbasis.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
5// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
6
7#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LAGRANGEDGBASIS_HH
8#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LAGRANGEDGBASIS_HH
9
11#include <dune/common/math.hh>
12
17
18
19
20
21namespace Dune {
22namespace Functions {
23
24
25
26// *****************************************************************************
27// This is the reusable part of the basis. It contains
28//
29// LagrangeDGPreBasis
30// LagrangeDGNode
31//
32// The pre-basis allows to create the others and is the owner of possible shared
33// state. These components do _not_ depend on the global basis and local view
34// and can be used without a global basis.
35// *****************************************************************************
36
37template<typename GV, int k, typename R=double>
39
48template<typename GV, int k, typename R=double>
51{
53
54 static constexpr bool useDynamicOrder = (k<0);
55
56 static MCMGLayout dofLayout(int order)
57 {
58 return [order](Dune::GeometryType type, size_t dimGrid) {
59 if (type.dim() == dimGrid)
60 {
61 if (type.isLine())
62 return order+1;
63 if (type.isTriangle())
64 return (order+1)*(order+2)/2;
65 if (type.isQuadrilateral())
66 return (order+1)*(order+1);
67 if (type.isTetrahedron())
68 return (order+1)*(order+2)*(order+3)/6;
69 if (type.isPrism())
70 return (order+1)*(order+1)*(order+2)/2;
71 if (type.isHexahedron())
72 return (order+1)*(order+1)*(order+1);
73 if (type.isPyramid())
74 return (order+1)*(order+2)*(2*order+3)/6;
75 DUNE_THROW(Dune::NotImplemented, "Using LagrangeDGPreBasis with non-supported GeometryType");
76 }
77 return 0;
78 };
79 }
80
81public:
82
84 using GridView = GV;
85 using size_type = typename Base::size_type;
87
95 requires(k>=0)
96 : Base(gv, dofLayout(k))
97 , order_(k)
98 {}
99
106 LagrangeDGPreBasis(const GridView& gv, unsigned int order)
107 requires(k<0)
108 : Base(gv, dofLayout(order))
109 , order_(order)
110 {}
111
116 {
117 return Node{order_};
118 }
119
120 template<class Node, class It>
121 It indices(const Node& node, It it) const
122 {
123 size_type elementOffset = Base::mapper_.index(node.element());
124 for(auto i : Dune::range(node.size()))
125 {
126 *it = {{ (size_type)(elementOffset+i) }};
127 ++it;
128 }
129 return it;
130 }
131
133 unsigned int order() const
134 {
135 return (useDynamicOrder) ? order_ : k;
136 }
137
138protected:
139
140 unsigned int order_;
141};
142
143
144
145namespace BasisFactory {
146
155template<std::size_t order, typename R=double>
157{
158 return [](const auto& gridView) {
159 return LagrangeDGPreBasis<std::decay_t<decltype(gridView)>, order, R>(gridView);
160 };
161}
162
171template<typename R=double>
172auto lagrangeDG(unsigned int order)
173{
174 return [order](const auto& gridView) {
175 return LagrangeDGPreBasis<std::decay_t<decltype(gridView)>, -1, R>(gridView, order);
176 };
177}
178
179} // end namespace BasisFactory
180
181
182
183// *****************************************************************************
184// This is the actual global basis implementation based on the reusable parts.
185// *****************************************************************************
186
195template<typename GV, int k=-1, typename R=double>
197
198
199
200} // end namespace Functions
201} // end namespace Dune
202
203
204#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LAGRANGEDGBASIS_HH
auto lagrangeDG()
Create a pre-basis factory that can create a LagrangeDG pre-basis.
Definition lagrangedgbasis.hh:156
static constexpr IntegralRange< std::decay_t< T > > range(T &&from, U &&to) noexcept
#define DUNE_THROW(E,...)
constexpr bool isPyramid() const
constexpr bool isTetrahedron() const
constexpr bool isPrism() const
constexpr unsigned int dim() const
constexpr bool isTriangle() const
constexpr bool isLine() const
constexpr bool isQuadrilateral() const
constexpr bool isHexahedron() const
Index index(const EntityType &e) const
Global basis for given pre-basis.
Definition defaultglobalbasis.hh:53
Definition lagrangebasis.hh:896
const Element & element() const
Return current element, throw if unbound.
Definition lagrangebasis.hh:965
PreBasis implementation for a Lagrangean-DG finite element space.
Definition lagrangedgbasis.hh:51
Node makeNode() const
Create tree node.
Definition lagrangedgbasis.hh:115
LagrangeDGPreBasis(const GridView &gv, unsigned int order)
Constructor for a given grid view object.
Definition lagrangedgbasis.hh:106
typename Base::size_type size_type
Definition lagrangedgbasis.hh:85
unsigned int order() const
Polynomial order used in the local Lagrange finite-elements.
Definition lagrangedgbasis.hh:133
LagrangeDGPreBasis(const GridView &gv)
Constructor for a given grid view object.
Definition lagrangedgbasis.hh:94
It indices(const Node &node, It it) const
Definition lagrangedgbasis.hh:121
unsigned int order_
Definition lagrangedgbasis.hh:140
GV GridView
The grid view that the FE space is defined on.
Definition lagrangedgbasis.hh:84
A generic MixIn class for PreBasis with flat indices computed from a mapper.
Definition leafprebasismappermixin.hh:62
Dune::MultipleCodimMultipleGeomTypeMapper< GridView > mapper_
Definition leafprebasismappermixin.hh:133
std::size_t size_type
Type used for index digits.
Definition leafprebasismappermixin.hh:71
size_type size() const
Obtain the number of basis function in the local node.
Definition nodes.hh:158