Dune Core Modules (2.9.0)

rannacherturekbasis.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_RANNACHERTUREKBASIS_HH
4#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_RANNACHERTUREKBASIS_HH
5
7
9
10#include <dune/localfunctions/common/localfiniteelementvariant.hh>
12#include <dune/localfunctions/crouzeixraviart.hh>
13
14#include <dune/functions/functionspacebases/nodes.hh>
15#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
16
17
18namespace Dune {
19namespace Functions {
20
21// *****************************************************************************
22// This is the reusable part of the basis. It contains
23//
24// RannacherTurekPreBasis
25// RannacherTurekNode
26//
27// The pre-basis allows to create the others and is the owner of possible shared
28// state. These components do _not_ depend on the global basis and local view
29// and can be used without a global basis.
30// *****************************************************************************
31
32template<typename GV>
33class RannacherTurekNode;
34
35template<typename GV>
36class RannacherTurekPreBasis;
37
50template<typename GV>
52{
53 static const int dim = GV::dimension;
54
55public:
56
58 using GridView = GV;
59
61 using size_type = std::size_t;
62
64 using Node = RannacherTurekNode<GV>;
65
66 static constexpr size_type maxMultiIndexSize = 1;
67 static constexpr size_type minMultiIndexSize = 1;
68 static constexpr size_type multiIndexBufferSize = 1;
69
72 gridView_(gv)
73 {
74 for(auto type : gv.indexSet().types(0))
75 if (!type.isSimplex() && !type.isCube())
76 DUNE_THROW(Dune::NotImplemented, "Rannacher-Turek or Crouzeix-Raviart elements are only implemented for grids with simplex or cube elements.");
77 }
78
81 {}
82
84 const GridView& gridView() const
85 {
86 return gridView_;
87 }
88
90 void update (const GridView& gv)
91 {
92 gridView_ = gv;
93 }
94
98 Node makeNode() const
99 {
100 return Node{};
101 }
102
105 {
106 return (size_type)(gridView_.size(1));
107 }
108
110 template<class SizePrefix>
111 size_type size(const SizePrefix prefix) const
112 {
113 assert(prefix.size() == 0 || prefix.size() == 1);
114 return (prefix.size() == 0) ? size() : 0;
115 }
116
119 {
120 return size();
121 }
122
125 {
126 return 2*GV::dimension;
127 }
128
129 template<typename It>
130 It indices(const Node& node, It it) const
131 {
132 for (size_type i = 0, end = node.size() ; i < end ; ++i, ++it)
133 {
134 Dune::LocalKey localKey = node.finiteElement().localCoefficients().localKey(i);
135 const auto& gridIndexSet = gridView().indexSet();
136 const auto& element = node.element();
137
138 *it = {{ (size_type)(gridIndexSet.subIndex(element,localKey.subEntity(),1)) }};
139 }
140 return it;
141 }
142
143protected:
144 GridView gridView_;
145};
146
147
148
149template<typename GV>
150class RannacherTurekNode :
151 public LeafBasisNode
152{
153 static const int dim = GV::dimension;
154 static const int maxSize = 2*dim;
155
156 constexpr static bool hasFixedElementType = Capabilities::hasSingleGeometryType<typename GV::Grid>::v;
157
158 using CubeFiniteElement = RannacherTurekLocalFiniteElement<typename GV::ctype,double,dim>;
159 using SimplexFiniteElement = CrouzeixRaviartLocalFiniteElement<typename GV::ctype,double,dim>;
160
161 constexpr static unsigned int topologyId = Capabilities::hasSingleGeometryType<typename GV::Grid>::topologyId; // meaningless if hasFixedElementType is false
162 constexpr static GeometryType type = GeometryType(topologyId, GV::dimension);
163
164public:
165
166 using size_type = std::size_t;
167 using Element = typename GV::template Codim<0>::Entity;
168 using FiniteElement = std::conditional_t<hasFixedElementType,
169 std::conditional_t<type.isCube(),CubeFiniteElement,SimplexFiniteElement>,
170 LocalFiniteElementVariant<CubeFiniteElement, SimplexFiniteElement> >;
171
172 RannacherTurekNode() :
173 finiteElement_(),
174 element_(nullptr)
175 {}
176
178 const Element& element() const
179 {
180 return *element_;
181 }
182
187 const FiniteElement& finiteElement() const
188 {
189 return finiteElement_;
190 }
191
193 void bind(const Element& e)
194 {
195 element_ = &e;
196 if constexpr (!hasFixedElementType)
197 finiteElement_ = e.type().isCube() ? static_cast<FiniteElement>(CubeFiniteElement())
198 : static_cast<FiniteElement>(SimplexFiniteElement()) ;
199 this->setSize(finiteElement_.size());
200 }
201
202protected:
203
204 FiniteElement finiteElement_;
205 const Element* element_;
206};
207
208
209
210namespace BasisFactory {
211
217template<class Dummy=void>
219{
220 return [](const auto& gridView) {
221 return RannacherTurekPreBasis<std::decay_t<decltype(gridView)>>(gridView);
222 };
223}
224
225} // end namespace BasisFactory
226
227
228
229
241template<typename GV>
243
244} // end namespace Functions
245} // end namespace Dune
246
247#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_RANNACHERTUREKBASIS_HH
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:46
Pre-basis for a Rannacher-Turek basis.
Definition: rannacherturekbasis.hh:52
void initializeIndices()
Initialize the global indices.
Definition: rannacherturekbasis.hh:80
size_type size(const SizePrefix prefix) const
Return number of possible values for next position in multi index.
Definition: rannacherturekbasis.hh:111
std::size_t size_type
Type used for indices and size information.
Definition: rannacherturekbasis.hh:61
Node makeNode() const
Create tree node.
Definition: rannacherturekbasis.hh:98
void update(const GridView &gv)
Update the stored grid view, to be called if the grid has changed.
Definition: rannacherturekbasis.hh:90
GV GridView
The grid view that the FE basis is defined on.
Definition: rannacherturekbasis.hh:58
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: rannacherturekbasis.hh:118
RannacherTurekPreBasis(const GridView &gv)
Constructor for a given grid view object.
Definition: rannacherturekbasis.hh:71
RannacherTurekNode< GV > Node
Template mapping root tree path to type of created tree node.
Definition: rannacherturekbasis.hh:64
size_type size() const
Same as size(prefix) with empty prefix.
Definition: rannacherturekbasis.hh:104
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: rannacherturekbasis.hh:84
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition: rannacherturekbasis.hh:124
Describe position of one degree of freedom.
Definition: localkey.hh:23
unsigned int subEntity() const
Return number of associated subentity.
Definition: localkey.hh:56
Default exception for dummy implementations.
Definition: exceptions.hh:263
A few common exception classes.
A set of traits classes to store static information about grid implementation.
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
auto rannacherTurek()
Create a pre-basis factory that can create a Rannacher-Turek pre-basis.
Definition: rannacherturekbasis.hh:218
Dune namespace.
Definition: alignedallocator.hh:13
Convenience header that includes all available Rannacher-Turek LocalFiniteElements.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)