dune-pdelab  2.5-dev
vectorgridfunctionspace.hh
Go to the documentation of this file.
1 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=8 sw=2 sts=2:
3 
4 #ifndef DUNE_PDELAB_GRIDFUNCTIONSPACE_VECTORGRIDFUNCTIONSPACE_HH
5 #define DUNE_PDELAB_GRIDFUNCTIONSPACE_VECTORGRIDFUNCTIONSPACE_HH
6 
7 #include <algorithm>
8 #include <cstddef>
9 
10 #include <dune/common/shared_ptr.hh>
11 
12 #include <dune/typetree/powernode.hh>
13 
18 
19 namespace Dune {
20  namespace PDELab {
21 
22  //=======================================
23  // vector grid function space
24  //=======================================
25 
49  template<typename GV,
50  typename FEM,
51  std::size_t k,
52  typename Backend,
53  typename LeafBackend,
54  typename Constraints = NoConstraints,
55  typename OrderingTag = LexicographicOrderingTag,
56  typename LeafOrderingTag = DefaultLeafOrderingTag>
58  : public TypeTree::PowerNode<GridFunctionSpace<
59  impl::EntitySet<GV>,
60  FEM,
61  Constraints,
62  LeafBackend,
63  LeafOrderingTag
64  >,
65  k>
66  , public PowerCompositeGridFunctionSpaceBase<VectorGridFunctionSpace<
67  GV,
68  FEM,
69  k,
70  Backend,
71  LeafBackend,
72  Constraints,
73  OrderingTag,
74  LeafOrderingTag
75  >,
76  impl::EntitySet<GV>,
77  Backend,
78  OrderingTag,
79  k>
80 
81  , public DataHandleProvider<VectorGridFunctionSpace<
82  GV,
83  FEM,
84  k,
85  Backend,
86  LeafBackend,
87  Constraints,
88  OrderingTag,
89  LeafOrderingTag
90  > >
91 
93  {
94 
95  typedef GridFunctionSpace<
96  impl::EntitySet<GV>,
97  FEM,
98  Constraints,
99  LeafBackend,
101  > LeafGFS;
102 
103  template<typename,typename>
104  friend class GridFunctionSpaceBase;
105 
106  public:
107 
109 
110  typedef TypeTree::PowerNode<LeafGFS,k> BaseT;
111 
114  impl::EntitySet<GV>,
115  Backend,
116  OrderingTag,
118 
121  impl::EntitySet<GV>,
122  Backend,
123  OrderingTag,
124  k>;
125 
126  typedef TypeTree::TransformTree<VectorGridFunctionSpace,
127  gfs_to_ordering<VectorGridFunctionSpace>
129 
130  public:
131 
132  typedef typename ordering_transformation::Type Ordering;
133 
136 
137  private:
138 
139  // Preconstruct children - it is important that the children are set before entering the constructor
140  // of ImplementationBase!
141  static typename BaseT::NodeStorage create_components(const typename Traits::EntitySet& es,
142  std::shared_ptr<const FEM> fem_ptr,
143  const LeafBackend& leaf_backend,
144  const LeafOrderingTag& leaf_ordering_tag)
145  {
146  typename BaseT::NodeStorage r;
147  for (std::size_t i = 0; i < k; ++i)
148  r[i] = std::make_shared<LeafGFS>(es,fem_ptr,leaf_backend,leaf_ordering_tag);
149  return r;
150  }
151 
152  public:
153 
154  VectorGridFunctionSpace(const typename Traits::GridView& gv, const FEM& fem,
155  const Backend& backend = Backend(), const LeafBackend& leaf_backend = LeafBackend(),
156  const OrderingTag& ordering_tag = OrderingTag(), const LeafOrderingTag& leaf_ordering_tag = LeafOrderingTag())
157  : BaseT(create_components(typename Traits::EntitySet(gv),stackobject_to_shared_ptr(fem),leaf_backend,leaf_ordering_tag))
158  , ImplementationBase(backend,ordering_tag)
159  {}
160 
161  VectorGridFunctionSpace(const typename Traits::EntitySet& es, const FEM& fem,
162  const Backend& backend = Backend(), const LeafBackend& leaf_backend = LeafBackend(),
163  const OrderingTag& ordering_tag = OrderingTag(), const LeafOrderingTag& leaf_ordering_tag = LeafOrderingTag())
164  : BaseT(create_components(es,stackobject_to_shared_ptr(fem),leaf_backend,leaf_ordering_tag))
165  , ImplementationBase(backend,ordering_tag)
166  {}
167 
168  std::string name() const
169  {
170  return ImplementationBase::name();
171  }
172 
173  void name(std::string name)
174  {
176  for (std::size_t i = 0; i < k; ++i)
177  {
178  std::stringstream ns;
179  ns << name << "_" << i;
180  this->child(i).name(ns.str());
181  }
182  }
183 
185  const Ordering &ordering() const
186  {
187  if (!this->isRootSpace())
188  {
190  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
191  }
192  if (!_ordering)
193  {
194  create_ordering();
195  this->update(*_ordering);
196  }
197  return *_ordering;
198  }
199 
202  {
203  if (!this->isRootSpace())
204  {
206  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
207  }
208  if (!_ordering)
209  {
210  create_ordering();
211  this->update(*_ordering);
212  }
213  return *_ordering;
214  }
215 
217  std::shared_ptr<const Ordering> orderingStorage() const
218  {
219  if (!this->isRootSpace())
220  {
222  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
223  }
224  if (!_ordering)
225  {
226  create_ordering();
227  _ordering->update();
228  }
229  return _ordering;
230  }
231 
233  std::shared_ptr<Ordering> orderingStorage()
234  {
235  if (!this->isRootSpace())
236  {
238  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
239  }
240  if (!_ordering)
241  {
242  create_ordering();
243  _ordering->update();
244  }
245  return _ordering;
246  }
247 
248  private:
249 
250  // This method here is to avoid a double update of the Ordering when the user calls
251  // GFS::update() before GFS::ordering().
252  void create_ordering() const
253  {
254  _ordering = std::make_shared<Ordering>(ordering_transformation::transform(*this));
255  }
256 
257  mutable std::shared_ptr<Ordering> _ordering;
258 
259  };
260 
261  } // namespace PDELab
262 } // namespace Dune
263 
264 #endif // DUNE_PDELAB_GRIDFUNCTIONSPACE_VECTORGRIDFUNCTIONSPACE_HH
Dune::PDELab::GridFunctionSpaceBase< GridFunctionSpace, PowerCompositeGridFunctionSpaceTraits< GV, B, O, k > >::name
const std::string & name() const
Definition: gridfunctionspacebase.hh:216
Dune::PDELab::GridFunctionOutputParameters
Mixin base class for specifying output hints to I/O routines like VTK.
Definition: function.hh:124
Dune::PDELab::VectorGridFunctionSpace::BaseT
TypeTree::PowerNode< LeafGFS, k > BaseT
Definition: vectorgridfunctionspace.hh:110
Dune::PDELab::LexicographicOrderingTag
Indicate lexicographic ordering of the unknowns of non-leaf grid function spaces.
Definition: gridfunctionspace/tags.hh:63
Dune::PDELab::VectorGridFunctionSpace::orderingStorage
std::shared_ptr< Ordering > orderingStorage()
Direct access to the storage of the DOF ordering.
Definition: vectorgridfunctionspace.hh:233
powercompositegridfunctionspacebase.hh
gridfunctionspace.hh
Dune::PDELab::VectorGridFunctionSpace
tensorproduct space representing a vector valued function space
Definition: vectorgridfunctionspace.hh:57
Dune::PDELab::GridFunctionSpaceBase< VectorGridFunctionSpace< GV, FEM, k, Backend, LeafBackend, NoConstraints, LexicographicOrderingTag, DefaultLeafOrderingTag >, PowerCompositeGridFunctionSpaceTraits< impl::EntitySet< GV >, Backend, LexicographicOrderingTag, k > >::isRootSpace
bool isRootSpace() const
Definition: gridfunctionspacebase.hh:246
Dune::PDELab::VectorGridFunctionSpace::orderingStorage
std::shared_ptr< const Ordering > orderingStorage() const
Direct access to the storage of the DOF ordering.
Definition: vectorgridfunctionspace.hh:217
Dune::PDELab::VectorGridFunctionSpace::ordering
Ordering & ordering()
Direct access to the DOF ordering.
Definition: vectorgridfunctionspace.hh:201
Dune
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
Dune::PDELab::VectorGridFunctionSpace::ordering
const Ordering & ordering() const
Direct access to the DOF ordering.
Definition: vectorgridfunctionspace.hh:185
Dune::PDELab::PowerCompositeGridFunctionSpaceBase
Mixin class providing common functionality of PowerGridFunctionSpace and CompositeGridFunctionSpace.
Definition: powercompositegridfunctionspacebase.hh:68
Dune::PDELab::GridFunctionSpaceBase
Definition: gridfunctionspacebase.hh:134
Dune::PDELab::GridFunctionSpaceBase< VectorGridFunctionSpace< GV, FEM, k, Backend, LeafBackend, NoConstraints, LexicographicOrderingTag, DefaultLeafOrderingTag >, PowerCompositeGridFunctionSpaceTraits< impl::EntitySet< GV >, Backend, LexicographicOrderingTag, k > >::update
void update(bool force=false)
Update the indexing information of the GridFunctionSpace.
Definition: gridfunctionspacebase.hh:205
Dune::PDELab::VectorGridFunctionSpaceTag
Definition: gridfunctionspace/tags.hh:28
Dune::PDELab::VectorGridFunctionSpace::VectorGridFunctionSpace
VectorGridFunctionSpace(const typename Traits::EntitySet &es, const FEM &fem, const Backend &backend=Backend(), const LeafBackend &leaf_backend=LeafBackend(), const OrderingTag &ordering_tag=OrderingTag(), const LeafOrderingTag &leaf_ordering_tag=LeafOrderingTag())
Definition: vectorgridfunctionspace.hh:161
Dune::PDELab::DefaultLeafOrderingTag
LeafOrderingTag< EmptyParams > DefaultLeafOrderingTag
Definition: gridfunctionspace/tags.hh:187
Dune::PDELab::GridFunctionSpace
A grid function space.
Definition: gridfunctionspace.hh:166
Dune::PDELab::PowerCompositeGridFunctionSpaceTraits::EntitySet
G EntitySet
Definition: powercompositegridfunctionspacebase.hh:45
Dune::PDELab::VectorGridFunctionSpace::ordering_transformation
TypeTree::TransformTree< VectorGridFunctionSpace, gfs_to_ordering< VectorGridFunctionSpace > > ordering_transformation
Definition: vectorgridfunctionspace.hh:128
tags.hh
powergridfunctionspace.hh
Dune::PDELab::GridFunctionSpaceBase< VectorGridFunctionSpace< GV, FEM, k, Backend, LeafBackend, NoConstraints, LexicographicOrderingTag, DefaultLeafOrderingTag >, PowerCompositeGridFunctionSpaceTraits< impl::EntitySet< GV >, Backend, LexicographicOrderingTag, k > >::backend
Traits::Backend & backend()
Definition: gridfunctionspacebase.hh:226
Dune::PDELab::DataHandleProvider
Definition: datahandleprovider.hh:187
Dune::PDELab::LeafOrderingTag
Tag indicating a standard ordering for a leaf GridfunctionSpace.
Definition: gridfunctionspace/tags.hh:183
Dune::PDELab::PowerCompositeGridFunctionSpaceTraits::GridView
typename EntitySet::GridView GridView
Definition: powercompositegridfunctionspacebase.hh:47
Dune::PDELab::VectorGridFunctionSpace::name
std::string name() const
Definition: vectorgridfunctionspace.hh:168
Dune::PDELab::GridFunctionSpaceHierarchyError
Definition: exceptions.hh:34
Dune::PDELab::VectorGridFunctionSpace::ImplementationBase
PowerCompositeGridFunctionSpaceBase< VectorGridFunctionSpace, impl::EntitySet< GV >, Backend, OrderingTag, k > ImplementationBase
Definition: vectorgridfunctionspace.hh:117
Dune::PDELab::PowerCompositeGridFunctionSpaceBase< VectorGridFunctionSpace< GV, FEM, k, Backend, LeafBackend, NoConstraints, LexicographicOrderingTag, DefaultLeafOrderingTag >, impl::EntitySet< GV >, Backend, LexicographicOrderingTag, k >::OrderingTag
LexicographicOrderingTag OrderingTag
Definition: powercompositegridfunctionspacebase.hh:100
Dune::PDELab::VectorGridFunctionSpace::Ordering
ordering_transformation::Type Ordering
Definition: vectorgridfunctionspace.hh:132
Dune::PDELab::VectorGridFunctionSpace::name
void name(std::string name)
Definition: vectorgridfunctionspace.hh:173
Dune::PDELab::VectorGridFunctionSpace::VectorGridFunctionSpace
VectorGridFunctionSpace(const typename Traits::GridView &gv, const FEM &fem, const Backend &backend=Backend(), const LeafBackend &leaf_backend=LeafBackend(), const OrderingTag &ordering_tag=OrderingTag(), const LeafOrderingTag &leaf_ordering_tag=LeafOrderingTag())
Definition: vectorgridfunctionspace.hh:154
Dune::PDELab::VectorGridFunctionSpace::ImplementationTag
VectorGridFunctionSpaceTag ImplementationTag
Definition: vectorgridfunctionspace.hh:108
Dune::PDELab::PowerCompositeGridFunctionSpaceTraits
Trait class for the multi component grid function spaces.
Definition: powercompositegridfunctionspacebase.hh:34