3 #ifndef DUNE_PDELAB_GRIDFUNCTIONSPACE_LOCALFUNCTIONSPACE_HH
4 #define DUNE_PDELAB_GRIDFUNCTIONSPACE_LOCALFUNCTIONSPACE_HH
8 #include <dune/common/stdstreams.hh>
9 #include <dune/common/shared_ptr.hh>
11 #include <dune/geometry/referenceelements.hh>
13 #include <dune/localfunctions/common/interfaceswitch.hh>
14 #include <dune/localfunctions/common/localkey.hh>
16 #include <dune/typetree/typetree.hh>
36 template<
typename =
int>
37 struct PropagateGlobalStorageVisitor
38 :
public TypeTree::TreeVisitor
39 ,
public TypeTree::DynamicTraversal
42 template<
typename LFS,
typename Child,
typename TreePath,
typename ChildIndex>
43 void beforeChild(
const LFS& lfs, Child& child, TreePath treePath, ChildIndex childIndex)
const
45 child._dof_indices = lfs._dof_indices;
52 template<
typename =
int>
53 struct ClearSizeVisitor
54 :
public TypeTree::TreeVisitor
55 ,
public TypeTree::DynamicTraversal
58 template<
typename Node,
typename TreePath>
59 void pre(Node& node, TreePath treePath)
64 template<
typename Node,
typename TreePath>
65 void leaf(Node& node, TreePath treePath)
71 ClearSizeVisitor(std::size_t offset_)
80 template<
typename Entity,
bool fast>
81 struct ComputeSizeVisitor
82 :
public TypeTree::TreeVisitor
83 ,
public TypeTree::DynamicTraversal
86 template<
typename Node,
typename TreePath>
87 void pre(Node& node, TreePath treePath)
92 template<
typename Node,
typename TreePath>
93 void post(Node& node, TreePath treePath)
95 node.n =
offset - node.offset;
98 template<
typename Node,
typename TreePath>
99 void leaf(Node& node, TreePath treePath)
105 node.n = node.pgfs->finiteElementMap().maxLocalSize();
106 Node::FESwitch::setStore(node.pfe, node.pgfs->finiteElementMap().find(
e));
110 Node::FESwitch::setStore(node.pfe, node.pgfs->finiteElementMap().find(
e));
111 node.n = Node::FESwitch::basis(*node.pfe).size();
116 ComputeSizeVisitor(
const Entity& entity, std::size_t offset_ = 0)
127 template<
typename Entity,
bool fast>
128 struct FillIndicesVisitor
129 :
public TypeTree::TreeVisitor
130 ,
public TypeTree::DynamicTraversal
133 template<
typename Node,
typename TreePath>
134 void leaf(Node& node, TreePath treePath)
137 node.dofIndices(
e,node._dof_indices->begin()+node.offset,node._dof_indices->begin()+node.offset+node.n,std::integral_constant<bool,fast>{});
140 template<
typename Node,
typename Child,
typename TreePath,
typename ChildIndex>
141 void afterChild(
const Node& node,
const Child& child, TreePath treePath, ChildIndex childIndex)
148 for (std::size_t i = 0; i<child.n; ++i)
151 (*node._dof_indices)[child.offset+i].treeIndex().push_back(childIndex);
155 FillIndicesVisitor(
const Entity& entity)
169 template<
typename GFS,
typename DI>
192 template <
typename GFS,
typename DOFIndex>
195 typedef typename GFS::Traits::Backend B;
200 template<
typename,
bool>
203 template<
typename,
bool>
206 template<
typename LFS,
typename C,
typename Tag,
bool>
221 typename Traits::IndexContainer::size_type
size ()
const
232 typename Traits::IndexContainer::size_type
maxSize ()
const
251 typename Traits::IndexContainer::size_type
localIndex (
typename Traits::IndexContainer::size_type
index)
const
272 std::cout <<
n <<
" indices = (";
273 for (
typename Traits::IndexContainer::size_type k=0; k<
n; k++)
275 std::cout <<
")" << std::endl;
285 template<
typename NodeType>
289 TypeTree::applyToTree(node,PropagateGlobalStorageVisitor<>());
292 std::shared_ptr<GFS const>
pgfs;
295 typename Traits::IndexContainer::size_type
n;
296 typename Traits::IndexContainer::size_type
offset;
300 template<
typename GFS,
typename DOFIndex>
307 typedef typename GFS::Traits::GridViewType
GridView;
315 template <
typename GFS,
typename DOFIndex>
319 typedef typename GFS::Traits::Backend B;
344 template<
typename NodeType,
bool fast = false>
345 void bind (NodeType& node,
const typename Traits::Element&
e, std::integral_constant<bool,fast> = std::integral_constant<bool,fast>{});
348 template <
typename GFS,
typename DOFIndex>
349 template <
typename NodeType,
bool fast>
352 std::integral_constant<bool,fast>)
355 assert(&node ==
this);
358 ComputeSizeVisitor<Element,fast> csv(
e);
359 TypeTree::applyToTree(node,csv);
363 FillIndicesVisitor<Element,fast> fiv(
e);
364 TypeTree::applyToTree(node,fiv);
372 template<
typename GFS,
typename DOFIndex,
typename N>
380 template<
typename GFS,
typename DOFIndex,
typename ChildLFS, std::
size_t k>
383 public TypeTree::PowerNode<ChildLFS,k>
386 typedef TypeTree::PowerNode<ChildLFS,k> TreeNode;
394 template<
typename,
bool>
397 template<
typename,
bool>
406 template<
typename Transformation>
408 const Transformation& t,
409 const std::array<std::shared_ptr<ChildLFS>,k>& children)
414 template<
typename Transformation>
416 const Transformation& t,
417 const std::array<std::shared_ptr<ChildLFS>,k>& children)
418 :
BaseT(stackobject_to_shared_ptr(gfs))
423 template<
bool fast = false>
424 void bind (
const typename Traits::Element&
e, std::integral_constant<bool,fast> fast_ = std::integral_constant<bool,fast>{})
434 template<
typename SourceNode,
typename Transformation>
437 template<
typename TC>
445 template<
typename PowerGr
idFunctionSpace,
typename Params>
446 TypeTree::TemplatizedGenericPowerNodeTransformation<
459 template<
typename GFS,
typename DOFIndex,
typename... Children>
462 ,
public TypeTree::CompositeNode<Children...>
465 typedef TypeTree::CompositeNode<Children...> NodeType;
473 template<
typename,
bool>
476 template<
typename,
bool>
484 template<
typename Transformation>
486 const Transformation& t,
487 std::shared_ptr<Children>... children)
489 , NodeType(children...)
492 template<
typename Transformation>
494 const Transformation& t,
495 std::shared_ptr<Children>... children)
496 :
BaseT(stackobject_to_shared_ptr(gfs))
497 , NodeType(children...)
501 template<
bool fast = false>
502 void bind (
const typename Traits::Element&
e, std::integral_constant<bool,fast> fast_ = std::integral_constant<bool,fast>{})
511 template<
typename SourceNode,
typename Transformation>
514 template<
typename... TC>
522 template<
typename CompositeGr
idFunctionSpace,
typename Params>
523 TypeTree::TemplatizedGenericCompositeNodeTransformation<
536 template<
typename GFS,
typename DOFIndex,
typename N>
552 template<
typename GFS,
typename DOFIndex>
555 ,
public TypeTree::LeafNode
565 template<
typename,
bool>
568 template<
typename,
bool>
577 typedef FiniteElementInterfaceSwitch<
584 template<
typename Transformation>
590 template<
typename Transformation>
592 :
BaseT(stackobject_to_shared_ptr(gfs))
606 return this->
pgfs->constraints();
610 template<
typename Entity,
typename DOFIndexIterator,
bool fast>
611 void dofIndices(
const Entity&
e, DOFIndexIterator it, DOFIndexIterator endit, std::integral_constant<bool,fast>)
617 GFS::Ordering::Traits::DOFIndexAccessor::store(*it,gt,
index,0);
623 const typename FESwitch::Coefficients &coeffs =
624 FESwitch::coefficients(*
pfe);
626 using EntitySet =
typename GFS::Traits::EntitySet;
629 auto refEl = Dune::ReferenceElements<double,EntitySet::dimension>::general(this->
pfe->type());
631 for (std::size_t i = 0; i < std::size_t(coeffs.size()); ++i, ++it)
634 auto gt = refEl.type(coeffs.localKey(i).subEntity(),
635 coeffs.localKey(i).codim());
638 auto index = es.indexSet().subIndex(
e,
639 coeffs.localKey(i).subEntity(),
640 coeffs.localKey(i).codim());
643 GFS::Ordering::Traits::DOFIndexAccessor::store(*it,gt,
index,coeffs.localKey(i).index());
652 template<
typename GC,
typename LC>
656 typedef typename LC::const_iterator local_col_iterator;
657 typedef typename LC::value_type::second_type::const_iterator local_row_iterator;
658 typedef typename GC::iterator global_col_iterator;
659 typedef typename GC::value_type::second_type global_row_type;
661 for (local_col_iterator cit=lc.begin(); cit!=lc.end(); ++cit)
665 global_col_iterator gcit = gc.insert(std::make_pair(std::ref(this->
dofIndex(cit->first)),global_row_type())).first;
668 for (local_row_iterator rit=(cit->second).begin(); rit!=(cit->second).end(); ++rit)
669 gcit->second[this->
dofIndex(rit->first)] = rit->second;
674 template<
bool fast = false>
675 void bind (
const typename Traits::Element&
e, std::integral_constant<bool,fast> fast_ = std::integral_constant<bool,fast>{})
682 typename FESwitch::Store
pfe;
686 template<
typename Gr
idFunctionSpace,
typename Params>
687 TypeTree::GenericLeafNodeTransformation<
698 template <
typename GFS,
typename TAG=AnySpaceTag>
714 template <
typename GFS,
typename TAG>
716 public TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type
718 typedef typename TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type BaseT;
719 typedef typename BaseT::Traits::IndexContainer::size_type I;
720 typedef typename BaseT::Traits::IndexContainer::size_type LocalIndex;
738 : BaseT(TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::transform(gfs))
755 return LocalIndex(BaseT::localIndex(
index));
761 void getChild ()
const;
769 template <
typename GFS>
771 public TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type
773 typedef typename TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type BaseT;
781 template<
typename,
bool>
784 template<
typename,
bool>
790 : BaseT(TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::transform(gfs))
797 : BaseT(*TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::transform_storage(
pgfs))
std::size_t index
Definition: interpolate.hh:97
const Entity & e
Definition: localfunctionspace.hh:121
const std::size_t offset
Definition: localfunctionspace.hh:75
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
Dune::TypeTree::GenericLeafNodeTransformation< LeafNode, GridFunctionToLocalViewTransformation, Imp::LocalGridViewFunctionAdapter< LeafNode > > registerNodeTransformation(LeafNode *l, GridFunctionToLocalViewTransformation *t, GridFunctionTag *tag)
A multi-index representing a degree of freedom in a GridFunctionSpace.
Definition: dofindex.hh:148
base class for tuples of grid function spaces base class that holds implementation of the methods thi...
Definition: compositegridfunctionspace.hh:53
A grid function space.
Definition: gridfunctionspace.hh:186
Definition: lfsindexcache.hh:245
traits mapping global function space information to local function space
Definition: localfunctionspace.hh:171
GFS GridFunctionSpace
Type of the underlying grid function space.
Definition: localfunctionspace.hh:176
std::vector< SizeType > IndexContainer
Type of container to store indices.
Definition: localfunctionspace.hh:182
GFS::Traits::SizeType SizeType
Type to store indices from Backend.
Definition: localfunctionspace.hh:179
GFS GridFunctionSpaceType
Type of the underlying grid function space.
Definition: localfunctionspace.hh:173
DI DOFIndex
Type of MultiIndex associated with this LocalFunctionSpace.
Definition: localfunctionspace.hh:185
std::vector< DI > DOFIndexContainer
Type of container to store multiindices.
Definition: localfunctionspace.hh:188
Definition: localfunctionspace.hh:194
const GFS & gridFunctionSpace() const
Returns the GridFunctionSpace underlying this LocalFunctionSpace.
Definition: localfunctionspace.hh:279
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:201
Traits::DOFIndexContainer _dof_index_storage
Definition: localfunctionspace.hh:293
LocalFunctionSpaceBaseTraits< GFS, DOFIndex > Traits
Definition: localfunctionspace.hh:210
Traits::IndexContainer::size_type localVectorSize() const
get size of an appropriate local vector object
Definition: localfunctionspace.hh:245
Traits::IndexContainer::size_type n
Definition: localfunctionspace.hh:295
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:204
Traits::IndexContainer::size_type offset
Definition: localfunctionspace.hh:296
void debug() const
print debug information about this local function space
Definition: localfunctionspace.hh:270
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:264
Traits::DOFIndexContainer * _dof_indices
Definition: localfunctionspace.hh:294
Traits::IndexContainer::size_type maxSize() const
get maximum possible size (which is maxLocalSize from grid function space)
Definition: localfunctionspace.hh:232
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:251
LocalFunctionSpaceBaseNode(std::shared_ptr< const GFS > gfs)
construct from global function space
Definition: localfunctionspace.hh:213
void setup(NodeType &node)
Definition: localfunctionspace.hh:286
std::shared_ptr< GFS const > pgfs
Definition: localfunctionspace.hh:292
Traits::IndexContainer::size_type size() const
get current size
Definition: localfunctionspace.hh:221
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:198
std::size_t subSpaceDepth() const
Definition: localfunctionspace.hh:226
traits for local function space on a gridview
Definition: localfunctionspace.hh:302
GFS::Traits::GridViewType GridViewType
Type of the grid view that the underlying grid function space is defined on.
Definition: localfunctionspace.hh:304
typename GFS::Traits::EntitySet EntitySet
Definition: localfunctionspace.hh:309
GFS::Traits::GridViewType GridView
Type of the grid view that the underlying grid function space is defined on.
Definition: localfunctionspace.hh:307
typename EntitySet::Element Element
Type of codim 0 entity in the grid.
Definition: localfunctionspace.hh:312
Definition: localfunctionspace.hh:318
GridViewLocalFunctionSpaceBaseTraits< GFS, DOFIndex > Traits
Definition: localfunctionspace.hh:323
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
GridViewLocalFunctionSpaceBaseNode(std::shared_ptr< const GFS > gfs)
construct from global function space
Definition: localfunctionspace.hh:326
traits for multi component local function space
Definition: localfunctionspace.hh:374
N NodeType
type of local function space node
Definition: localfunctionspace.hh:376
Definition: localfunctionspace.hh:384
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:407
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:395
friend struct ClearSizeVisitor
Definition: localfunctionspace.hh:392
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:398
PowerLocalFunctionSpaceTag ImplementationTag
Definition: localfunctionspace.hh:403
PowerCompositeLocalFunctionSpaceTraits< GFS, DOFIndex, PowerLocalFunctionSpaceNode > Traits
Definition: localfunctionspace.hh:401
PowerLocalFunctionSpaceNode(const GFS &gfs, const Transformation &t, const std::array< std::shared_ptr< ChildLFS >, k > &children)
Definition: localfunctionspace.hh:415
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:424
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:389
Definition: localfunctionspace.hh:436
Definition: localfunctionspace.hh:439
PowerLocalFunctionSpaceNode< SourceNode, typename Transformation::DOFIndex, TC, TypeTree::StaticDegree< SourceNode >::value > type
Definition: localfunctionspace.hh:440
Definition: localfunctionspace.hh:463
CompositeLocalFunctionSpaceNode(const GFS &gfs, const Transformation &t, std::shared_ptr< Children >... children)
Definition: localfunctionspace.hh:493
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:474
friend struct ClearSizeVisitor
Definition: localfunctionspace.hh:471
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:502
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:477
CompositeLocalFunctionSpaceNode(std::shared_ptr< const GFS > gfs, const Transformation &t, std::shared_ptr< Children >... children)
Definition: localfunctionspace.hh:485
PowerCompositeLocalFunctionSpaceTraits< GFS, DOFIndex, CompositeLocalFunctionSpaceNode > Traits
Definition: localfunctionspace.hh:480
CompositeLocalFunctionSpaceTag ImplementationTag
Definition: localfunctionspace.hh:482
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:468
Definition: localfunctionspace.hh:513
Definition: localfunctionspace.hh:516
CompositeLocalFunctionSpaceNode< SourceNode, typename Transformation::DOFIndex, TC... > type
Definition: localfunctionspace.hh:517
traits for single component local function space
Definition: localfunctionspace.hh:538
GFS::Traits::FiniteElementType FiniteElement
Definition: localfunctionspace.hh:542
GFS::Traits::ConstraintsType ConstraintsType
Type of constraints engine.
Definition: localfunctionspace.hh:545
GFS::Traits::FiniteElementType FiniteElementType
Type of local finite element.
Definition: localfunctionspace.hh:540
GFS::Traits::ConstraintsType Constraints
Definition: localfunctionspace.hh:547
single component local function space
Definition: localfunctionspace.hh:556
LeafLocalFunctionSpaceNode(const GFS &gfs, const Transformation &t)
Definition: localfunctionspace.hh:591
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:611
LeafLocalFunctionSpaceTraits< GFS, DOFIndex, LeafLocalFunctionSpaceNode > Traits
Definition: localfunctionspace.hh:572
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:566
friend struct ClearSizeVisitor
Definition: localfunctionspace.hh:563
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:569
LeafLocalFunctionSpaceNode(std::shared_ptr< const GFS > gfs, const Transformation &t)
initialize with grid function space
Definition: localfunctionspace.hh:585
const Traits::ConstraintsType & constraints() const
get constraints engine
Definition: localfunctionspace.hh:604
void insert_constraints(const LC &lc, GC &gc) const
Definition: localfunctionspace.hh:653
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:675
LeafLocalFunctionSpaceTag ImplementationTag
Definition: localfunctionspace.hh:574
const Traits::FiniteElementType & finiteElement() const
get finite element
Definition: localfunctionspace.hh:597
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:560
FESwitch::Store pfe
Definition: localfunctionspace.hh:682
Create a local function space from a global function space.
Definition: localfunctionspace.hh:717
friend struct ClearSizeVisitor
Definition: localfunctionspace.hh:726
friend struct ComputeSizeVisitor
Definition: localfunctionspace.hh:729
LocalIndex localIndex(typename Traits::IndexContainer::size_type index) const
Definition: localfunctionspace.hh:753
LocalFunctionSpace(const GFS &gfs)
Definition: localfunctionspace.hh:737
LocalFunctionSpace(const LocalFunctionSpace &lfs)
Definition: localfunctionspace.hh:743
BaseT::Traits Traits
Definition: localfunctionspace.hh:735
friend struct FillIndicesVisitor
Definition: localfunctionspace.hh:732
friend struct PropagateGlobalStorageVisitor
Definition: localfunctionspace.hh:723
LocalFunctionSpace(std::shared_ptr< const GFS > pgfs)
Definition: localfunctionspace.hh:796
LocalFunctionSpace(const GFS &gfs)
Definition: localfunctionspace.hh:789
LocalFunctionSpace(const LocalFunctionSpace &lfs)
Definition: localfunctionspace.hh:803
Definition: localfunctionspacetags.hh:40
base class for tuples of grid function spaces product of identical grid function spaces base class th...
Definition: powergridfunctionspace.hh:49
Definition: gridfunctionspace/tags.hh:26
Definition: gridfunctionspace/tags.hh:30
Definition: gridfunctionspace/tags.hh:32
Tag denoting a PowerLocalFunctionSpace.
Definition: gridfunctionspace/tags.hh:194
Tag denoting a CompositeLocalFunctionSpace.
Definition: gridfunctionspace/tags.hh:197
Tag denoting a LeafLocalFunctionSpace.
Definition: gridfunctionspace/tags.hh:200