Go to the documentation of this file.
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>
262 class TaylorHoodBasisTree :
263 public CompositeBasisNode<std::size_t, 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()));
271 using VelocityNode=TaylorHoodVelocityTree<GV, VelocityTreePath>;
272 using PressureNode=PQkNode<GV,1, PressureTreePath>;
274 using Base=CompositeBasisNode<std::size_t, TP, VelocityNode, PressureNode>;
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>
289 class TaylorHoodNodeIndexSet
291 static const bool useHybridIndices = HI;
293 static const int dim = GV::dimension;
309 using PQ1NodeIndexSet =
typename PreBasis::PQ1PreBasis::template IndexSet<PQ1TreePath>;
310 using PQ2NodeIndexSet =
typename PreBasis::PQ2PreBasis::template IndexSet<PQ2TreePath>;
313 preBasis_(&preBasis),
314 pq1NodeIndexSet_(preBasis_->pq1PreBasis_.template indexSet<
PQ1TreePath>()),
315 pq2NodeIndexSet_(preBasis_->pq2PreBasis_.template indexSet<
PQ2TreePath>())
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();
338 template<
typename It>
341 return indicesImp<useHybridIndices>(multiIndices);
346 M.resize(M.size()+1);
347 for(std::size_t i=M.size()-1; i>0; --i)
352 template<
bool hi,
class It,
353 typename std::enable_if<not hi,int>::type = 0>
356 for(std::size_t child=0; child<dim; ++child)
358 size_type subTreeSize = pq2NodeIndexSet_.size();
359 pq2NodeIndexSet_.indices(multiIndices);
360 for (std::size_t i = 0; i<subTreeSize; ++i)
362 multiIndexPushFront(multiIndices[i], 0);
363 multiIndices[i][1] = multiIndices[i][1]*dim + child;
365 multiIndices += subTreeSize;
367 pq1NodeIndexSet_.indices(multiIndices);
368 size_type subTreeSize = pq1NodeIndexSet_.size();
369 for (std::size_t i = 0; i<subTreeSize; ++i)
370 multiIndexPushFront(multiIndices[i], 1);
371 multiIndices += subTreeSize;
375 template<
bool hi,
class It,
376 typename std::enable_if<hi,int>::type = 0>
379 for(std::size_t child=0; child<dim; ++child)
381 size_type subTreeSize = pq2NodeIndexSet_.size();
382 pq2NodeIndexSet_.indices(multiIndices);
383 for (std::size_t i = 0; i<subTreeSize; ++i)
385 multiIndexPushFront(multiIndices[i], 0);
386 multiIndices[i].push_back(i);
388 multiIndices += subTreeSize;
390 pq1NodeIndexSet_.indices(multiIndices);
391 size_type subTreeSize = pq1NodeIndexSet_.size();
392 for (std::size_t i = 0; i<subTreeSize; ++i)
393 multiIndexPushFront(multiIndices[i], 1);
394 multiIndices += subTreeSize;
399 const PreBasis* preBasis_;
401 PQ2NodeIndexSet pq2NodeIndexSet_;
433 template<
typename GV>
442 #endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_TAYLORHOODBASIS_HH
Definition: taylorhoodbasis.hh:41
Definition: polynomial.hh:7
size_type size(const SizePrefix prefix) const
Return number of possible values for next position in multi index.
Definition: taylorhoodbasis.hh:170
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: taylorhoodbasis.hh:120
void update(const GridView &gv)
Update the stored grid view, to be called if the grid has changed.
Definition: pqknodalbasis.hh:142
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition: taylorhoodbasis.hh:229
void bind(const Node &node)
Definition: taylorhoodbasis.hh:318
void update(const GridView &gv)
Update the stored grid view, to be called if the grid has changed.
Definition: taylorhoodbasis.hh:126
void initializeIndices()
Initialize the global indices.
Definition: taylorhoodbasis.hh:113
size_type size() const
Definition: taylorhoodbasis.hh:333
typename PreBasis::PQ2PreBasis::template IndexSet< PQ2TreePath > PQ2NodeIndexSet
Definition: taylorhoodbasis.hh:310
typename TypeTree::Child< Node, 1 >::TreePath PQ1TreePath
Definition: taylorhoodbasis.hh:306
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition: pqknodalbasis.hh:222
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: taylorhoodbasis.hh:223
TaylorHoodPreBasis(const GridView &gv)
Constructor for a given grid view object.
Definition: taylorhoodbasis.hh:106
Definition: pq1nodalbasis.hh:37
PQ2PreBasis pq2PreBasis_
Definition: taylorhoodbasis.hh:238
IndexSet< TP > indexSet() const
Create tree node index set with given root tree path.
Definition: taylorhoodbasis.hh:158
Pre-basis for lowest order Taylor-Hood basis.
Definition: taylorhoodbasis.hh:66
std::size_t size_type
Type used for indices and size information.
Definition: taylorhoodbasis.hh:81
size_type size() const
Same as size(prefix) with empty prefix.
Definition: taylorhoodbasis.hh:164
Definition: taylorhoodbasis.hh:38
size_type size() const
Same as size(prefix) with empty prefix.
Definition: pqknodalbasis.hh:179
Definition: pqknodalbasis.hh:36
GV GridView
The grid view that the FE basis is defined on.
Definition: taylorhoodbasis.hh:78
It indicesImp(It multiIndices) const
Definition: taylorhoodbasis.hh:354
void unbind()
Definition: taylorhoodbasis.hh:326
TaylorHoodNodeIndexSet(const PreBasis &preBasis)
Definition: taylorhoodbasis.hh:312
MI MultiIndex
Type used for global numbering of the basis vectors.
Definition: taylorhoodbasis.hh:300
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
PQ1PreBasis pq1PreBasis_
Definition: taylorhoodbasis.hh:237
typename TypeTree::Child< Node, 0, 0 >::TreePath PQ2TreePath
Definition: taylorhoodbasis.hh:307
typename PreBasis::template Node< TP > Node
Definition: taylorhoodbasis.hh:304
TaylorHoodBasisTree(const TP &tp)
Definition: taylorhoodbasis.hh:277
MI MultiIndex
Type used for global numbering of the basis vectors.
Definition: taylorhoodbasis.hh:92
Definition: taylorhoodbasis.hh:35
It indices(It multiIndices) const
Definition: taylorhoodbasis.hh:339
void initializeIndices()
Initialize the global indices.
Definition: pqknodalbasis.hh:116
typename PreBasis::PQ1PreBasis::template IndexSet< PQ1TreePath > PQ1NodeIndexSet
Definition: taylorhoodbasis.hh:309
std::size_t size_type
Definition: taylorhoodbasis.hh:297
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:42
TaylorHoodVelocityTree(const TP &tp)
Definition: taylorhoodbasis.hh:253
GridView gridView_
Definition: taylorhoodbasis.hh:235
static const void multiIndexPushFront(MultiIndex &M, size_type M0)
Definition: taylorhoodbasis.hh:344