3 #ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_TAYLORHOODBASIS_HH 4 #define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_TAYLORHOODBASIS_HH 6 #include <dune/common/exceptions.hh> 7 #include <dune/common/reservedvector.hh> 9 #include <dune/typetree/powernode.hh> 10 #include <dune/typetree/compositenode.hh> 34 template<
typename GV,
typename TP>
37 template<
typename GV,
typename TP>
40 template<
typename GV,
class MI,
class TP,
bool HI>
65 template<
typename GV,
class MI,
bool HI=false>
68 static const bool useHybridIndices = HI;
70 static const int dim = GV::dimension;
72 template<
class,
class,
class,
bool>
99 using PQMultiIndex = std::array<size_type, 1>;
172 return sizeImp<useHybridIndices>(prefix);
178 typename std::enable_if<not hi,int>::type = 0>
181 if (prefix.size() == 0)
183 if (prefix.size() == 1)
190 if (prefix.size() == 2)
196 typename std::enable_if<hi,int>::type = 0>
199 if (prefix.size() == 0)
201 if (prefix.size() == 1)
208 if (prefix.size() == 2)
215 if (prefix.size() == 3)
243 template<
typename GV,
typename TP>
245 public PowerBasisNode<std::size_t, TP ,PQkNode<GV,2, decltype(TypeTree::push_back(TP(), 0)) >, GV::dimension>
247 using ComponentTreePath = decltype(TypeTree::push_back(TP(), 0));
256 for(
int i=0; i<GV::dimension; ++i)
257 this->setChild(i, std::make_shared<PQ2Node>(TypeTree::push_back(tp, i)));
261 template<
typename GV,
typename TP>
264 TaylorHoodVelocityTree<GV, decltype(TypeTree::push_back<0>(TP()))>,
265 PQkNode<GV,1, decltype(TypeTree::push_back<1ul>(TP()))>
268 using VelocityTreePath = decltype(TypeTree::push_back<0ul>(TP()));
269 using PressureTreePath = decltype(TypeTree::push_back<1ul>(TP()));
280 using namespace Dune::TypeTree::Indices;
281 this->
template setChild<0>(std::make_shared<VelocityNode>(push_back(tp, _0)));
282 this->
template setChild<1>(std::make_shared<PressureNode>(push_back(tp, _1)));
288 template<
typename GV,
class MI,
class TP,
bool HI>
291 static const bool useHybridIndices = HI;
293 static const int dim = GV::dimension;
309 using PQ1NodeIndexSet =
typename NodeFactory::PQ1Factory::template IndexSet<PQ1TreePath>;
310 using PQ2NodeIndexSet =
typename NodeFactory::PQ2Factory::template IndexSet<PQ2TreePath>;
313 nodeFactory_(&nodeFactory),
320 using namespace TypeTree::Indices;
322 pq1NodeIndexSet_.bind(node.child(_1));
323 pq2NodeIndexSet_.bind(node.child(_0, 0));
329 pq1NodeIndexSet_.unbind();
330 pq2NodeIndexSet_.unbind();
335 return node_->size();
340 return indexImp<useHybridIndices>(localIndex);
344 typename std::enable_if<not hi,int>::type = 0>
349 size_type velocityComponentSize = pq2NodeIndexSet_.size();
350 size_type pressureOffset = velocityComponentSize * dim;
352 mi[0] = localIndex / pressureOffset;
355 size_type v_comp = localIndex / velocityComponentSize;
356 size_type v_localIndex = localIndex % velocityComponentSize;
357 mi[1] = pq2NodeIndexSet_.index(v_localIndex)[0] * dim + v_comp;
360 mi[1] = pq1NodeIndexSet_.index(localIndex-pressureOffset)[0];
365 typename std::enable_if<hi,int>::type = 0>
370 size_type velocityComponentSize = pq2NodeIndexSet_.size();
371 size_type pressureOffset = velocityComponentSize * dim;
373 mi.push_back(localIndex / pressureOffset);
376 size_type v_comp = localIndex / velocityComponentSize;
377 size_type v_localIndex = localIndex % velocityComponentSize;
378 mi.push_back(pq2NodeIndexSet_.index(v_localIndex)[0]);
379 mi.push_back(v_comp);
382 mi.push_back(pq1NodeIndexSet_.index(localIndex-pressureOffset)[0]);
421 template<
typename GV>
430 #endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_TAYLORHOODBASIS_HH
Definition: taylorhoodbasis.hh:41
MI MultiIndex
Type used for global numbering of the basis vectors.
Definition: taylorhoodbasis.hh:92
std::size_t size_type
Definition: taylorhoodbasis.hh:297
IndexSet< TP > indexSet() const
Create tree node index set with given root tree path.
Definition: taylorhoodbasis.hh:158
MultiIndex index(size_type localIndex) const
Definition: taylorhoodbasis.hh:338
Definition: taylorhoodbasis.hh:38
size_type size() const
Same as size(prefix) with empty prefix.
Definition: taylorhoodbasis.hh:164
void bind(const Node &node)
Definition: taylorhoodbasis.hh:318
Global basis for given node factory.
Definition: defaultglobalbasis.hh:42
Definition: polynomial.hh:7
TaylorHoodNodeFactory(const GridView &gv)
Constructor for a given grid view object.
Definition: taylorhoodbasis.hh:106
typename NodeFactory::PQ1Factory::template IndexSet< PQ1TreePath > PQ1NodeIndexSet
Definition: taylorhoodbasis.hh:309
void update(const GridView &gv)
Update the stored grid view, to be called if the grid has changed.
Definition: taylorhoodbasis.hh:126
TaylorHoodNodeIndexSet(const NodeFactory &nodeFactory)
Definition: taylorhoodbasis.hh:312
typename TypeTree::Child< Node, 1 >::TreePath PQ1TreePath
Definition: taylorhoodbasis.hh:306
MI MultiIndex
Type used for global numbering of the basis vectors.
Definition: taylorhoodbasis.hh:300
TaylorHoodVelocityTree(const TP &tp)
Definition: taylorhoodbasis.hh:253
PQ1Factory pq1Factory_
Definition: taylorhoodbasis.hh:237
Dune::ReservedVector< size_type, 3 > SizePrefix
Type used for prefixes handed to the size() method.
Definition: taylorhoodbasis.hh:95
Node< TP > node(const TP &tp) const
Create tree node with given root tree path.
Definition: taylorhoodbasis.hh:143
PQ2Factory pq2Factory_
Definition: taylorhoodbasis.hh:238
size_type size() const
Definition: taylorhoodbasis.hh:333
typename NodeFactory::template Node< TP > Node
Definition: taylorhoodbasis.hh:304
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: taylorhoodbasis.hh:120
Definition: pqknodalbasis.hh:36
typename NodeFactory::PQ2Factory::template IndexSet< PQ2TreePath > PQ2NodeIndexSet
Definition: taylorhoodbasis.hh:310
void initializeIndices()
Initialize the global indices.
Definition: taylorhoodbasis.hh:113
size_type size() const
Same as size(prefix) with empty prefix.
Definition: pqknodalbasis.hh:191
size_type size(const SizePrefix prefix) const
Return number of possible values for next position in multi index.
Definition: taylorhoodbasis.hh:170
typename TypeTree::Child< Node, 0, 0 >::TreePath PQ2TreePath
Definition: taylorhoodbasis.hh:307
MultiIndex indexImp(size_type localIndex) const
Definition: taylorhoodbasis.hh:345
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition: pqknodalbasis.hh:245
std::size_t size_type
Type used for indices and size information.
Definition: taylorhoodbasis.hh:81
void update(const GridView &gv)
Update the stored grid view, to be called if the grid has changed.
Definition: pqknodalbasis.hh:154
Factory for lowest order Taylor-Hood basis.
Definition: taylorhoodbasis.hh:66
GridView gridView_
Definition: taylorhoodbasis.hh:235
Definition: taylorhoodbasis.hh:35
void unbind()
Definition: taylorhoodbasis.hh:326
TaylorHoodBasisTree(const TP &tp)
Definition: taylorhoodbasis.hh:277
GV GridView
The grid view that the FE basis is defined on.
Definition: taylorhoodbasis.hh:78
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition: taylorhoodbasis.hh:229
void initializeIndices()
Initialize the global indices.
Definition: pqknodalbasis.hh:118
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: taylorhoodbasis.hh:223