dune-pdelab  2.5-dev
dunefunctionslocalfunctionspace.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_PDELAB_GRIDFUNCTIONSPACE_DUNEFUNCTIONSLOCALFUNCTIONSPACE_HH
4 #define DUNE_PDELAB_GRIDFUNCTIONSPACE_DUNEFUNCTIONSLOCALFUNCTIONSPACE_HH
5 
6 #include<vector>
7 
8 #include <dune/common/stdstreams.hh>
9 
10 #include <dune/geometry/referenceelements.hh>
11 
12 #include <dune/localfunctions/common/interfaceswitch.hh>
13 #include <dune/localfunctions/common/localkey.hh>
14 
15 #include <dune/typetree/typetree.hh>
16 
19 
20 namespace Dune {
21  namespace PDELab {
22 
26 
27  namespace Experimental {
28 
29  template<typename LFS>
30  struct LeafLFSMixin
31  : public TypeTree::LeafNode
32  {
33 
34  const auto& finiteElement() const
35  {
36  return static_cast<const LFS*>(this)->tree().finiteElement();
37  }
38 
39  template<typename Tree>
40  struct Traits
41  {
42  using FiniteElement = typename Tree::FiniteElement;
44  };
45  };
46 
47  template<typename GFS, typename TreePath = TypeTree::HybridTreePath<>>
49  : public LeafLFSMixin<LocalFunctionSpace<GFS,TreePath>>
50  {
51 
52  public:
53 
54  using Basis = typename GFS::Basis;
55  using LocalView = typename Basis::LocalView;
56  using Tree = TypeTree::ChildForTreePath<typename LocalView::Tree,TreePath>;
57  using LocalIndexSet = typename Basis::LocalIndexSet;
58  using DOFIndex = typename Basis::MultiIndex;
59 
60  template<typename LFS, typename C, typename Tag, bool fast>
61  friend class LFSIndexCacheBase;
62 
63  struct Traits
64  : public LeafLFSMixin<LocalFunctionSpace<GFS,TreePath>>::template Traits<Tree>
65  {
66 
67  using GridFunctionSpace = GFS;
68  using GridView = typename GFS::Traits::GridView;
69  using SizeType = std::size_t;
70  using DOFIndex = typename Basis::MultiIndex;
71  using ConstraintsType = typename GFS::Traits::ConstraintsType;
72 
73  };
74 
75  using size_type = std::size_t;
76 
77  LocalFunctionSpace(std::shared_ptr<const GFS> gfs, TreePath tree_path = TreePath(), size_type offset = 0)
78  : _gfs(gfs)
79  , _local_view(gfs->basis())
80  , _tree_path(tree_path)
81  , _tree(TypeTree::child(_local_view.tree(),tree_path))
82  , _local_index_set(gfs->basis().localIndexSet())
83  {}
84 
86  {
87  return 0;
88  }
89 
91  size_type size () const
92  {
93  return _local_view.size();
94  }
95 
96  size_type maxSize () const
97  {
98  // _dof_indices is always as large as the max local size of the root GFS
99  return _local_view.maxSize();
100  }
101 
104  {
105  return _tree.localIndex(index);
106  }
107 
109  {
110  return _local_index_set.index(_tree.localIndex(index));
111  }
112 
114  const GFS& gridFunctionSpace() const
115  {
116  return *_gfs;
117  }
118 
119  void bind(const typename GFS::Traits::EntitySet::template Codim<0>::Entity& e)
120  {
121  _local_view.bind(e);
122  _local_index_set.bind(_local_view);
123  }
124 
125  const typename Traits::ConstraintsType& constraints() const
126  {
127  return _gfs->constraints();
128  }
129 
130  const Tree& tree() const
131  {
132  return _tree;
133  }
134 
135  private:
136 
137  std::shared_ptr<const GFS> _gfs;
138  LocalView _local_view;
139  TreePath _tree_path;
140  const Tree& _tree;
141  LocalIndexSet _local_index_set;
142 
143  };
144 
145  // forward declare GridFunctionSpace
146  template<typename DFBasis, typename V, typename CE=NoConstraints>
147  class GridFunctionSpace;
148 
149 
150  } // namespace Experimental
151 
152 
153  template<typename DFBasis, typename V, typename CE, typename TAG>
154  class LocalFunctionSpace<Experimental::GridFunctionSpace<DFBasis,V,CE>,TAG>
155  : public Experimental::LocalFunctionSpace<Experimental::GridFunctionSpace<DFBasis,V,CE>>
156  {
157 
159 
160  public:
161 
162  LocalFunctionSpace(std::shared_ptr<const GFS> gfs)
163  : Experimental::LocalFunctionSpace<GFS>(gfs)
164  {}
165 
167  : Experimental::LocalFunctionSpace<GFS>(stackobject_to_shared_ptr(gfs))
168  {}
169 
170  };
171 
172  template<typename DFBasis, typename V, typename CE>
173  class LocalFunctionSpace<Experimental::GridFunctionSpace<DFBasis,V,CE>,AnySpaceTag>
174  : public Experimental::LocalFunctionSpace<Experimental::GridFunctionSpace<DFBasis,V,CE>>
175  {
176 
178 
179  public:
180 
181  LocalFunctionSpace(std::shared_ptr<const GFS> gfs)
182  : Experimental::LocalFunctionSpace<GFS>(gfs)
183  {}
184 
186  : Experimental::LocalFunctionSpace<GFS>(stackobject_to_shared_ptr(gfs))
187  {}
188 
189  };
190 
192  } // namespace PDELab
193 } // namespace Dune
194 
195 #endif // DUNE_PDELAB_GRIDFUNCTIONSPACE_DUNEFUNCTIONSLOCALFUNCTIONSPACE_HH
Dune::PDELab::Experimental::LocalFunctionSpace< Experimental::GridFunctionSpace< DFBasis, V, CE > >::DOFIndex
typename Basis::MultiIndex DOFIndex
Definition: dunefunctionslocalfunctionspace.hh:58
Dune::PDELab::Experimental::LocalFunctionSpace::bind
void bind(const typename GFS::Traits::EntitySet::template Codim< 0 >::Entity &e)
Definition: dunefunctionslocalfunctionspace.hh:119
Dune::PDELab::AnySpaceTag
Definition: localfunctionspacetags.hh:40
Dune::PDELab::Experimental::GridFunctionSpace< DFBasis, V, CE >
Dune::PDELab::LocalFunctionSpace< Experimental::GridFunctionSpace< DFBasis, V, CE >, TAG >::LocalFunctionSpace
LocalFunctionSpace(std::shared_ptr< const GFS > gfs)
Definition: dunefunctionslocalfunctionspace.hh:162
Dune::PDELab::Experimental::LocalFunctionSpace
Definition: dunefunctionslocalfunctionspace.hh:48
Dune::PDELab::Experimental::LocalFunctionSpace::gridFunctionSpace
const GFS & gridFunctionSpace() const
Returns the GridFunctionSpace underlying this LocalFunctionSpace.
Definition: dunefunctionslocalfunctionspace.hh:114
Dune::PDELab::Experimental::LocalFunctionSpace::Traits::GridView
typename GFS::Traits::GridView GridView
Definition: dunefunctionslocalfunctionspace.hh:68
index
std::size_t index
Definition: interpolate.hh:118
Dune
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
Dune::PDELab::Experimental::LocalFunctionSpace::dofIndex
DOFIndex dofIndex(size_type index) const
Definition: dunefunctionslocalfunctionspace.hh:108
Dune::PDELab::Experimental::LocalFunctionSpace::Traits::SizeType
std::size_t SizeType
Definition: dunefunctionslocalfunctionspace.hh:69
Dune::PDELab::Experimental::LocalFunctionSpace< Experimental::GridFunctionSpace< DFBasis, V, CE > >::LocalView
typename Basis::LocalView LocalView
Definition: dunefunctionslocalfunctionspace.hh:55
Dune::PDELab::Experimental::LeafLFSMixin::finiteElement
const auto & finiteElement() const
Definition: dunefunctionslocalfunctionspace.hh:34
Dune::PDELab::Experimental::LeafLFSMixin::Traits::FiniteElementType
FiniteElement FiniteElementType
Definition: dunefunctionslocalfunctionspace.hh:43
Dune::PDELab::Experimental::LocalFunctionSpace::subSpaceDepth
size_type subSpaceDepth() const
Definition: dunefunctionslocalfunctionspace.hh:85
offset
const std::size_t offset
Definition: localfunctionspace.hh:74
Dune::PDELab::Experimental::LocalFunctionSpace::Traits::GridFunctionSpace
GFS GridFunctionSpace
Definition: dunefunctionslocalfunctionspace.hh:67
Dune::PDELab::Experimental::LocalFunctionSpace::Traits::DOFIndex
typename Basis::MultiIndex DOFIndex
Definition: dunefunctionslocalfunctionspace.hh:70
Dune::PDELab::Experimental::LocalFunctionSpace::tree
const Tree & tree() const
Definition: dunefunctionslocalfunctionspace.hh:130
Dune::PDELab::Experimental::LocalFunctionSpace< Experimental::GridFunctionSpace< DFBasis, V, CE > >::Basis
typename Experimental::GridFunctionSpace< DFBasis, V, CE > ::Basis Basis
Definition: dunefunctionslocalfunctionspace.hh:54
Dune::PDELab::GridFunctionSpace
A grid function space.
Definition: gridfunctionspace.hh:166
localvector.hh
tags.hh
Dune::PDELab::Experimental::LocalFunctionSpace::localIndex
size_type localIndex(size_type index) const
map index in this local function space to root local function space
Definition: dunefunctionslocalfunctionspace.hh:103
Dune::PDELab::Experimental::LocalFunctionSpace::Traits
Definition: dunefunctionslocalfunctionspace.hh:63
e
const Entity & e
Definition: localfunctionspace.hh:120
Dune::PDELab::LocalFunctionSpace< Experimental::GridFunctionSpace< DFBasis, V, CE >, TAG >::LocalFunctionSpace
LocalFunctionSpace(const GFS &gfs)
Definition: dunefunctionslocalfunctionspace.hh:166
Dune::PDELab::Experimental::LocalFunctionSpace::LocalFunctionSpace
LocalFunctionSpace(std::shared_ptr< const GFS > gfs, TreePath tree_path=TreePath(), size_type offset=0)
Definition: dunefunctionslocalfunctionspace.hh:77
Dune::PDELab::Experimental::LeafLFSMixin::Traits
Definition: dunefunctionslocalfunctionspace.hh:40
Dune::PDELab::Experimental::LocalFunctionSpace::Traits::ConstraintsType
typename GFS::Traits::ConstraintsType ConstraintsType
Definition: dunefunctionslocalfunctionspace.hh:71
Dune::PDELab::Experimental::LocalFunctionSpace::size
size_type size() const
get current size
Definition: dunefunctionslocalfunctionspace.hh:91
Dune::PDELab::LFSIndexCacheBase
Definition: lfsindexcache.hh:244
Dune::PDELab::Experimental::LeafLFSMixin
Definition: dunefunctionslocalfunctionspace.hh:30
Dune::PDELab::Experimental::LocalFunctionSpace::constraints
const Traits::ConstraintsType & constraints() const
Definition: dunefunctionslocalfunctionspace.hh:125
Dune::PDELab::LocalFunctionSpace
Create a local function space from a global function space.
Definition: localfunctionspace.hh:698
Dune::PDELab::Experimental::LocalFunctionSpace< Experimental::GridFunctionSpace< DFBasis, V, CE > >::Tree
TypeTree::ChildForTreePath< typename LocalView::Tree, TypeTree::HybridTreePath<> > Tree
Definition: dunefunctionslocalfunctionspace.hh:56
Dune::PDELab::Experimental::LocalFunctionSpace< Experimental::GridFunctionSpace< DFBasis, V, CE > >::size_type
std::size_t size_type
Definition: dunefunctionslocalfunctionspace.hh:75
Dune::PDELab::LocalFunctionSpace< Experimental::GridFunctionSpace< DFBasis, V, CE >, AnySpaceTag >::LocalFunctionSpace
LocalFunctionSpace(const GFS &gfs)
Definition: dunefunctionslocalfunctionspace.hh:185
Dune::PDELab::LocalFunctionSpace< Experimental::GridFunctionSpace< DFBasis, V, CE >, AnySpaceTag >::LocalFunctionSpace
LocalFunctionSpace(std::shared_ptr< const GFS > gfs)
Definition: dunefunctionslocalfunctionspace.hh:181
Dune::PDELab::Experimental::LocalFunctionSpace< Experimental::GridFunctionSpace< DFBasis, V, CE > >::LocalIndexSet
typename Basis::LocalIndexSet LocalIndexSet
Definition: dunefunctionslocalfunctionspace.hh:57
Dune::PDELab::Experimental::LocalFunctionSpace::maxSize
size_type maxSize() const
Definition: dunefunctionslocalfunctionspace.hh:96
Dune::PDELab::Experimental::LeafLFSMixin::Traits::FiniteElement
typename Tree::FiniteElement FiniteElement
Definition: dunefunctionslocalfunctionspace.hh:42