7#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_RANNACHERTUREKBASIS_HH
8#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_RANNACHERTUREKBASIS_HH
10#include <dune/common/exceptions.hh>
12#include <dune/grid/common/capabilities.hh>
14#include <dune/localfunctions/common/localfiniteelementvariant.hh>
15#include <dune/localfunctions/rannacherturek.hh>
16#include <dune/localfunctions/crouzeixraviart.hh>
18#include <dune/functions/functionspacebases/nodes.hh>
19#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
20#include <dune/functions/functionspacebases/leafprebasismixin.hh>
38class RannacherTurekNode;
41class RannacherTurekPreBasis;
59 static const int dim = GV::dimension;
70 using Node = RannacherTurekNode<GV>;
76 for(
auto type : gv.indexSet().types(0))
77 if (!type.isSimplex() && !type.isCube())
78 DUNE_THROW(Dune::NotImplemented,
"Rannacher-Turek or Crouzeix-Raviart elements are only implemented for grids with simplex or cube elements.");
114 return 2*GV::dimension;
117 template<
typename It>
118 It indices(
const Node& node, It it)
const
120 for (
size_type i = 0, end = node.size() ; i < end ; ++i, ++it)
122 Dune::LocalKey localKey = node.finiteElement().localCoefficients().localKey(i);
123 const auto& gridIndexSet =
gridView().indexSet();
124 const auto& element = node.element();
126 *it = {{ (
size_type)(gridIndexSet.subIndex(element,localKey.subEntity(),1)) }};
138class RannacherTurekNode :
141 static const int dim = GV::dimension;
142 static const int maxSize = 2*dim;
144 constexpr static bool hasFixedElementType = Capabilities::hasSingleGeometryType<typename GV::Grid>::v;
146 using CubeFiniteElement = RannacherTurekLocalFiniteElement<typename GV::ctype,double,dim>;
147 using SimplexFiniteElement = CrouzeixRaviartLocalFiniteElement<typename GV::ctype,double,dim>;
149 constexpr static unsigned int topologyId = Capabilities::hasSingleGeometryType<typename GV::Grid>::topologyId;
150 constexpr static GeometryType type = GeometryType(topologyId, GV::dimension);
154 using size_type = std::size_t;
155 using Element =
typename GV::template Codim<0>::Entity;
156 using FiniteElement = std::conditional_t<hasFixedElementType,
157 std::conditional_t<type.isCube(),CubeFiniteElement,SimplexFiniteElement>,
158 LocalFiniteElementVariant<CubeFiniteElement, SimplexFiniteElement> >;
160 RannacherTurekNode() :
166 const Element& element()
const
175 const FiniteElement& finiteElement()
const
177 return finiteElement_;
181 void bind(
const Element& e)
184 if constexpr (!hasFixedElementType)
185 finiteElement_ = e.type().isCube() ?
static_cast<FiniteElement
>(CubeFiniteElement())
186 :
static_cast<FiniteElement
>(SimplexFiniteElement()) ;
187 this->setSize(finiteElement_.size());
192 FiniteElement finiteElement_;
193 const Element* element_;
198namespace BasisFactory {
205template<
class Dummy=
void>
208 return [](
const auto& gridView) {
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:50
A generic MixIn class for PreBasis.
Definition: leafprebasismixin.hh:36
Pre-basis for a Rannacher-Turek basis.
Definition: rannacherturekbasis.hh:58
void initializeIndices()
Initialize the global indices.
Definition: rannacherturekbasis.hh:82
std::size_t size_type
Type used for indices and size information.
Definition: rannacherturekbasis.hh:67
Node makeNode() const
Create tree node.
Definition: rannacherturekbasis.hh:100
void update(const GridView &gv)
Update the stored grid view, to be called if the grid has changed.
Definition: rannacherturekbasis.hh:92
GV GridView
The grid view that the FE basis is defined on.
Definition: rannacherturekbasis.hh:64
size_type dimension() const
Same as size(prefix) with empty prefix.
Definition: rannacherturekbasis.hh:106
RannacherTurekPreBasis(const GridView &gv)
Constructor for a given grid view object.
Definition: rannacherturekbasis.hh:73
RannacherTurekNode< GV > Node
Template mapping root tree path to type of created tree node.
Definition: rannacherturekbasis.hh:70
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: rannacherturekbasis.hh:86
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition: rannacherturekbasis.hh:112
auto rannacherTurek()
Create a pre-basis factory that can create a Rannacher-Turek pre-basis.
Definition: rannacherturekbasis.hh:206
Definition: monomialset.hh:19