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>
40 template<
typename GV,
class MI,
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,
bool>
97 using PQMultiIndex = std::array<size_type, 1>;
158 return sizeImp<useHybridIndices>(prefix);
164 typename std::enable_if<not hi,int>::type = 0>
167 if (prefix.size() == 0)
169 if (prefix.size() == 1)
176 assert(prefix.size() == 2);
181 typename std::enable_if<hi,int>::type = 0>
184 if (prefix.size() == 0)
186 if (prefix.size() == 1)
193 if (prefix.size() == 2)
200 assert(prefix.size() == 3);
227 template<
typename GV>
237 for(
int i=0; i<GV::dimension; ++i)
238 this->setChild(i, std::make_shared<PQ2Node>());
242 template<
typename GV>
243 class TaylorHoodBasisTree :
244 public CompositeBasisNode<
245 TaylorHoodVelocityTree<GV>,
249 using VelocityNode=TaylorHoodVelocityTree<GV>;
250 using PressureNode=LagrangeNode<GV,1>;
252 using Base=CompositeBasisNode<VelocityNode, PressureNode>;
257 this->
template setChild<0>(std::make_shared<VelocityNode>());
258 this->
template setChild<1>(std::make_shared<PressureNode>());
264 template<
typename GV,
class MI,
bool HI>
265 class TaylorHoodNodeIndexSet
267 static const bool useHybridIndices = HI;
269 static const int dim = GV::dimension;
286 preBasis_(&preBasis),
287 pq1NodeIndexSet_(preBasis_->pq1PreBasis_.makeIndexSet()),
288 pq2NodeIndexSet_(preBasis_->pq2PreBasis_.makeIndexSet())
293 using namespace TypeTree::Indices;
295 pq1NodeIndexSet_.bind(node.child(_1));
296 pq2NodeIndexSet_.bind(node.child(_0, 0));
302 pq1NodeIndexSet_.unbind();
303 pq2NodeIndexSet_.unbind();
308 return node_->size();
311 template<
typename It>
314 return indicesImp<useHybridIndices>(multiIndices);
319 M.resize(M.size()+1);
320 for(std::size_t i=M.size()-1; i>0; --i)
325 template<
bool hi,
class It,
326 typename std::enable_if<not hi,int>::type = 0>
329 for(std::size_t child=0; child<dim; ++child)
331 size_type subTreeSize = pq2NodeIndexSet_.size();
332 pq2NodeIndexSet_.indices(multiIndices);
333 for (std::size_t i = 0; i<subTreeSize; ++i)
335 multiIndexPushFront(multiIndices[i], 0);
336 multiIndices[i][1] = multiIndices[i][1]*dim + child;
338 multiIndices += subTreeSize;
340 pq1NodeIndexSet_.indices(multiIndices);
341 size_type subTreeSize = pq1NodeIndexSet_.size();
342 for (std::size_t i = 0; i<subTreeSize; ++i)
343 multiIndexPushFront(multiIndices[i], 1);
344 multiIndices += subTreeSize;
348 template<
bool hi,
class It,
349 typename std::enable_if<hi,int>::type = 0>
352 for(std::size_t child=0; child<dim; ++child)
354 size_type subTreeSize = pq2NodeIndexSet_.size();
355 pq2NodeIndexSet_.indices(multiIndices);
356 for (std::size_t i = 0; i<subTreeSize; ++i)
358 multiIndexPushFront(multiIndices[i], 0);
359 multiIndices[i].push_back(i);
361 multiIndices += subTreeSize;
363 pq1NodeIndexSet_.indices(multiIndices);
364 size_type subTreeSize = pq1NodeIndexSet_.size();
365 for (std::size_t i = 0; i<subTreeSize; ++i)
366 multiIndexPushFront(multiIndices[i], 1);
367 multiIndices += subTreeSize;
372 const PreBasis* preBasis_;
373 PQ1NodeIndexSet pq1NodeIndexSet_;
374 PQ2NodeIndexSet pq2NodeIndexSet_;
381 namespace BasisFactory {
385 class TaylorHoodPreBasisFactory
388 static const std::size_t requiredMultiIndexSize=2;
390 template<
class MultiIndex,
class Gr
idView>
391 auto makePreBasis(
const GridView& gridView)
const
393 return TaylorHoodPreBasis<GridView, MultiIndex>(gridView);
408 return Imp::TaylorHoodPreBasisFactory();
438 template<
typename GV>
447 #endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_TAYLORHOODBASIS_HH
TaylorHoodPreBasis(const GridView &gv)
Constructor for a given grid view object.
Definition: taylorhoodbasis.hh:104
void initializeIndices()
Initialize the global indices.
Definition: taylorhoodbasis.hh:111
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition: lagrangebasis.hh:211
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition: taylorhoodbasis.hh:207
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition: taylorhoodbasis.hh:213
Definition: taylorhoodbasis.hh:38
TaylorHoodBasisTree()
Definition: taylorhoodbasis.hh:255
IndexSet makeIndexSet() const
Create tree node index set.
Definition: taylorhoodbasis.hh:144
Node makeNode() const
Create tree node.
Definition: taylorhoodbasis.hh:133
Pre-basis for lowest order Taylor-Hood basis.
Definition: taylorhoodbasis.hh:66
Definition: taylorhoodbasis.hh:35
size_type size(const SizePrefix prefix) const
Return number of possible values for next position in multi index.
Definition: taylorhoodbasis.hh:156
void update(const GridView &gv)
Update the stored grid view, to be called if the grid has changed.
Definition: lagrangebasis.hh:143
TaylorHoodNodeIndexSet(const PreBasis &preBasis)
Definition: taylorhoodbasis.hh:285
std::size_t size_type
Definition: taylorhoodbasis.hh:273
void update(const GridView &gv)
Update the stored grid view, to be called if the grid has changed.
Definition: taylorhoodbasis.hh:124
auto taylorHood()
Create a pre-basis factory that can create a Taylor-Hood pre-basis.
Definition: taylorhoodbasis.hh:406
PQ1PreBasis pq1PreBasis_
Definition: taylorhoodbasis.hh:221
void unbind()
Definition: taylorhoodbasis.hh:299
typename PreBasis::PQ2PreBasis::IndexSet PQ2NodeIndexSet
Definition: taylorhoodbasis.hh:283
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:46
Dune::ReservedVector< size_type, 2 > SizePrefix
Type used for prefixes handed to the size() method.
Definition: taylorhoodbasis.hh:93
size_type size() const
Same as size(prefix) with empty prefix.
Definition: lagrangebasis.hh:168
void initializeIndices()
Initialize the global indices.
Definition: lagrangebasis.hh:113
TaylorHoodVelocityTree()
Definition: taylorhoodbasis.hh:235
MI MultiIndex
Type used for global numbering of the basis vectors.
Definition: taylorhoodbasis.hh:90
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition: taylorhoodbasis.hh:118
PQ2PreBasis pq2PreBasis_
Definition: taylorhoodbasis.hh:222
Definition: polynomial.hh:10
void bind(const Node &node)
Definition: taylorhoodbasis.hh:291
Definition: lagrangebasis.hh:33
typename PreBasis::PQ1PreBasis::IndexSet PQ1NodeIndexSet
Definition: taylorhoodbasis.hh:282
Definition: taylorhoodbasis.hh:41
MI MultiIndex
Type used for global numbering of the basis vectors.
Definition: taylorhoodbasis.hh:276
It indices(It multiIndices) const
Definition: taylorhoodbasis.hh:312
static const void multiIndexPushFront(MultiIndex &M, size_type M0)
Definition: taylorhoodbasis.hh:317
GridView gridView_
Definition: taylorhoodbasis.hh:219
size_type size() const
Same as size(prefix) with empty prefix.
Definition: taylorhoodbasis.hh:150
It indicesImp(It multiIndices) const
Definition: taylorhoodbasis.hh:327
size_type size() const
Definition: taylorhoodbasis.hh:306
std::size_t size_type
Type used for indices and size information.
Definition: taylorhoodbasis.hh:81
GV GridView
The grid view that the FE basis is defined on.
Definition: taylorhoodbasis.hh:78