3#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_RANNACHERTUREKBASIS_HH
4#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_RANNACHERTUREKBASIS_HH
10#include <dune/typetree/leafnode.hh>
12#include <dune/functions/functionspacebases/nodes.hh>
13#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
14#include <dune/functions/functionspacebases/flatmultiindex.hh>
33class RannacherTurekNode;
35template<
typename GV,
class MI>
36class RannacherTurekNodeIndexSet;
38template<
typename GV,
class MI>
39class RannacherTurekPreBasis;
54template<
typename GV,
class MI>
57 static const int dim = GV::dimension;
68 using Node = RannacherTurekNode<GV>;
71 using IndexSet = RannacherTurekNodeIndexSet<GV, MI>;
128 assert(prefix.
size() == 0 || prefix.
size() == 1);
129 return (prefix.
size() == 0) ?
size() : 0;
141 return 2*GV::dimension;
151class RannacherTurekNode :
154 static const int dim = GV::dimension;
155 static const int maxSize = 2*dim;
159 using size_type = std::size_t;
163 RannacherTurekNode() :
169 const Element& element()
const
178 const FiniteElement& finiteElement()
const
180 return finiteElement_;
184 void bind(
const Element& e)
188 if (e.type() != finiteElement_.type())
190 "Rannacher-Turek elements do not exist for elements of type " << e.type());
192 this->setSize(finiteElement_.size());
197 const FiniteElement finiteElement_;
198 const Element* element_;
203template<
typename GV,
class MI>
204class RannacherTurekNodeIndexSet
206 enum {dim = GV::dimension};
210 using size_type = std::size_t;
213 using MultiIndex = MI;
215 using PreBasis = RannacherTurekPreBasis<GV, MI>;
217 using Node = RannacherTurekNode<GV>;
219 RannacherTurekNodeIndexSet(
const PreBasis& preBasis) :
228 void bind(
const Node& node)
242 size_type size()
const
244 return (size_type)(node_->finiteElement().size());
248 template<
typename It>
249 It indices(It it)
const
251 for (size_type i = 0, end = size() ; i < end ; ++i, ++it)
253 Dune::LocalKey localKey = node_->finiteElement().localCoefficients().localKey(i);
254 const auto& gridIndexSet = preBasis_->gridView().indexSet();
255 const auto& element = node_->element();
257 *it = {{ (size_type)(gridIndexSet.subIndex(element,localKey.
subEntity(),1)) }};
263 const PreBasis* preBasis_;
270namespace BasisFactory {
274template<
class Dummy=
void>
275class RannacherTurekPreBasisFactory
278 static const std::size_t requiredMultiIndexSize = 1;
280 template<
class MultiIndex,
class Gr
idView>
281 auto makePreBasis(
const GridView& gridView)
const
283 return RannacherTurekPreBasis<GridView, MultiIndex>(gridView);
297template<
class Dummy=
void>
300 return Imp::RannacherTurekPreBasisFactory<void>();
Base class for Dune-Exceptions.
Definition: exceptions.hh:94
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:47
Pre-basis for a Rannacher-Turek basis.
Definition: rannacherturekbasis.hh:56
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition: rannacherturekbasis.hh:139
IndexSet makeIndexSet() const
Create tree node index set.
Definition: rannacherturekbasis.hh:114
std::size_t size_type
Type used for indices and size information.
Definition: rannacherturekbasis.hh:65
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: rannacherturekbasis.hh:133
GV GridView
The grid view that the FE basis is defined on.
Definition: rannacherturekbasis.hh:62
size_type size() const
Same as size(prefix) with empty prefix.
Definition: rannacherturekbasis.hh:120
RannacherTurekNode< GV > Node
Template mapping root tree path to type of created tree node.
Definition: rannacherturekbasis.hh:68
MI MultiIndex
Type used for global numbering of the basis vectors.
Definition: rannacherturekbasis.hh:74
size_type size(const SizePrefix prefix) const
Return number of possible values for next position in multi index.
Definition: rannacherturekbasis.hh:126
void update(const GridView &gv)
Update the stored grid view, to be called if the grid has changed.
Definition: rannacherturekbasis.hh:95
Node makeNode() const
Create tree node.
Definition: rannacherturekbasis.hh:103
RannacherTurekNodeIndexSet< GV, MI > IndexSet
Template mapping root tree path to type of created tree node index set.
Definition: rannacherturekbasis.hh:71
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: rannacherturekbasis.hh:89
void initializeIndices()
Initialize the global indices.
Definition: rannacherturekbasis.hh:85
RannacherTurekPreBasis(const GridView &gv)
Constructor for a given grid view object.
Definition: rannacherturekbasis.hh:80
Grid view abstract base class.
Definition: gridview.hh:60
Describe position of one degree of freedom.
Definition: localkey.hh:21
unsigned int subEntity() const
Return number of associated subentity.
Definition: localkey.hh:54
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 few common exception classes.
#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:298
Dune namespace.
Definition: alignedallocator.hh:14
Convenience header that includes all available Rannacher-Turek LocalFiniteElements.
Static tag representing a codimension.
Definition: dimension.hh:22
Rannacher-Turek shape functions.
Definition: rannacherturek.hh:28