Dune Core Modules (2.8.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#include <dune/functions/functionspacebases/flatmultiindex.hh>
17
18
19namespace Dune {
20namespace Functions {
21
22// *****************************************************************************
23// This is the reusable part of the basis. It contains
24//
25// RannacherTurekPreBasis
26// RannacherTurekNode
27//
28// The pre-basis allows to create the others and is the owner of possible shared
29// state. These components do _not_ depend on the global basis and local view
30// and can be used without a global basis.
31// *****************************************************************************
32
33template<typename GV>
34class RannacherTurekNode;
35
36template<typename GV, class MI>
37class RannacherTurekPreBasis;
38
52template<typename GV, class MI>
54{
55 static const int dim = GV::dimension;
56
57public:
58
60 using GridView = GV;
61
63 using size_type = std::size_t;
64
66 using Node = RannacherTurekNode<GV>;
67
69 using IndexSet = Impl::DefaultNodeIndexSet<RannacherTurekPreBasis>;
70
72 using MultiIndex = MI;
73
76
79 gridView_(gv)
80 {
81 for(auto type : gv.indexSet().types(0))
82 if (!type.isSimplex() && !type.isCube())
83 DUNE_THROW(Dune::NotImplemented, "Rannacher-Turek or Crouzeix-Raviart elements are only implemented for grids with simplex or cube elements.");
84 }
85
88 {}
89
91 const GridView& gridView() const
92 {
93 return gridView_;
94 }
95
97 void update (const GridView& gv)
98 {
99 gridView_ = gv;
100 }
101
106 {
107 return Node{};
108 }
109
117 [[deprecated("Warning: The IndexSet typedef and the makeIndexSet method are deprecated. "\
118 "As a replacement use the indices() method of the PreBasis directly.")]]
120 {
121 return IndexSet{*this};
122 }
123
126 {
127 return (size_type)(gridView_.size(1));
128 }
129
131 size_type size(const SizePrefix prefix) const
132 {
133 assert(prefix.size() == 0 || prefix.size() == 1);
134 return (prefix.size() == 0) ? size() : 0;
135 }
136
139 {
140 return size();
141 }
142
145 {
146 return 2*GV::dimension;
147 }
148
149 template<typename It>
150 It indices(const Node& node, It it) const
151 {
152 for (size_type i = 0, end = node.size() ; i < end ; ++i, ++it)
153 {
154 Dune::LocalKey localKey = node.finiteElement().localCoefficients().localKey(i);
155 const auto& gridIndexSet = gridView().indexSet();
156 const auto& element = node.element();
157
158 *it = {{ (size_type)(gridIndexSet.subIndex(element,localKey.subEntity(),1)) }};
159 }
160 return it;
161 }
162
163protected:
164 GridView gridView_;
165};
166
167
168
169template<typename GV>
170class RannacherTurekNode :
171 public LeafBasisNode
172{
173 static const int dim = GV::dimension;
174 static const int maxSize = 2*dim;
175
176 constexpr static bool hasFixedElementType = Capabilities::hasSingleGeometryType<typename GV::Grid>::v;
177
178 using CubeFiniteElement = RannacherTurekLocalFiniteElement<typename GV::ctype,double,dim>;
179 using SimplexFiniteElement = CrouzeixRaviartLocalFiniteElement<typename GV::ctype,double,dim>;
180
181 constexpr static unsigned int topologyId = Capabilities::hasSingleGeometryType<typename GV::Grid>::topologyId; // meaningless if hasFixedElementType is false
182 constexpr static GeometryType type = GeometryType(topologyId, GV::dimension);
183
184public:
185
186 using size_type = std::size_t;
187 using Element = typename GV::template Codim<0>::Entity;
188 using FiniteElement = std::conditional_t<hasFixedElementType,
189 std::conditional_t<type.isCube(),CubeFiniteElement,SimplexFiniteElement>,
190 LocalFiniteElementVariant<CubeFiniteElement, SimplexFiniteElement> >;
191
192 RannacherTurekNode() :
193 finiteElement_(),
194 element_(nullptr)
195 {}
196
198 const Element& element() const
199 {
200 return *element_;
201 }
202
207 const FiniteElement& finiteElement() const
208 {
209 return finiteElement_;
210 }
211
213 void bind(const Element& e)
214 {
215 element_ = &e;
216 if constexpr (!hasFixedElementType)
217 finiteElement_ = e.type().isCube() ? static_cast<FiniteElement>(CubeFiniteElement())
218 : static_cast<FiniteElement>(SimplexFiniteElement()) ;
219 this->setSize(finiteElement_.size());
220 }
221
222protected:
223
224 FiniteElement finiteElement_;
225 const Element* element_;
226};
227
228
229
230namespace BasisFactory {
231
232namespace Imp {
233
234template<class Dummy=void>
235class RannacherTurekPreBasisFactory
236{
237public:
238 static const std::size_t requiredMultiIndexSize = 1;
239
240 template<class MultiIndex, class GridView>
241 auto makePreBasis(const GridView& gridView) const
242 {
243 return RannacherTurekPreBasis<GridView, MultiIndex>(gridView);
244 }
245
246};
247
248} // end namespace BasisFactory::Imp
249
250
251
257template<class Dummy=void>
259{
260 return Imp::RannacherTurekPreBasisFactory<void>();
261}
262
263} // end namespace BasisFactory
264
265
266
267
279template<typename GV>
281
282} // end namespace Functions
283} // end namespace Dune
284
285#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_RANNACHERTUREKBASIS_HH
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:47
Pre-basis for a Rannacher-Turek basis.
Definition: rannacherturekbasis.hh:54
Impl::DefaultNodeIndexSet< RannacherTurekPreBasis > IndexSet
Type of created tree node index set.
Definition: rannacherturekbasis.hh:69
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition: rannacherturekbasis.hh:144
IndexSet makeIndexSet() const
Create tree node index set.
Definition: rannacherturekbasis.hh:119
std::size_t size_type
Type used for indices and size information.
Definition: rannacherturekbasis.hh:63
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: rannacherturekbasis.hh:138
GV GridView
The grid view that the FE basis is defined on.
Definition: rannacherturekbasis.hh:60
size_type size() const
Same as size(prefix) with empty prefix.
Definition: rannacherturekbasis.hh:125
RannacherTurekNode< GV > Node
Template mapping root tree path to type of created tree node.
Definition: rannacherturekbasis.hh:66
MI MultiIndex
Type used for global numbering of the basis vectors.
Definition: rannacherturekbasis.hh:72
size_type size(const SizePrefix prefix) const
Return number of possible values for next position in multi index.
Definition: rannacherturekbasis.hh:131
void update(const GridView &gv)
Update the stored grid view, to be called if the grid has changed.
Definition: rannacherturekbasis.hh:97
Node makeNode() const
Create tree node.
Definition: rannacherturekbasis.hh:105
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: rannacherturekbasis.hh:91
void initializeIndices()
Initialize the global indices.
Definition: rannacherturekbasis.hh:87
RannacherTurekPreBasis(const GridView &gv)
Constructor for a given grid view object.
Definition: rannacherturekbasis.hh:78
Describe position of one degree of freedom.
Definition: localkey.hh:21
unsigned int subEntity() const
Return number of associated subentity.
Definition: localkey.hh:54
Default exception for dummy implementations.
Definition: exceptions.hh:261
A Vector class with statically reserved memory.
Definition: reservedvector.hh:43
size_type size() const
Returns number of elements in the vector.
Definition: reservedvector.hh:184
A set of traits classes to store static information about grid implementation.
A few common exception classes.
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:130
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
auto rannacherTurek()
Create a pre-basis factory that can create a Rannacher-Turek pre-basis.
Definition: rannacherturekbasis.hh:258
Dune namespace.
Definition: alignedallocator.hh:11
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 (Nov 21, 23:30, 2024)