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<>());
277 std::shared_ptr<GFS const>
pgfs;
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 std::array<std::shared_ptr<ChildLFS>,k>& children)
396 template<
typename Transformation>
398 const Transformation& t,
399 const std::array<std::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 TypeTree::TemplatizedGenericPowerNodeTransformation<
440 template<
typename GFS,
typename DOFIndex,
typename... Children>
443 ,
public TypeTree::CompositeNode<Children...>
446 typedef TypeTree::CompositeNode<Children...> NodeType;
465 template<
typename Transformation>
467 const Transformation& t,
468 std::shared_ptr<Children>... children)
470 , NodeType(children...)
473 template<
typename Transformation>
475 const Transformation& t,
476 std::shared_ptr<Children>... children)
477 : BaseT(stackobject_to_shared_ptr(gfs))
478 , NodeType(children...)
491 template<
typename SourceNode,
typename Transformation>
494 template<
typename... TC>
502 template<
typename CompositeGr
idFunctionSpace,
typename Params>
503 TypeTree::TemplatizedGenericCompositeNodeTransformation<
516 template<
typename GFS,
typename DOFIndex,
typename N>
532 template<
typename GFS,
typename DOFIndex>
535 ,
public TypeTree::LeafNode
557 typedef FiniteElementInterfaceSwitch<
564 template<
typename Transformation>
570 template<
typename Transformation>
572 : BaseT(stackobject_to_shared_ptr(gfs))
585 return this->
pgfs->constraints();
589 template<
typename Entity,
typename DOFIndexIterator>
590 void dofIndices(
const Entity&
e, DOFIndexIterator it, DOFIndexIterator endit)
593 const typename FESwitch::Coefficients &coeffs =
594 FESwitch::coefficients(*
pfe);
596 typedef typename GFS::Traits::GridViewType GV;
599 const Dune::ReferenceElement<double,GV::Grid::dimension>& refEl =
600 Dune::ReferenceElements<double,GV::Grid::dimension>::general(this->
pfe->type());
602 for (std::size_t i = 0; i < std::size_t(coeffs.size()); ++i, ++it)
605 Dune::GeometryType gt = refEl.type(coeffs.localKey(i).subEntity(),
606 coeffs.localKey(i).codim());
609 typename GV::IndexSet::IndexType index = gv.indexSet().subIndex(e,
610 coeffs.localKey(i).subEntity(),
611 coeffs.localKey(i).codim());
614 GFS::Ordering::Traits::DOFIndexAccessor::store(*it,gt,index,coeffs.localKey(i).index());
622 template<
typename GC,
typename LC>
626 typedef typename LC::const_iterator local_col_iterator;
627 typedef typename LC::value_type::second_type::const_iterator local_row_iterator;
628 typedef typename GC::iterator global_col_iterator;
629 typedef typename GC::value_type::second_type global_row_type;
631 for (local_col_iterator cit=lc.begin(); cit!=lc.end(); ++cit)
635 global_col_iterator gcit = gc.insert(std::make_pair(std::ref(this->
dofIndex(cit->first)),global_row_type())).first;
638 for (local_row_iterator rit=(cit->second).begin(); rit!=(cit->second).end(); ++rit)
639 gcit->second[this->dofIndex(rit->first)] = rit->second;
651 typename FESwitch::Store
pfe;
655 template<
typename Gr
idFunctionSpace,
typename Params>
656 TypeTree::GenericLeafNodeTransformation<
667 template <
typename GFS,
typename TAG=AnySpaceTag>
683 template <
typename GFS,
typename TAG>
685 public TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type
687 typedef typename TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type BaseT;
688 typedef typename BaseT::Traits::IndexContainer::size_type I;
689 typedef typename BaseT::Traits::IndexContainer::size_type LocalIndex;
707 : BaseT(TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::transform(gfs))
722 LocalIndex
localIndex (
typename Traits::IndexContainer::size_type index)
const
724 return LocalIndex(BaseT::localIndex(index));
730 void getChild ()
const;
738 template <
typename GFS>
740 public TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type
742 typedef typename TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type BaseT;
759 : BaseT(TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::transform(gfs))
766 : BaseT(*TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::transform_storage(pgfs))
GridViewLocalFunctionSpaceBaseNode(std::shared_ptr< const GFS > gfs)
construct from global function space
Definition: localfunctionspace.hh:309
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:449
GFS::Traits::ConstraintsType ConstraintsType
Type of constraints engine.
Definition: localfunctionspace.hh:525
const std::size_t offset
Definition: localfunctionspace.hh:74
Traits::DOFIndexContainer _dof_index_storage
Definition: localfunctionspace.hh:278
traits for local function space on a gridview
Definition: localfunctionspace.hh:286
Definition: localfunctionspace.hh:419
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:540
Definition: localfunctionspacetags.hh:40
Create a local function space from a global function space.
Definition: localfunctionspace.hh:668
GFS::Traits::FiniteElementType FiniteElementType
Type of local finite element.
Definition: localfunctionspace.hh:520
Traits::IndexContainer::size_type offset
Definition: localfunctionspace.hh:281
Traits::DOFIndexContainer * _dof_indices
Definition: localfunctionspace.hh:279
PowerLocalFunctionSpaceTag ImplementationTag
Definition: localfunctionspace.hh:385
Tag denoting a CompositeLocalFunctionSpace.
Definition: gridfunctionspace/tags.hh:273
Definition: localfunctionspace.hh:495
CompositeLocalFunctionSpaceNode(std::shared_ptr< const GFS > gfs, const Transformation &t, std::shared_ptr< Children >...children)
Definition: localfunctionspace.hh:466
LocalFunctionSpace(const LocalFunctionSpace &lfs)
Definition: localfunctionspace.hh:712
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:377
traits mapping global function space information to local function space
Definition: localfunctionspace.hh:155
void bind(const typename Traits::Element &e)
bind local function space to entity
Definition: localfunctionspace.hh:405
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 GridFunctionSpace
Type of the underlying grid function space.
Definition: localfunctionspace.hh:161
void bind(NodeType &node, const typename Traits::Element &e)
bind local function space to entity
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:546
LeafLocalFunctionSpaceTag ImplementationTag
Definition: localfunctionspace.hh:554
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:371
LocalFunctionSpaceBaseNode(std::shared_ptr< const GFS > gfs)
construct from global function space
Definition: localfunctionspace.hh:198
traits for single component local function space
Definition: localfunctionspace.hh:517
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:183
base class for tuples of grid function spaces base class that holds implementation of the methods thi...
Definition: compositegridfunctionspace.hh:40
PowerCompositeLocalFunctionSpaceTraits< GFS, DOFIndex, CompositeLocalFunctionSpaceNode > Traits
Definition: localfunctionspace.hh:461
LocalIndex localIndex(typename Traits::IndexContainer::size_type index) const
Definition: localfunctionspace.hh:722
void insert_constraints(const LC &lc, GC &gc) const
Definition: localfunctionspace.hh:623
BaseT::Traits Traits
Definition: localfunctionspace.hh:704
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:549
CompositeLocalFunctionSpaceNode(const GFS &gfs, const Transformation &t, std::shared_ptr< Children >...children)
Definition: localfunctionspace.hh:474
PowerLocalFunctionSpaceNode(const GFS &gfs, const Transformation &t, const std::array< std::shared_ptr< ChildLFS >, k > &children)
Definition: localfunctionspace.hh:397
Definition: localfunctionspace.hh:492
friend struct ClearSizeVisitor
Definition: localfunctionspace.hh:543
LeafLocalFunctionSpaceNode(std::shared_ptr< const GFS > gfs, const Transformation &t)
initialize with grid function space
Definition: localfunctionspace.hh:565
CompositeLocalFunctionSpaceTag ImplementationTag
Definition: localfunctionspace.hh:463
std::vector< DI > DOFIndexContainer
Type of container to store multiindices.
Definition: localfunctionspace.hh:173
CompositeLocalFunctionSpaceNode< SourceNode, typename Transformation::DOFIndex, TC...> type
Definition: localfunctionspace.hh:497
Definition: localfunctionspace.hh:299
LocalFunctionSpace(std::shared_ptr< const GFS > pgfs)
Definition: localfunctionspace.hh:765
Traits::IndexContainer::size_type size() const
get current size
Definition: localfunctionspace.hh:206
PowerCompositeLocalFunctionSpaceTraits< GFS, DOFIndex, PowerLocalFunctionSpaceNode > Traits
Definition: localfunctionspace.hh:383
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:692
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:189
LeafLocalFunctionSpaceTraits< GFS, DOFIndex, LeafLocalFunctionSpaceNode > Traits
Definition: localfunctionspace.hh:552
A multi-index representing a degree of freedom in a GridFunctionSpace.
Definition: dofindex.hh:146
LocalFunctionSpace(const LocalFunctionSpace &lfs)
Definition: localfunctionspace.hh:772
Definition: localfunctionspace.hh:178
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:455
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:458
Definition: lfsindexcache.hh:240
Tag denoting a PowerLocalFunctionSpace.
Definition: gridfunctionspace/tags.hh:270
std::shared_ptr< GFS const > pgfs
Definition: localfunctionspace.hh:277
Definition: gridfunctionspace/tags.hh:32
GFS GridFunctionSpaceType
Type of the underlying grid function space.
Definition: localfunctionspace.hh:158
N NodeType
type of local function space node
Definition: localfunctionspace.hh:358
const Entity & e
Definition: localfunctionspace.hh:111
friend struct ClearSizeVisitor
Definition: localfunctionspace.hh:374
Tag denoting a LeafLocalFunctionSpace.
Definition: gridfunctionspace/tags.hh:276
const Traits::FiniteElementType & finiteElement() const
get finite element
Definition: localfunctionspace.hh:577
Definition: adaptivity.hh:27
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:701
friend struct ClearSizeVisitor
Definition: localfunctionspace.hh:452
GridViewLocalFunctionSpaceBaseTraits< GFS, DOFIndex > Traits
Definition: localfunctionspace.hh:306
LocalFunctionSpaceBaseTraits< GFS, DOFIndex > Traits
Definition: localfunctionspace.hh:195
Definition: localfunctionspace.hh:416
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)
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:590
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:389
Definition: gridfunctionspace/tags.hh:26
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:698
const GFS & gridFunctionSpace() const
Returns the GridFunctionSpace underlying this LocalFunctionSpace.
Definition: localfunctionspace.hh:264
Definition: gridfunctionspace/tags.hh:30
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:380
void bind(const typename Traits::Element &e)
bind local function space to entity
Definition: localfunctionspace.hh:644
void bind(const typename Traits::Element &e)
bind local function space to entity
Definition: localfunctionspace.hh:482
LocalFunctionSpace(const GFS &gfs)
Definition: localfunctionspace.hh:758
GFS::Traits::SizeType SizeType
Type to store indices from Backend.
Definition: localfunctionspace.hh:164
Definition: localfunctionspace.hh:363
GFS::Traits::GridViewType GridViewType
Type of the grid view that the underlying grid function space is defined on.
Definition: localfunctionspace.hh:289
FESwitch::Store pfe
Definition: localfunctionspace.hh:651
traits for multi component local function space
Definition: localfunctionspace.hh:355
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
GFS::Traits::GridViewType GridView
Type of the grid view that the underlying grid function space is defined on.
Definition: localfunctionspace.hh:292
std::size_t subSpaceDepth() const
Definition: localfunctionspace.hh:211
Traits::IndexContainer::size_type localVectorSize() const
get size of an appropriate local vector object
Definition: localfunctionspace.hh:230
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:186
A grid function space.
Definition: gridfunctionspace.hh:108
Traits::IndexContainer::size_type n
Definition: localfunctionspace.hh:280
base class for tuples of grid function spaces product of identical grid function spaces base class th...
Definition: powergridfunctionspace.hh:40
GFS::Traits::ConstraintsType Constraints
Definition: localfunctionspace.hh:527
std::vector< SizeType > IndexContainer
Type of container to store indices.
Definition: localfunctionspace.hh:167
friend struct ClearSizeVisitor
Definition: localfunctionspace.hh:695
GFS::Traits::FiniteElementType FiniteElement
Definition: localfunctionspace.hh:522
DI DOFIndex
Type of MultiIndex associated with this LocalFunctionSpace.
Definition: localfunctionspace.hh:170
Definition: localfunctionspace.hh:441
LocalFunctionSpace(const GFS &gfs)
Definition: localfunctionspace.hh:706
const Traits::ConstraintsType & constraints() const
get constraints engine
Definition: localfunctionspace.hh:583
single component local function space
Definition: localfunctionspace.hh:533
PowerLocalFunctionSpaceNode< SourceNode, typename Transformation::DOFIndex, TC, SourceNode::CHILDREN > type
Definition: localfunctionspace.hh:421
void setup(NodeType &node)
Definition: localfunctionspace.hh:271
LeafLocalFunctionSpaceNode(const GFS &gfs, const Transformation &t)
Definition: localfunctionspace.hh:571
GridViewType::Traits::template Codim< 0 >::Entity Element
Type of codim 0 entity in the grid.
Definition: localfunctionspace.hh:295