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>
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;
183 friend struct PropagateGlobalStorageVisitor;
186 friend struct ComputeSizeVisitor;
189 friend struct FillIndicesVisitor;
191 template<
typename LFS,
typename C,
typename Tag>
200 , _dof_index_storage()
201 , _dof_indices(&_dof_index_storage)
206 typename Traits::IndexContainer::size_type
size ()
const 217 typename Traits::IndexContainer::size_type
maxSize ()
const 220 return _dof_indices->size();
232 return _dof_indices->size();
236 typename Traits::IndexContainer::size_type
localIndex (
typename Traits::IndexContainer::size_type index)
const 251 return (*_dof_indices)[
offset + index];
257 std::cout << n <<
" indices = (";
258 for (
typename Traits::IndexContainer::size_type k=0; k<n; k++)
259 std::cout << (*_dof_indices)[localIndex(k)] <<
" ";
260 std::cout <<
")" << std::endl;
270 template<
typename NodeType>
273 _dof_index_storage.resize(gridFunctionSpace().ordering().maxLocalSize());
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;
300 template <
typename GFS,
typename DOFIndex>
304 typedef typename GFS::Traits::Backend B;
329 template<
typename NodeType>
330 void bind (NodeType& node,
const typename Traits::Element&
e);
333 template <
typename GFS,
typename DOFIndex>
334 template <
typename NodeType>
339 assert(&node ==
this);
342 ComputeSizeVisitor<Element> csv(e);
343 TypeTree::applyToTree(node,csv);
347 FillIndicesVisitor<Element> fiv(e);
348 TypeTree::applyToTree(node,fiv);
356 template<
typename GFS,
typename DOFIndex,
typename N>
364 template<
typename GFS,
typename DOFIndex,
typename ChildLFS, std::
size_t k>
367 public TypeTree::PowerNode<ChildLFS,k>
370 typedef TypeTree::PowerNode<ChildLFS,k> TreeNode;
373 friend struct PropagateGlobalStorageVisitor;
376 friend struct ClearSizeVisitor;
379 friend struct ComputeSizeVisitor;
382 friend struct FillIndicesVisitor;
390 template<
typename Transformation>
392 const Transformation& t,
393 const std::array<std::shared_ptr<ChildLFS>,k>& children)
398 template<
typename Transformation>
400 const Transformation& t,
401 const std::array<std::shared_ptr<ChildLFS>,k>& children)
402 : BaseT(stackobject_to_shared_ptr(gfs))
407 void bind (
const typename Traits::Element&
e)
410 BaseT::bind(*
this,e);
417 template<
typename SourceNode,
typename Transformation>
420 template<
typename TC>
428 template<
typename PowerGr
idFunctionSpace,
typename Params>
429 TypeTree::TemplatizedGenericPowerNodeTransformation<
442 template<
typename GFS,
typename DOFIndex,
typename... Children>
445 ,
public TypeTree::CompositeNode<Children...>
448 typedef TypeTree::CompositeNode<Children...> NodeType;
451 friend struct PropagateGlobalStorageVisitor;
454 friend struct ClearSizeVisitor;
457 friend struct ComputeSizeVisitor;
460 friend struct FillIndicesVisitor;
467 template<
typename Transformation>
469 const Transformation& t,
470 std::shared_ptr<Children>... children)
472 , NodeType(children...)
475 template<
typename Transformation>
477 const Transformation& t,
478 std::shared_ptr<Children>... children)
479 : BaseT(stackobject_to_shared_ptr(gfs))
480 , NodeType(children...)
484 void bind (
const typename Traits::Element&
e)
487 BaseT::bind(*
this,e);
493 template<
typename SourceNode,
typename Transformation>
496 template<
typename... TC>
504 template<
typename CompositeGr
idFunctionSpace,
typename Params>
505 TypeTree::TemplatizedGenericCompositeNodeTransformation<
518 template<
typename GFS,
typename DOFIndex,
typename N>
534 template<
typename GFS,
typename DOFIndex>
537 ,
public TypeTree::LeafNode
542 friend struct PropagateGlobalStorageVisitor;
545 friend struct ClearSizeVisitor;
548 friend struct ComputeSizeVisitor;
551 friend struct FillIndicesVisitor;
559 typedef FiniteElementInterfaceSwitch<
560 typename Traits::FiniteElementType
566 template<
typename Transformation>
572 template<
typename Transformation>
574 : BaseT(stackobject_to_shared_ptr(gfs))
587 return this->pgfs->constraints();
591 template<
typename Entity,
typename DOFIndexIterator>
592 void dofIndices(
const Entity&
e, DOFIndexIterator it, DOFIndexIterator endit)
595 const typename FESwitch::Coefficients &coeffs =
596 FESwitch::coefficients(*pfe);
598 using EntitySet =
typename GFS::Traits::EntitySet;
599 auto es = this->gridFunctionSpace().entitySet();
601 const Dune::ReferenceElement<double,EntitySet::dimension>& refEl =
602 Dune::ReferenceElements<double,EntitySet::dimension>::general(this->pfe->type());
604 for (std::size_t i = 0; i < std::size_t(coeffs.size()); ++i, ++it)
607 auto gt = refEl.type(coeffs.localKey(i).subEntity(),
608 coeffs.localKey(i).codim());
611 auto index = es.indexSet().subIndex(e,
612 coeffs.localKey(i).subEntity(),
613 coeffs.localKey(i).codim());
616 GFS::Ordering::Traits::DOFIndexAccessor::store(*it,gt,index,coeffs.localKey(i).index());
624 template<
typename GC,
typename LC>
628 typedef typename LC::const_iterator local_col_iterator;
629 typedef typename LC::value_type::second_type::const_iterator local_row_iterator;
630 typedef typename GC::iterator global_col_iterator;
631 typedef typename GC::value_type::second_type global_row_type;
633 for (local_col_iterator cit=lc.begin(); cit!=lc.end(); ++cit)
637 global_col_iterator gcit = gc.insert(std::make_pair(std::ref(this->dofIndex(cit->first)),global_row_type())).first;
640 for (local_row_iterator rit=(cit->second).begin(); rit!=(cit->second).end(); ++rit)
641 gcit->second[this->dofIndex(rit->first)] = rit->second;
646 void bind (
const typename Traits::Element&
e)
649 BaseT::bind(*
this,e);
653 typename FESwitch::Store
pfe;
657 template<
typename Gr
idFunctionSpace,
typename Params>
658 TypeTree::GenericLeafNodeTransformation<
669 template <
typename GFS,
typename TAG=AnySpaceTag>
685 template <
typename GFS,
typename TAG>
687 public TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type
689 typedef typename TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type BaseT;
690 typedef typename BaseT::Traits::IndexContainer::size_type I;
691 typedef typename BaseT::Traits::IndexContainer::size_type LocalIndex;
694 friend struct PropagateGlobalStorageVisitor;
697 friend struct ClearSizeVisitor;
700 friend struct ComputeSizeVisitor;
703 friend struct FillIndicesVisitor;
709 : BaseT(TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::transform(gfs))
720 this->_dof_indices = &(this->_dof_index_storage);
724 LocalIndex
localIndex (
typename Traits::IndexContainer::size_type index)
const 726 return LocalIndex(BaseT::localIndex(index));
732 void getChild ()
const;
740 template <
typename GFS>
742 public TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type
744 typedef typename TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::Type BaseT;
747 friend struct PropagateGlobalStorageVisitor;
750 friend struct ClearSizeVisitor;
753 friend struct ComputeSizeVisitor;
756 friend struct FillIndicesVisitor;
761 : BaseT(TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::transform(gfs))
763 this->_dof_indices = &(this->_dof_index_storage);
768 : BaseT(*TypeTree::TransformTree<GFS,gfs_to_lfs<GFS> >::transform_storage(pgfs))
770 this->_dof_indices = &(this->_dof_index_storage);
780 this->_dof_indices = &(this->_dof_index_storage);
790 #endif // DUNE_PDELAB_GRIDFUNCTIONSPACE_LOCALFUNCTIONSPACE_HH PowerLocalFunctionSpaceTag ImplementationTag
Definition: localfunctionspace.hh:387
LeafLocalFunctionSpaceNode(std::shared_ptr< const GFS > gfs, const Transformation &t)
initialize with grid function space
Definition: localfunctionspace.hh:567
Traits::IndexContainer::size_type n
Definition: localfunctionspace.hh:280
Traits::IndexContainer::size_type size() const
get current size
Definition: localfunctionspace.hh:206
PowerCompositeLocalFunctionSpaceTraits< GFS, DOFIndex, PowerLocalFunctionSpaceNode > Traits
Definition: localfunctionspace.hh:385
base class for tuples of grid function spaces product of identical grid function spaces base class th...
Definition: powergridfunctionspace.hh:40
Traits::DOFIndexContainer _dof_index_storage
Definition: localfunctionspace.hh:278
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:391
LocalIndex localIndex(typename Traits::IndexContainer::size_type index) const
Definition: localfunctionspace.hh:724
Traits::IndexContainer::size_type offset
Definition: localfunctionspace.hh:281
GFS::Traits::GridViewType GridViewType
Type of the grid view that the underlying grid function space is defined on.
Definition: localfunctionspace.hh:289
GFS::Traits::FiniteElementType FiniteElement
Definition: localfunctionspace.hh:524
LocalFunctionSpaceBaseTraits< GFS, DOFIndex > Traits
Definition: localfunctionspace.hh:195
GFS::Traits::SizeType SizeType
Type to store indices from Backend.
Definition: localfunctionspace.hh:164
Definition: localfunctionspace.hh:301
LocalFunctionSpace(const LocalFunctionSpace &lfs)
Definition: localfunctionspace.hh:774
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:197
traits mapping global function space information to local function space
Definition: localfunctionspace.hh:155
GFS GridFunctionSpaceType
Type of the underlying grid function space.
Definition: localfunctionspace.hh:158
PowerLocalFunctionSpaceNode< SourceNode, typename Transformation::DOFIndex, TC, TypeTree::StaticDegree< SourceNode >::value > type
Definition: localfunctionspace.hh:423
typename GFS::Traits::EntitySet EntitySet
Definition: localfunctionspace.hh:294
LocalFunctionSpace(const GFS &gfs)
Definition: localfunctionspace.hh:708
void debug() const
print debug information about this local function space
Definition: localfunctionspace.hh:255
Definition: gridfunctionspace/tags.hh:26
Definition: localfunctionspace.hh:443
LeafLocalFunctionSpaceTraits< GFS, DOFIndex, LeafLocalFunctionSpaceNode > Traits
Definition: localfunctionspace.hh:554
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
Definition: localfunctionspace.hh:365
BaseT::Traits Traits
Definition: localfunctionspace.hh:706
std::shared_ptr< GFS const > pgfs
Definition: localfunctionspace.hh:277
For backward compatibility – Do not use this!
Definition: adaptivity.hh:27
GridViewLocalFunctionSpaceBaseNode(std::shared_ptr< const GFS > gfs)
construct from global function space
Definition: localfunctionspace.hh:311
GridViewLocalFunctionSpaceBaseTraits< GFS, DOFIndex > Traits
Definition: localfunctionspace.hh:308
Create a local function space from a global function space.
Definition: localfunctionspace.hh:670
Definition: gridfunctionspace/tags.hh:30
Definition: localfunctionspace.hh:497
CompositeLocalFunctionSpaceTag ImplementationTag
Definition: localfunctionspace.hh:465
GFS::Traits::ConstraintsType ConstraintsType
Type of constraints engine.
Definition: localfunctionspace.hh:527
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)
std::vector< SizeType > IndexContainer
Type of container to store indices.
Definition: localfunctionspace.hh:167
FESwitch::Store pfe
Definition: localfunctionspace.hh:653
void bind(const typename Traits::Element &e)
bind local function space to entity
Definition: localfunctionspace.hh:646
traits for local function space on a gridview
Definition: localfunctionspace.hh:286
void dofIndices(const Entity &e, DOFIndexIterator it, DOFIndexIterator endit)
Calculates the multiindices associated with the given entity.
Definition: localfunctionspace.hh:592
CompositeLocalFunctionSpaceNode(const GFS &gfs, const Transformation &t, std::shared_ptr< Children >... children)
Definition: localfunctionspace.hh:476
LocalFunctionSpaceBaseNode(std::shared_ptr< const GFS > gfs)
construct from global function space
Definition: localfunctionspace.hh:198
Definition: localfunctionspacetags.hh:40
const Entity & e
Definition: localfunctionspace.hh:111
LocalFunctionSpace(std::shared_ptr< const GFS > pgfs)
Definition: localfunctionspace.hh:767
GFS::Traits::ConstraintsType Constraints
Definition: localfunctionspace.hh:529
Tag denoting a PowerLocalFunctionSpace.
Definition: gridfunctionspace/tags.hh:194
CompositeLocalFunctionSpaceNode< SourceNode, typename Transformation::DOFIndex, TC... > type
Definition: localfunctionspace.hh:499
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 GridFunctionSpace
Type of the underlying grid function space.
Definition: localfunctionspace.hh:161
GFS::Traits::FiniteElementType FiniteElementType
Type of local finite element.
Definition: localfunctionspace.hh:522
CompositeLocalFunctionSpaceNode(std::shared_ptr< const GFS > gfs, const Transformation &t, std::shared_ptr< Children >... children)
Definition: localfunctionspace.hh:468
A grid function space.
Definition: gridfunctionspace.hh:169
Definition: localfunctionspace.hh:421
void bind(const typename Traits::Element &e)
bind local function space to entity
Definition: localfunctionspace.hh:407
traits for multi component local function space
Definition: localfunctionspace.hh:357
Tag denoting a LeafLocalFunctionSpace.
Definition: gridfunctionspace/tags.hh:200
Definition: localfunctionspace.hh:178
LeafLocalFunctionSpaceNode(const GFS &gfs, const Transformation &t)
Definition: localfunctionspace.hh:573
single component local function space
Definition: localfunctionspace.hh:535
Traits::IndexContainer::size_type localVectorSize() const
get size of an appropriate local vector object
Definition: localfunctionspace.hh:230
Definition: localfunctionspace.hh:494
Traits::IndexContainer::size_type maxSize() const
get maximum possible size (which is maxLocalSize from grid function space)
Definition: localfunctionspace.hh:217
Definition: localfunctionspace.hh:418
typename EntitySet::Element Element
Type of codim 0 entity in the grid.
Definition: localfunctionspace.hh:297
std::vector< DI > DOFIndexContainer
Type of container to store multiindices.
Definition: localfunctionspace.hh:173
const Traits::FiniteElementType & finiteElement() const
get finite element
Definition: localfunctionspace.hh:579
PowerCompositeLocalFunctionSpaceTraits< GFS, DOFIndex, CompositeLocalFunctionSpaceNode > Traits
Definition: localfunctionspace.hh:463
void bind(const typename Traits::Element &e)
bind local function space to entity
Definition: localfunctionspace.hh:484
Definition: lfsindexcache.hh:240
DI DOFIndex
Type of MultiIndex associated with this LocalFunctionSpace.
Definition: localfunctionspace.hh:170
LeafLocalFunctionSpaceTag ImplementationTag
Definition: localfunctionspace.hh:556
Definition: gridfunctionspace/tags.hh:32
traits for single component local function space
Definition: localfunctionspace.hh:519
const GFS & gridFunctionSpace() const
Returns the GridFunctionSpace underlying this LocalFunctionSpace.
Definition: localfunctionspace.hh:264
Traits::DOFIndexContainer * _dof_indices
Definition: localfunctionspace.hh:279
LocalFunctionSpace(const LocalFunctionSpace &lfs)
Definition: localfunctionspace.hh:714
const Traits::ConstraintsType & constraints() const
get constraints engine
Definition: localfunctionspace.hh:585
void setup(NodeType &node)
Definition: localfunctionspace.hh:271
LocalFunctionSpace(const GFS &gfs)
Definition: localfunctionspace.hh:760
void bind(NodeType &node, const typename Traits::Element &e)
bind local function space to entity
const std::size_t offset
Definition: localfunctionspace.hh:74
void insert_constraints(const LC &lc, GC &gc) const
Definition: localfunctionspace.hh:625
A multi-index representing a degree of freedom in a GridFunctionSpace.
Definition: dofindex.hh:146
GFS::Traits::GridViewType GridView
Type of the grid view that the underlying grid function space is defined on.
Definition: localfunctionspace.hh:292
N NodeType
type of local function space node
Definition: localfunctionspace.hh:360
PowerLocalFunctionSpaceNode(const GFS &gfs, const Transformation &t, const std::array< std::shared_ptr< ChildLFS >, k > &children)
Definition: localfunctionspace.hh:399
std::size_t subSpaceDepth() const
Definition: localfunctionspace.hh:211