Dune-Functions 2.11
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;
86
87 // Precompute the number of dofs per entity type
88 [[deprecated("This constant will be removed after Dune 2.11")]] const static int dofsPerEdge = k+1;
89 [[deprecated("This constant will be removed after Dune 2.11")]] const static int dofsPerTriangle = (k+1)*(k+2)/2;
90 [[deprecated("This constant will be removed after Dune 2.11")]] const static int dofsPerQuad = (k+1)*(k+1);
91 [[deprecated("This constant will be removed after Dune 2.11")]] const static int dofsPerTetrahedron = (k+1)*(k+2)*(k+3)/6;
92 [[deprecated("This constant will be removed after Dune 2.11")]] const static int dofsPerPrism = (k+1)*(k+1)*(k+2)/2;
93 [[deprecated("This constant will be removed after Dune 2.11")]] const static int dofsPerHexahedron = (k+1)*(k+1)*(k+1);
94 [[deprecated("This constant will be removed after Dune 2.11")]] const static int dofsPerPyramid = (k+1)*(k+2)*(2*k+3)/6;
95
97
105 requires(k>=0)
106 : Base(gv, dofLayout(k))
107 , order_(k)
108 {}
109
116 LagrangeDGPreBasis(const GridView& gv, unsigned int order)
117 requires(k<0)
118 : Base(gv, dofLayout(order))
119 , order_(order)
120 {}
121
126 {
127 return Node{order_};
128 }
129
130 template<class Node, class It>
131 It indices(const Node& node, It it) const
132 {
133 size_type elementOffset = Base::mapper_.index(node.element());
134 for(auto i : Dune::range(node.size()))
135 {
136 *it = {{ (size_type)(elementOffset+i) }};
137 ++it;
138 }
139 return it;
140 }
141
143 unsigned int order() const
144 {
145 return (useDynamicOrder) ? order_ : k;
146 }
147
148protected:
149
150 unsigned int order_;
151};
152
153
154
155namespace BasisFactory {
156
165template<std::size_t order, typename R=double>
167{
168 return [](const auto& gridView) {
169 return LagrangeDGPreBasis<std::decay_t<decltype(gridView)>, order, R>(gridView);
170 };
171}
172
181template<typename R=double>
182auto lagrangeDG(unsigned int order)
183{
184 return [order](const auto& gridView) {
185 return LagrangeDGPreBasis<std::decay_t<decltype(gridView)>, -1, R>(gridView, order);
186 };
187}
188
189} // end namespace BasisFactory
190
191
192
193// *****************************************************************************
194// This is the actual global basis implementation based on the reusable parts.
195// *****************************************************************************
196
205template<typename GV, int k=-1, typename R=double>
207
208
209
210} // end namespace Functions
211} // end namespace Dune
212
213
214#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LAGRANGEDGBASIS_HH
auto lagrangeDG()
Create a pre-basis factory that can create a LagrangeDG pre-basis.
Definition lagrangedgbasis.hh:166
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:379
const Element & element() const
Return current element, throw if unbound.
Definition lagrangebasis.hh:427
PreBasis implementation for a Lagrangean-DG finite element space.
Definition lagrangedgbasis.hh:51
Node makeNode() const
Create tree node.
Definition lagrangedgbasis.hh:125
LagrangeDGPreBasis(const GridView &gv, unsigned int order)
Constructor for a given grid view object.
Definition lagrangedgbasis.hh:116
static const int dofsPerPrism
Definition lagrangedgbasis.hh:92
static const int dofsPerQuad
Definition lagrangedgbasis.hh:90
static const int dofsPerTriangle
Definition lagrangedgbasis.hh:89
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:143
static const int dofsPerPyramid
Definition lagrangedgbasis.hh:94
LagrangeDGPreBasis(const GridView &gv)
Constructor for a given grid view object.
Definition lagrangedgbasis.hh:104
static const int dofsPerHexahedron
Definition lagrangedgbasis.hh:93
It indices(const Node &node, It it) const
Definition lagrangedgbasis.hh:131
static const int dofsPerEdge
Definition lagrangedgbasis.hh:88
unsigned int order_
Definition lagrangedgbasis.hh:150
static const int dofsPerTetrahedron
Definition lagrangedgbasis.hh:91
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:162