DUNE PDELab (git)

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/leafprebasismixin.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>
37class RannacherTurekPreBasis;
38
51template<typename GV>
53 public LeafPreBasisMixin< RannacherTurekPreBasis<GV> >
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
70 gridView_(gv)
71 {
72 for(auto type : gv.indexSet().types(0))
73 if (!type.isSimplex() && !type.isCube())
74 DUNE_THROW(Dune::NotImplemented, "Rannacher-Turek or Crouzeix-Raviart elements are only implemented for grids with simplex or cube elements.");
75 }
76
79 {}
80
82 const GridView& gridView() const
83 {
84 return gridView_;
85 }
86
88 void update (const GridView& gv)
89 {
90 gridView_ = gv;
91 }
92
96 Node makeNode() const
97 {
98 return Node{};
99 }
100
103 {
104 return (size_type)(gridView_.size(1));
105 }
106
109 {
110 return 2*GV::dimension;
111 }
112
113 template<typename It>
114 It indices(const Node& node, It it) const
115 {
116 for (size_type i = 0, end = node.size() ; i < end ; ++i, ++it)
117 {
118 Dune::LocalKey localKey = node.finiteElement().localCoefficients().localKey(i);
119 const auto& gridIndexSet = gridView().indexSet();
120 const auto& element = node.element();
121
122 *it = {{ (size_type)(gridIndexSet.subIndex(element,localKey.subEntity(),1)) }};
123 }
124 return it;
125 }
126
127protected:
128 GridView gridView_;
129};
130
131
132
133template<typename GV>
134class RannacherTurekNode :
135 public LeafBasisNode
136{
137 static const int dim = GV::dimension;
138 static const int maxSize = 2*dim;
139
140 constexpr static bool hasFixedElementType = Capabilities::hasSingleGeometryType<typename GV::Grid>::v;
141
142 using CubeFiniteElement = RannacherTurekLocalFiniteElement<typename GV::ctype,double,dim>;
143 using SimplexFiniteElement = CrouzeixRaviartLocalFiniteElement<typename GV::ctype,double,dim>;
144
145 constexpr static unsigned int topologyId = Capabilities::hasSingleGeometryType<typename GV::Grid>::topologyId; // meaningless if hasFixedElementType is false
146 constexpr static GeometryType type = GeometryType(topologyId, GV::dimension);
147
148public:
149
150 using size_type = std::size_t;
151 using Element = typename GV::template Codim<0>::Entity;
152 using FiniteElement = std::conditional_t<hasFixedElementType,
153 std::conditional_t<type.isCube(),CubeFiniteElement,SimplexFiniteElement>,
154 LocalFiniteElementVariant<CubeFiniteElement, SimplexFiniteElement> >;
155
156 RannacherTurekNode() :
157 finiteElement_(),
158 element_(nullptr)
159 {}
160
162 const Element& element() const
163 {
164 return *element_;
165 }
166
171 const FiniteElement& finiteElement() const
172 {
173 return finiteElement_;
174 }
175
177 void bind(const Element& e)
178 {
179 element_ = &e;
180 if constexpr (!hasFixedElementType)
181 finiteElement_ = e.type().isCube() ? static_cast<FiniteElement>(CubeFiniteElement())
182 : static_cast<FiniteElement>(SimplexFiniteElement()) ;
183 this->setSize(finiteElement_.size());
184 }
185
186protected:
187
188 FiniteElement finiteElement_;
189 const Element* element_;
190};
191
192
193
194namespace BasisFactory {
195
201template<class Dummy=void>
203{
204 return [](const auto& gridView) {
205 return RannacherTurekPreBasis<std::decay_t<decltype(gridView)>>(gridView);
206 };
207}
208
209} // end namespace BasisFactory
210
211
212
213
225template<typename GV>
227
228} // end namespace Functions
229} // end namespace Dune
230
231#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_RANNACHERTUREKBASIS_HH
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:46
A generic MixIn class for PreBasis.
Definition: leafprebasismixin.hh:32
Pre-basis for a Rannacher-Turek basis.
Definition: rannacherturekbasis.hh:54
void initializeIndices()
Initialize the global indices.
Definition: rannacherturekbasis.hh:78
std::size_t size_type
Type used for indices and size information.
Definition: rannacherturekbasis.hh:63
Node makeNode() const
Create tree node.
Definition: rannacherturekbasis.hh:96
void update(const GridView &gv)
Update the stored grid view, to be called if the grid has changed.
Definition: rannacherturekbasis.hh:88
GV GridView
The grid view that the FE basis is defined on.
Definition: rannacherturekbasis.hh:60
size_type dimension() const
Same as size(prefix) with empty prefix.
Definition: rannacherturekbasis.hh:102
RannacherTurekPreBasis(const GridView &gv)
Constructor for a given grid view object.
Definition: rannacherturekbasis.hh:69
RannacherTurekNode< GV > Node
Template mapping root tree path to type of created tree node.
Definition: rannacherturekbasis.hh:66
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: rannacherturekbasis.hh:82
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition: rannacherturekbasis.hh:108
Describe position of one degree of freedom.
Definition: localkey.hh:24
constexpr unsigned int subEntity() const noexcept
Return number of associated subentity.
Definition: localkey.hh:56
Default exception for dummy implementations.
Definition: exceptions.hh:263
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: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:202
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 (Jul 15, 22:36, 2024)