Go to the documentation of this file.
3 #ifndef DUNE_PDELAB_GRIDFUNCTIONSPACE_LOCALFUNCTIONSPACE_HH
4 #define DUNE_PDELAB_GRIDFUNCTIONSPACE_LOCALFUNCTIONSPACE_HH
8 #include <dune/common/stdstreams.hh>
10 #include <dune/geometry/referenceelements.hh>
12 #include <dune/localfunctions/common/interfaceswitch.hh>
13 #include <dune/localfunctions/common/localkey.hh>
15 #include <dune/typetree/typetree.hh>
35 template<
typename =
int>
36 struct PropagateGlobalStorageVisitor
37 :
public TypeTree::TreeVisitor
38 ,
public TypeTree::DynamicTraversal
41 template<
typename LFS,
typename Child,
typename TreePath,
typename ChildIndex>
42 void beforeChild(
const LFS& lfs, Child& child, TreePath treePath, ChildIndex childIndex)
const
44 child._dof_indices = lfs._dof_indices;
51 template<
typename =
int>
52 struct ClearSizeVisitor
53 :
public TypeTree::TreeVisitor
54 ,
public TypeTree::DynamicTraversal
57 template<
typename Node,
typename TreePath>
58 void pre(Node& node, TreePath treePath)
63 template<
typename Node,
typename TreePath>
64 void leaf(Node& node, TreePath treePath)
70 ClearSizeVisitor(std::size_t offset_)
79 template<
typename Entity,
bool fast>
80 struct ComputeSizeVisitor
81 :
public TypeTree::TreeVisitor
82 ,
public TypeTree::DynamicTraversal
85 template<
typename Node,
typename TreePath>
86 void pre(Node& node, TreePath treePath)
91 template<
typename Node,
typename TreePath>
92 void post(Node& node, TreePath treePath)
94 node.n =
offset - node.offset;
97 template<
typename Node,
typename TreePath>
98 void leaf(Node& node, TreePath treePath)
104 node.n = node.pgfs->finiteElementMap().maxLocalSize();
105 Node::FESwitch::setStore(node.pfe, node.pgfs->finiteElementMap().find(
e));
109 Node::FESwitch::setStore(node.pfe, node.pgfs->finiteElementMap().find(
e));
110 node.n = Node::FESwitch::basis(*node.pfe).size();
115 ComputeSizeVisitor(
const Entity& entity, std::size_t offset_ = 0)
126 template<
typename Entity,
bool fast>
127 struct FillIndicesVisitor
128 :
public TypeTree::TreeVisitor
129 ,
public TypeTree::DynamicTraversal
132 template<
typename Node,
typename TreePath>
133 void leaf(Node& node, TreePath treePath)
136 node.dofIndices(
e,node._dof_indices->begin()+node.offset,node._dof_indices->begin()+node.offset+node.n,std::integral_constant<bool,fast>{});
139 template<
typename Node,
typename Child,
typename TreePath,
typename ChildIndex>
140 void afterChild(
const Node& node,
const Child& child, TreePath treePath, ChildIndex childIndex)
147 for (std::size_t i = 0; i<child.n; ++i)
150 (*node._dof_indices)[child.offset+i].treeIndex().push_back(childIndex);
154 FillIndicesVisitor(
const Entity& entity)
168 template<
typename GFS,
typename DI>
191 template <
typename GFS,
typename DOFIndex>
194 typedef typename GFS::Traits::Backend B;
199 template<
typename,
bool>
202 template<
typename,
bool>
205 template<
typename LFS,
typename C,
typename Tag,
bool>
220 typename Traits::IndexContainer::size_type
size ()
const
231 typename Traits::IndexContainer::size_type
maxSize ()
const
250 typename Traits::IndexContainer::size_type
localIndex (
typename Traits::IndexContainer::size_type
index)
const
271 std::cout <<
n <<
" indices = (";
272 for (
typename Traits::IndexContainer::size_type k=0; k<
n; k++)
274 std::cout <<
")" << std::endl;
284 template<
typename NodeType>
288 TypeTree::applyToTree(node,PropagateGlobalStorageVisitor<>());
291 std::shared_ptr<GFS const>
pgfs;
294 typename Traits::IndexContainer::size_type
n;
295 typename Traits::IndexContainer::size_type
offset;
299 template<
typename GFS,
typename DOFIndex>
306 typedef typename GFS::Traits::GridViewType
GridView;
314 template <
typename GFS,
typename DOFIndex>
318 typedef typename GFS::Traits::Backend B;
343 template<
typename NodeType,
bool fast = false>
344 void bind (NodeType& node,
const typename Traits::Element&
e, std::integral_constant<bool,fast> = std::integral_constant<bool,fast>{});
347 template <
typename GFS,
typename DOFIndex>
348 template <
typename NodeType,
bool fast>
351 std::integral_constant<bool,fast>)
354 assert(&node ==
this);
357 ComputeSizeVisitor<Element,fast> csv(
e);
358 TypeTree::applyToTree(node,csv);
362 FillIndicesVisitor<Element,fast> fiv(
e);
363 TypeTree::applyToTree(node,fiv);
371 template<
typename GFS,
typename DOFIndex,
typename N>
379 template<
typename GFS,
typename DOFIndex,
typename ChildLFS, std::
size_t k>
382 public TypeTree::PowerNode<ChildLFS,k>
385 typedef TypeTree::PowerNode<ChildLFS,k> TreeNode;
393 template<
typename,
bool>
396 template<
typename,
bool>
405 template<
typename Transformation>
407 const Transformation& t,
408 const std::array<std::shared_ptr<ChildLFS>,k>& children)
413 template<
typename Transformation>
415 const Transformation& t,
416 const std::array<std::shared_ptr<ChildLFS>,k>& children)
417 :
BaseT(stackobject_to_shared_ptr(gfs))
422 template<
bool fast = false>
423 void bind (
const typename Traits::Element&
e, std::integral_constant<bool,fast> fast_ = std::integral_constant<bool,fast>{})
433 template<
typename SourceNode,
typename Transformation>
436 template<
typename TC>
444 template<
typename PowerGr
idFunctionSpace,
typename Params>
445 TypeTree::TemplatizedGenericPowerNodeTransformation<
458 template<
typename GFS,
typename DOFIndex,
typename... Children>
461 ,
public TypeTree::CompositeNode<Children...>
464 typedef TypeTree::CompositeNode<Children...> NodeType;
472 template<
typename,
bool>
475 template<
typename,
bool>
483 template<
typename Transformation>
485 const Transformation& t,
486 std::shared_ptr<Children>... children)
488 , NodeType(children...)
491 template<
typename Transformation>
493 const Transformation& t,
494 std::shared_ptr<Children>... children)
495 :
BaseT(stackobject_to_shared_ptr(gfs))
496 , NodeType(children...)
500 template<
bool fast = false>
501 void bind (
const typename Traits::Element&
e, std::integral_constant<bool,fast> fast_ = std::integral_constant<bool,fast>{})
510 template<
typename SourceNode,
typename Transformation>
513 template<
typename... TC>
521 template<
typename CompositeGr
idFunctionSpace,
typename Params>
522 TypeTree::TemplatizedGenericCompositeNodeTransformation<
535 template<
typename GFS,
typename DOFIndex,
typename N>
551 template<
typename GFS,
typename DOFIndex>
554 ,
public TypeTree::LeafNode
564 template<
typename,
bool>
567 template<
typename,
bool>
576 typedef FiniteElementInterfaceSwitch<
583 template<
typename Transformation>
589 template<
typename Transformation>
591 :
BaseT(stackobject_to_shared_ptr(gfs))
605 return this->
pgfs->constraints();
609 template<
typename Entity,
typename DOFIndexIterator,
bool fast>
610 void dofIndices(
const Entity&
e, DOFIndexIterator it, DOFIndexIterator endit, std::integral_constant<bool,fast>)
616 GFS::Ordering::Traits::DOFIndexAccessor::store(*it,gt,
index,0);
622 const typename FESwitch::Coefficients &coeffs =
623 FESwitch::coefficients(*
pfe);
625 using EntitySet =
typename GFS::Traits::EntitySet;
628 auto refEl = Dune::ReferenceElements<double,EntitySet::dimension>::general(this->
pfe->type());
630 for (std::size_t i = 0; i < std::size_t(coeffs.size()); ++i, ++it)
633 auto gt = refEl.type(coeffs.localKey(i).subEntity(),
634 coeffs.localKey(i).codim());
637 auto index = es.indexSet().subIndex(
e,
638 coeffs.localKey(i).subEntity(),
639 coeffs.localKey(i).codim());
642 GFS::Ordering::Traits::DOFIndexAccessor::store(*it,gt,
index,coeffs.localKey(i).index());
651 template<
typename GC,
typename LC>
655 typedef typename LC::const_iterator local_col_iterator;
656 typedef typename LC::value_type::second_type::const_iterator local_row_iterator;
657 typedef typename GC::iterator global_col_iterator;
658 typedef typename GC::value_type::second_type global_row_type;
660 for (local_col_iterator cit=lc.begin(); cit!=lc.end(); ++cit)
664 global_col_iterator gcit = gc.insert(std::make_pair(std::ref(this->
dofIndex(cit->first)),global_row_type())).first;
667 for (local_row_iterator rit=(cit->second).begin(); rit!=(cit->second).end(); ++rit)
668 gcit->second[this->
dofIndex(rit->first)] = rit->second;
673 template<
bool fast = false>
674 void bind (
const typename Traits::Element&
e, std::integral_constant<bool,fast> fast_ = std::integral_constant<bool,fast>{})
681 typename FESwitch::Store
pfe;
685 template<
typename Gr
idFunctionSpace,
typename Params>
686 TypeTree::GenericLeafNodeTransformation<
697 template <
typename GFS,
typename TAG=AnySpaceTag>
713 template <
typename GFS,
typename TAG>
715 public TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type
717 typedef typename TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type BaseT;
718 typedef typename BaseT::Traits::IndexContainer::size_type I;
719 typedef typename BaseT::Traits::IndexContainer::size_type LocalIndex;
737 : BaseT(TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::transform(gfs))
748 this->_dof_indices = &(this->_dof_index_storage);
754 return LocalIndex(BaseT::localIndex(
index));
760 void getChild ()
const;
768 template <
typename GFS>
770 public TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type
772 typedef typename TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type BaseT;
780 template<
typename,
bool>
783 template<
typename,
bool>
789 : BaseT(TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::transform(gfs))
791 this->_dof_indices = &(this->_dof_index_storage);
796 : BaseT(*TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::transform_storage(pgfs))
798 this->_dof_indices = &(this->_dof_index_storage);
808 this->_dof_indices = &(this->_dof_index_storage);
818 #endif // DUNE_PDELAB_GRIDFUNCTIONSPACE_LOCALFUNCTIONSPACE_HH
LocalFunctionSpace(const LocalFunctionSpace &lfs)
Definition: localfunctionspace.hh:802
N NodeType
type of local function space node
Definition: localfunctionspace.hh:375
Traits::IndexContainer::size_type n
Definition: localfunctionspace.hh:294
Definition: localfunctionspace.hh:434
PowerCompositeLocalFunctionSpaceTraits< GFS, DOFIndex, CompositeLocalFunctionSpaceNode > Traits
Definition: localfunctionspace.hh:479
Traits::IndexContainer::size_type localIndex(typename Traits::IndexContainer::size_type index) const
map index in this local function space to root local function space
Definition: localfunctionspace.hh:250
Definition: localfunctionspacetags.hh:40
Traits::DOFIndexContainer * _dof_indices
Definition: localfunctionspace.hh:293
LocalFunctionSpace(const GFS &gfs)
Definition: localfunctionspace.hh:736
single component local function space
Definition: localfunctionspace.hh:552
PowerLocalFunctionSpaceNode(std::shared_ptr< const GFS > gfs, const Transformation &t, const std::array< std::shared_ptr< ChildLFS >, k > &children)
initialize with grid function space
Definition: localfunctionspace.hh:406
CompositeLocalFunctionSpaceNode(const GFS &gfs, const Transformation &t, std::shared_ptr< Children >... children)
Definition: localfunctionspace.hh:492
Definition: localfunctionspace.hh:192
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:731
PowerLocalFunctionSpaceNode< SourceNode, typename Transformation::DOFIndex, TC, TypeTree::StaticDegree< SourceNode >::value > type
Definition: localfunctionspace.hh:439
BaseT::Traits Traits
Definition: localfunctionspace.hh:734
Definition: localfunctionspace.hh:514
const Traits::ConstraintsType & constraints() const
get constraints engine
Definition: localfunctionspace.hh:603
Tag denoting a LeafLocalFunctionSpace.
Definition: gridfunctionspace/tags.hh:200
Definition: gridfunctionspace/tags.hh:30
std::size_t index
Definition: interpolate.hh:118
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:200
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:473
LocalFunctionSpaceBaseTraits< GFS, DOFIndex > Traits
Definition: localfunctionspace.hh:209
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:568
void bind(NodeType &node, const typename Traits::Element &e, std::integral_constant< bool, fast >=std::integral_constant< bool, fast >{})
bind local function space to entity
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:397
const GFS & gridFunctionSpace() const
Returns the GridFunctionSpace underlying this LocalFunctionSpace.
Definition: localfunctionspace.hh:278
LeafLocalFunctionSpaceNode(std::shared_ptr< const GFS > gfs, const Transformation &t)
initialize with grid function space
Definition: localfunctionspace.hh:584
void bind(const typename Traits::Element &e, std::integral_constant< bool, fast > fast_=std::integral_constant< bool, fast >{})
bind local function space to entity
Definition: localfunctionspace.hh:423
std::vector< SizeType > IndexContainer
Type of container to store indices.
Definition: localfunctionspace.hh:181
LocalFunctionSpace(std::shared_ptr< const GFS > pgfs)
Definition: localfunctionspace.hh:795
Definition: localfunctionspace.hh:315
GFS::Traits::ConstraintsType Constraints
Definition: localfunctionspace.hh:546
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:722
Definition: localfunctionspace.hh:511
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:394
GridViewLocalFunctionSpaceBaseTraits< GFS, DOFIndex > Traits
Definition: localfunctionspace.hh:322
const std::size_t offset
Definition: localfunctionspace.hh:74
GFS::Traits::GridViewType GridViewType
Type of the grid view that the underlying grid function space is defined on.
Definition: localfunctionspace.hh:303
LocalIndex localIndex(typename Traits::IndexContainer::size_type index) const
Definition: localfunctionspace.hh:752
PowerLocalFunctionSpaceTag ImplementationTag
Definition: localfunctionspace.hh:402
GFS GridFunctionSpaceType
Type of the underlying grid function space.
Definition: localfunctionspace.hh:172
PowerCompositeLocalFunctionSpaceTraits< GFS, DOFIndex, PowerLocalFunctionSpaceNode > Traits
Definition: localfunctionspace.hh:400
typename GFS::Traits::EntitySet EntitySet
Definition: localfunctionspace.hh:308
LeafLocalFunctionSpaceNode(const GFS &gfs, const Transformation &t)
Definition: localfunctionspace.hh:590
base class for tuples of grid function spaces product of identical grid function spaces base class th...
Definition: powergridfunctionspace.hh:40
Traits::IndexContainer::size_type size() const
get current size
Definition: localfunctionspace.hh:220
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:467
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:559
Traits::IndexContainer::size_type maxSize() const
get maximum possible size (which is maxLocalSize from grid function space)
Definition: localfunctionspace.hh:231
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:565
std::vector< DI > DOFIndexContainer
Type of container to store multiindices.
Definition: localfunctionspace.hh:187
typename EntitySet::Element Element
Type of codim 0 entity in the grid.
Definition: localfunctionspace.hh:311
void dofIndices(const Entity &e, DOFIndexIterator it, DOFIndexIterator endit, std::integral_constant< bool, fast >)
Calculates the multiindices associated with the given entity.
Definition: localfunctionspace.hh:610
LocalFunctionSpaceBaseNode(std::shared_ptr< const GFS > gfs)
construct from global function space
Definition: localfunctionspace.hh:212
A grid function space.
Definition: gridfunctionspace.hh:166
GFS::Traits::GridViewType GridView
Type of the grid view that the underlying grid function space is defined on.
Definition: localfunctionspace.hh:306
base class for tuples of grid function spaces base class that holds implementation of the methods thi...
Definition: compositegridfunctionspace.hh:40
Definition: localfunctionspace.hh:437
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:388
GFS GridFunctionSpace
Type of the underlying grid function space.
Definition: localfunctionspace.hh:175
GFS::Traits::ConstraintsType ConstraintsType
Type of constraints engine.
Definition: localfunctionspace.hh:544
friend struct ClearSizeVisitor
Definition: localfunctionspace.hh:391
void bind(const typename Traits::Element &e, std::integral_constant< bool, fast > fast_=std::integral_constant< bool, fast >{})
bind local function space to entity
Definition: localfunctionspace.hh:674
std::size_t subSpaceDepth() const
Definition: localfunctionspace.hh:225
CompositeLocalFunctionSpaceNode< SourceNode, typename Transformation::DOFIndex, TC... > type
Definition: localfunctionspace.hh:516
LeafLocalFunctionSpaceTag ImplementationTag
Definition: localfunctionspace.hh:573
DI DOFIndex
Type of MultiIndex associated with this LocalFunctionSpace.
Definition: localfunctionspace.hh:184
std::shared_ptr< GFS const > pgfs
Definition: localfunctionspace.hh:291
Definition: localfunctionspace.hh:380
traits for local function space on a gridview
Definition: localfunctionspace.hh:300
const Traits::DOFIndex & dofIndex(typename Traits::IndexContainer::size_type index) const
Maps given index in this local function space to its corresponding global MultiIndex.
Definition: localfunctionspace.hh:263
void debug() const
print debug information about this local function space
Definition: localfunctionspace.hh:269
Traits::IndexContainer::size_type localVectorSize() const
get size of an appropriate local vector object
Definition: localfunctionspace.hh:244
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:476
GFS::Traits::FiniteElementType FiniteElementType
Type of local finite element.
Definition: localfunctionspace.hh:539
const Traits::FiniteElementType & finiteElement() const
get finite element
Definition: localfunctionspace.hh:596
const Entity & e
Definition: localfunctionspace.hh:120
friend struct ClearSizeVisitor
Definition: localfunctionspace.hh:470
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:203
A multi-index representing a degree of freedom in a GridFunctionSpace.
Definition: dofindex.hh:147
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:728
GridViewLocalFunctionSpaceBaseNode(std::shared_ptr< const GFS > gfs)
construct from global function space
Definition: localfunctionspace.hh:325
traits mapping global function space information to local function space
Definition: localfunctionspace.hh:169
Tag denoting a CompositeLocalFunctionSpace.
Definition: gridfunctionspace/tags.hh:197
void bind(const typename Traits::Element &e, std::integral_constant< bool, fast > fast_=std::integral_constant< bool, fast >{})
bind local function space to entity
Definition: localfunctionspace.hh:501
GFS::Traits::SizeType SizeType
Type to store indices from Backend.
Definition: localfunctionspace.hh:178
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:197
Definition: lfsindexcache.hh:244
traits for single component local function space
Definition: localfunctionspace.hh:536
traits for multi component local function space
Definition: localfunctionspace.hh:372
Definition: gridfunctionspace/tags.hh:32
GFS::Traits::FiniteElementType FiniteElement
Definition: localfunctionspace.hh:541
Traits::DOFIndexContainer _dof_index_storage
Definition: localfunctionspace.hh:292
Tag denoting a PowerLocalFunctionSpace.
Definition: gridfunctionspace/tags.hh:194
Create a local function space from a global function space.
Definition: localfunctionspace.hh:698
Traits::IndexContainer::size_type offset
Definition: localfunctionspace.hh:295
void setup(NodeType &node)
Definition: localfunctionspace.hh:285
PowerLocalFunctionSpaceNode(const GFS &gfs, const Transformation &t, const std::array< std::shared_ptr< ChildLFS >, k > &children)
Definition: localfunctionspace.hh:414
Dune::TypeTree::GenericLeafNodeTransformation< LeafNode, GridFunctionToLocalViewTransformation, Imp::LocalGridViewFunctionAdapter< LeafNode > > registerNodeTransformation(LeafNode *l, GridFunctionToLocalViewTransformation *t, GridFunctionTag *tag)
LocalFunctionSpace(const GFS &gfs)
Definition: localfunctionspace.hh:788
FESwitch::Store pfe
Definition: localfunctionspace.hh:681
Definition: localfunctionspace.hh:459
friend struct ClearSizeVisitor
Definition: localfunctionspace.hh:725
Definition: gridfunctionspace/tags.hh:26
LocalFunctionSpace(const LocalFunctionSpace &lfs)
Definition: localfunctionspace.hh:742
CompositeLocalFunctionSpaceNode(std::shared_ptr< const GFS > gfs, const Transformation &t, std::shared_ptr< Children >... children)
Definition: localfunctionspace.hh:484
LeafLocalFunctionSpaceTraits< GFS, DOFIndex, LeafLocalFunctionSpaceNode > Traits
Definition: localfunctionspace.hh:571
friend struct ClearSizeVisitor
Definition: localfunctionspace.hh:562
CompositeLocalFunctionSpaceTag ImplementationTag
Definition: localfunctionspace.hh:481
void insert_constraints(const LC &lc, GC &gc) const
Definition: localfunctionspace.hh:652