3 #ifndef DUNE_PDELAB_LOCALFUNCTIONSPACE_HH
4 #define DUNE_PDELAB_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>
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)
101 Node::FESwitch::setStore(node.pfe, node.pgfs->finiteElementMap().find(
e));
102 node.n = Node::FESwitch::basis(*node.pfe).size();
106 ComputeSizeVisitor(
const Entity& entity, std::size_t
offset = 0)
117 template<
typename Entity>
118 struct FillIndicesVisitor
119 :
public TypeTree::TreeVisitor
120 ,
public TypeTree::DynamicTraversal
123 template<
typename Node,
typename TreePath>
124 void leaf(Node& node, TreePath treePath)
127 node.dofIndices(
e,node._dof_indices->begin()+node.offset,node._dof_indices->begin()+node.offset+node.n);
130 template<
typename Node,
typename Child,
typename TreePath,
typename ChildIndex>
131 void afterChild(
const Node& node,
const Child& child, TreePath treePath, ChildIndex childIndex)
133 for (std::size_t i = 0; i<child.n; ++i)
136 (*node._dof_indices)[child.offset+i].treeIndex().push_back(childIndex);
140 FillIndicesVisitor(
const Entity& entity)
154 template<
typename GFS,
typename DI>
177 template <
typename GFS,
typename DOFIndex>
180 typedef typename GFS::Traits::Backend B;
191 template<
typename LFS,
typename C,
typename Tag>
206 typename Traits::IndexContainer::size_type
size ()
const
217 typename Traits::IndexContainer::size_type
maxSize ()
const
236 typename Traits::IndexContainer::size_type
localIndex (
typename Traits::IndexContainer::size_type index)
const
257 std::cout <<
n <<
" indices = (";
258 for (
typename Traits::IndexContainer::size_type k=0; k<
n; k++)
260 std::cout <<
")" << std::endl;
270 template<
typename NodeType>
274 TypeTree::applyToTree(node,PropagateGlobalStorageVisitor<>());
280 typename Traits::IndexContainer::size_type
n;
281 typename Traits::IndexContainer::size_type
offset;
285 template<
typename GFS,
typename DOFIndex>
292 typedef typename GFS::Traits::GridViewType
GridView;
295 typedef typename GridViewType::Traits::template Codim<0>::Entity
Element;
298 template <
typename GFS,
typename DOFIndex>
302 typedef typename GFS::Traits::Backend B;
327 template<
typename NodeType>
331 template <
typename GFS,
typename DOFIndex>
332 template <
typename NodeType>
337 assert(&node ==
this);
340 ComputeSizeVisitor<Element> csv(e);
341 TypeTree::applyToTree(node,csv);
345 FillIndicesVisitor<Element> fiv(e);
346 TypeTree::applyToTree(node,fiv);
354 template<
typename GFS,
typename DOFIndex,
typename N>
362 template<
typename GFS,
typename DOFIndex,
typename ChildLFS, std::
size_t k>
365 public TypeTree::PowerNode<ChildLFS,k>
368 typedef TypeTree::PowerNode<ChildLFS,k> TreeNode;
388 template<
typename Transformation>
390 const Transformation& t,
391 const array<shared_ptr<ChildLFS>,k>& children)
396 template<
typename Transformation>
398 const Transformation& t,
399 const array<shared_ptr<ChildLFS>,k>& children)
400 :
BaseT(stackobject_to_shared_ptr(gfs))
415 template<
typename SourceNode,
typename Transformation>
418 template<
typename TC>
426 template<
typename PowerGr
idFunctionSpace,
typename Params>
427 Dune::TypeTree::TemplatizedGenericPowerNodeTransformation<
440 template<
typename GFS,
typename DOFIndex, DUNE_TYPETREE_COMPOSITENODE_TEMPLATE_CHILDREN>
443 ,
public DUNE_TYPETREE_COMPOSITENODE_BASETYPE
446 typedef DUNE_TYPETREE_COMPOSITENODE_BASETYPE NodeType;
465 template<
typename Transformation>
467 const Transformation& t,
468 DUNE_TYPETREE_COMPOSITENODE_STORAGE_CONSTRUCTOR_SIGNATURE)
470 , NodeType(DUNE_TYPETREE_COMPOSITENODE_CHILDVARIABLES)
473 template<
typename Transformation>
475 const Transformation& t,
476 DUNE_TYPETREE_COMPOSITENODE_STORAGE_CONSTRUCTOR_SIGNATURE)
477 :
BaseT(stackobject_to_shared_ptr(gfs))
478 , NodeType(DUNE_TYPETREE_COMPOSITENODE_CHILDVARIABLES)
490 #if HAVE_VARIADIC_TEMPLATES
493 template<
typename SourceNode,
typename Transformation>
494 struct variadic_composite_gfs_to_lfs_template
496 template<
typename... TC>
499 typedef CompositeLocalFunctionSpaceNode<SourceNode,
typename Transformation::DOFIndex,TC...> type;
504 template<
typename CompositeGr
idFunctionSpace,
typename Params>
505 Dune::TypeTree::TemplatizedGenericVariadicCompositeNodeTransformation<
506 CompositeGridFunctionSpace,
508 variadic_composite_gfs_to_lfs_template<CompositeGridFunctionSpace,gfs_to_lfs<Params> >::template result
515 template<
typename SourceNode,
typename Transformation>
518 template<
typename TC0,
530 typedef CompositeLocalFunctionSpaceNode<SourceNode,typename Transformation::DOFIndex,TC0,TC1,TC2,TC3,TC4,TC5,TC6,TC7,TC8,TC9> type;
535 template<
typename CompositeGr
idFunctionSpace,
typename Params>
536 Dune::TypeTree::TemplatizedGenericCompositeNodeTransformation<
550 template<
typename GFS,
typename DOFIndex,
typename N>
566 template<
typename GFS,
typename DOFIndex>
569 ,
public TypeTree::LeafNode
591 typedef FiniteElementInterfaceSwitch<
598 template<
typename Transformation>
604 template<
typename Transformation>
606 :
BaseT(stackobject_to_shared_ptr(gfs))
619 return this->
pgfs->constraints();
623 template<
typename Entity,
typename DOFIndexIterator>
624 void dofIndices(
const Entity&
e, DOFIndexIterator it, DOFIndexIterator endit)
627 const typename FESwitch::Coefficients &coeffs =
628 FESwitch::coefficients(*
pfe);
630 typedef typename GFS::Traits::GridViewType GV;
633 const Dune::ReferenceElement<double,GV::Grid::dimension>& refEl =
634 Dune::ReferenceElements<double,GV::Grid::dimension>::general(this->
pfe->type());
636 for (std::size_t i = 0; i < std::size_t(coeffs.size()); ++i, ++it)
639 Dune::GeometryType gt = refEl.type(coeffs.localKey(i).subEntity(),
640 coeffs.localKey(i).codim());
643 typename GV::IndexSet::IndexType index = gv.indexSet().subIndex(e,
644 coeffs.localKey(i).subEntity(),
645 coeffs.localKey(i).codim());
648 GFS::Ordering::Traits::DOFIndexAccessor::store(*it,gt,index,coeffs.localKey(i).index());
656 template<
typename GC,
typename LC>
660 typedef typename LC::const_iterator local_col_iterator;
661 typedef typename LC::value_type::second_type::const_iterator local_row_iterator;
662 typedef typename GC::iterator global_col_iterator;
663 typedef typename GC::value_type::second_type global_row_type;
665 for (local_col_iterator cit=lc.begin(); cit!=lc.end(); ++cit)
669 global_col_iterator gcit = gc.insert(std::make_pair(std::ref(this->
dofIndex(cit->first)),global_row_type())).first;
672 for (local_row_iterator rit=(cit->second).begin(); rit!=(cit->second).end(); ++rit)
673 gcit->second[this->dofIndex(rit->first)] = rit->second;
685 typename FESwitch::Store
pfe;
689 template<
typename Gr
idFunctionSpace,
typename Params>
690 Dune::TypeTree::GenericLeafNodeTransformation<
701 template <
typename GFS,
typename TAG=AnySpaceTag>
717 template <
typename GFS,
typename TAG>
719 public Dune::TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type
721 typedef typename Dune::TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type BaseT;
722 typedef typename BaseT::Traits::IndexContainer::size_type I;
723 typedef typename BaseT::Traits::IndexContainer::size_type LocalIndex;
741 : BaseT(TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::transform(gfs))
756 LocalIndex
localIndex (
typename Traits::IndexContainer::size_type index)
const
758 return LocalIndex(BaseT::localIndex(index));
764 void getChild ()
const;
772 template <
typename GFS>
774 public Dune::TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type
776 typedef typename Dune::TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type BaseT;
793 : BaseT(TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::transform(gfs))
800 : BaseT(*TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::transform_storage(pgfs))
GFS::Traits::ConstraintsType ConstraintsType
Type of constraints engine.
Definition: localfunctionspace.hh:559
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:458
void debug() const
print debug information about this local function space
Definition: localfunctionspace.hh:255
void dofIndices(const Entity &e, DOFIndexIterator it, DOFIndexIterator endit)
Calculates the multiindices associated with the given entity.
Definition: localfunctionspace.hh:624
friend struct ClearSizeVisitor
Definition: localfunctionspace.hh:374
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:186
std::vector< DI > DOFIndexContainer
Type of container to store multiindices.
Definition: localfunctionspace.hh:173
Tag denoting a PowerLocalFunctionSpace.
Definition: gridfunctionspace/tags.hh:270
void bind(const typename Traits::Element &e)
bind local function space to entity
Definition: localfunctionspace.hh:678
single component local function space
Definition: localfunctionspace.hh:567
FESwitch::Store pfe
Definition: localfunctionspace.hh:685
LocalFunctionSpace(const LocalFunctionSpace &lfs)
Definition: localfunctionspace.hh:806
traits for local function space on a gridview
Definition: localfunctionspace.hh:286
Definition: localfunctionspace.hh:441
LocalFunctionSpace(shared_ptr< const GFS > pgfs)
Definition: localfunctionspace.hh:799
PowerLocalFunctionSpaceNode< SourceNode, typename Transformation::DOFIndex, TC, SourceNode::CHILDREN > type
Definition: localfunctionspace.hh:421
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:380
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:236
GFS GridFunctionSpaceType
Type of the underlying grid function space.
Definition: localfunctionspace.hh:158
Definition: gridfunctionspace/tags.hh:22
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:449
GridViewLocalFunctionSpaceBaseNode(shared_ptr< const GFS > gfs)
construct from global function space
Definition: localfunctionspace.hh:309
LocalFunctionSpace(const LocalFunctionSpace &lfs)
Definition: localfunctionspace.hh:746
GFS::Traits::GridViewType GridViewType
Type of the grid view that the underlying grid function space is defined on.
Definition: localfunctionspace.hh:289
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:455
Definition: localfunctionspace.hh:363
PowerLocalFunctionSpaceNode(shared_ptr< const GFS > gfs, const Transformation &t, const array< shared_ptr< ChildLFS >, k > &children)
initialize with grid function space
Definition: localfunctionspace.hh:389
DI DOFIndex
Type of MultiIndex associated with this LocalFunctionSpace.
Definition: localfunctionspace.hh:170
traits mapping global function space information to local function space
Definition: localfunctionspace.hh:155
traits for multi component local function space
Definition: localfunctionspace.hh:355
LocalFunctionSpaceBaseNode(shared_ptr< const GFS > gfs)
construct from global function space
Definition: localfunctionspace.hh:198
Traits::IndexContainer::size_type maxSize() const
get maximum possible size (which is maxLocalSize from grid function space)
Definition: localfunctionspace.hh:217
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:732
friend struct ClearSizeVisitor
Definition: localfunctionspace.hh:452
N NodeType
type of local function space node
Definition: localfunctionspace.hh:358
const Entity & e
Definition: localfunctionspace.hh:111
GridViewLocalFunctionSpaceBaseTraits< GFS, DOFIndex > Traits
Definition: localfunctionspace.hh:306
PowerLocalFunctionSpaceNode(const GFS &gfs, const Transformation &t, const array< shared_ptr< ChildLFS >, k > &children)
Definition: localfunctionspace.hh:397
GFS::Traits::ConstraintsType Constraints
Definition: localfunctionspace.hh:561
Definition: gridfunctionspace/tags.hh:26
LocalFunctionSpace(const GFS &gfs)
Definition: localfunctionspace.hh:792
GFS::Traits::SizeType SizeType
Type to store indices from Backend.
Definition: localfunctionspace.hh:164
const std::size_t offset
Definition: localfunctionspace.hh:74
Traits::IndexContainer::size_type n
Definition: localfunctionspace.hh:280
void setup(NodeType &node)
Definition: localfunctionspace.hh:271
LeafLocalFunctionSpaceNode(shared_ptr< const GFS > gfs, const Transformation &t)
initialize with grid function space
Definition: localfunctionspace.hh:599
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:574
base class for tuples of grid function spaces product of identical grid function spaces base class th...
Definition: powergridfunctionspace.hh:41
std::size_t subSpaceDepth() const
Definition: localfunctionspace.hh:211
traits for single component local function space
Definition: localfunctionspace.hh:551
std::vector< SizeType > IndexContainer
Type of container to store indices.
Definition: localfunctionspace.hh:167
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:735
shared_ptr< GFS const > pgfs
Definition: localfunctionspace.hh:277
GFS::Traits::GridViewType GridView
Type of the grid view that the underlying grid function space is defined on.
Definition: localfunctionspace.hh:292
LocalFunctionSpace(const GFS &gfs)
Definition: localfunctionspace.hh:740
const Traits::ConstraintsType & constraints() const
get constraints engine
Definition: localfunctionspace.hh:617
LeafLocalFunctionSpaceTag ImplementationTag
Definition: localfunctionspace.hh:588
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:371
void bind(const typename Traits::Element &e)
bind local function space to entity
Definition: localfunctionspace.hh:482
LeafLocalFunctionSpaceNode(const GFS &gfs, const Transformation &t)
Definition: localfunctionspace.hh:605
Traits::IndexContainer::size_type size() const
get current size
Definition: localfunctionspace.hh:206
void bind(const typename Traits::Element &e)
bind local function space to entity
Definition: localfunctionspace.hh:405
Dune::TypeTree::TemplatizedGenericPowerNodeTransformation< PowerGridFunctionSpace, gfs_to_lfs< Params >, power_gfs_to_lfs_template< PowerGridFunctionSpace, gfs_to_lfs< Params > >::template result > registerNodeTransformation(PowerGridFunctionSpace *pgfs, gfs_to_lfs< Params > *t, PowerGridFunctionSpaceTag *tag)
LocalIndex localIndex(typename Traits::IndexContainer::size_type index) const
Definition: localfunctionspace.hh:756
Definition: localfunctionspace.hh:178
Definition: lfsindexcache.hh:240
Traits::DOFIndexContainer * _dof_indices
Definition: localfunctionspace.hh:279
Create a local function space from a global function space.
Definition: localfunctionspace.hh:702
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:583
Definition: gridfunctionspace/tags.hh:28
PowerLocalFunctionSpaceTag ImplementationTag
Definition: localfunctionspace.hh:385
const GFS & gridFunctionSpace() const
Returns the GridFunctionSpace underlying this LocalFunctionSpace.
Definition: localfunctionspace.hh:264
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:377
void bind(NodeType &node, const typename Traits::Element &e)
bind local function space to entity
A grid function space.
Definition: gridfunctionspace.hh:109
friend struct ClearSizeVisitor
Definition: localfunctionspace.hh:577
CompositeLocalFunctionSpaceNode(shared_ptr< const GFS > gfs, const Transformation &t, DUNE_TYPETREE_COMPOSITENODE_STORAGE_CONSTRUCTOR_SIGNATURE)
Definition: localfunctionspace.hh:466
Traits::DOFIndexContainer _dof_index_storage
Definition: localfunctionspace.hh:278
CompositeLocalFunctionSpaceTag ImplementationTag
Definition: localfunctionspace.hh:463
Definition: localfunctionspace.hh:516
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:726
GFS GridFunctionSpace
Type of the underlying grid function space.
Definition: localfunctionspace.hh:161
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:189
LeafLocalFunctionSpaceTraits< GFS, DOFIndex, LeafLocalFunctionSpaceNode > Traits
Definition: localfunctionspace.hh:586
GFS::Traits::FiniteElementType FiniteElement
Definition: localfunctionspace.hh:556
friend struct ClearSizeVisitor
Definition: localfunctionspace.hh:729
PowerCompositeLocalFunctionSpaceTraits< GFS, DOFIndex, CompositeLocalFunctionSpaceNode > Traits
Definition: localfunctionspace.hh:461
GFS::Traits::FiniteElementType FiniteElementType
Type of local finite element.
Definition: localfunctionspace.hh:554
CompositeLocalFunctionSpaceNode(const GFS &gfs, const Transformation &t, DUNE_TYPETREE_COMPOSITENODE_STORAGE_CONSTRUCTOR_SIGNATURE)
Definition: localfunctionspace.hh:474
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:580
Definition: localfunctionspacetags.hh:40
GridViewType::Traits::template Codim< 0 >::Entity Element
Type of codim 0 entity in the grid.
Definition: localfunctionspace.hh:295
Definition: localfunctionspace.hh:419
Tag denoting a LeafLocalFunctionSpace.
Definition: gridfunctionspace/tags.hh:276
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:249
CompositeLocalFunctionSpaceNode< SourceNode, typename Transformation::DOFIndex, TC0, TC1, TC2, TC3, TC4, TC5, TC6, TC7, TC8, TC9 > type
Definition: localfunctionspace.hh:530
base class for tuples of grid function spaces base class that holds implementation of the methods thi...
Definition: compositegridfunctionspace.hh:40
Tag denoting a CompositeLocalFunctionSpace.
Definition: gridfunctionspace/tags.hh:273
LocalFunctionSpaceBaseTraits< GFS, DOFIndex > Traits
Definition: localfunctionspace.hh:195
Traits::IndexContainer::size_type localVectorSize() const
get size of an appropriate local vector object
Definition: localfunctionspace.hh:230
Definition: localfunctionspace.hh:299
void insert_constraints(const LC &lc, GC &gc) const
Definition: localfunctionspace.hh:657
Traits::IndexContainer::size_type offset
Definition: localfunctionspace.hh:281
BaseT::Traits Traits
Definition: localfunctionspace.hh:738
Definition: localfunctionspace.hh:416
Definition: localfunctionspace.hh:528
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:183
PowerCompositeLocalFunctionSpaceTraits< GFS, DOFIndex, PowerLocalFunctionSpaceNode > Traits
Definition: localfunctionspace.hh:383
const Traits::FiniteElementType & finiteElement() const
get finite element
Definition: localfunctionspace.hh:611