dune-pdelab  2.7-git
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 #include <memory>
10 
11 #include <dune/common/shared_ptr.hh>
12 
13 #include <dune/typetree/powernode.hh>
14 
19 
20 namespace Dune {
21  namespace PDELab {
22 
23  //=======================================
24  // vector grid function space
25  //=======================================
26 
50  template<typename GV,
51  typename FEM,
52  std::size_t k,
53  typename Backend,
54  typename LeafBackend,
55  typename Constraints = NoConstraints,
56  typename OrderingTag = LexicographicOrderingTag,
57  typename LeafOrderingTag = DefaultLeafOrderingTag>
59  : public TypeTree::PowerNode<GridFunctionSpace<
60  impl::EntitySet<GV>,
61  FEM,
62  Constraints,
63  LeafBackend,
64  LeafOrderingTag
65  >,
66  k>
67  , public PowerCompositeGridFunctionSpaceBase<VectorGridFunctionSpace<
68  GV,
69  FEM,
70  k,
71  Backend,
72  LeafBackend,
73  Constraints,
74  OrderingTag,
75  LeafOrderingTag
76  >,
77  impl::EntitySet<GV>,
78  Backend,
79  OrderingTag,
80  k>
81 
82  , public DataHandleProvider<VectorGridFunctionSpace<
83  GV,
84  FEM,
85  k,
86  Backend,
87  LeafBackend,
88  Constraints,
89  OrderingTag,
90  LeafOrderingTag
91  > >
92 
94  {
95 
96  typedef GridFunctionSpace<
97  impl::EntitySet<GV>,
98  FEM,
99  Constraints,
100  LeafBackend,
102  > LeafGFS;
103 
104  template<typename,typename>
105  friend class GridFunctionSpaceBase;
106 
107  public:
108 
110 
111  typedef TypeTree::PowerNode<LeafGFS,k> BaseT;
112 
115  impl::EntitySet<GV>,
116  Backend,
117  OrderingTag,
119 
122  impl::EntitySet<GV>,
123  Backend,
124  OrderingTag,
125  k>;
126 
127  typedef TypeTree::TransformTree<VectorGridFunctionSpace,
128  gfs_to_ordering<VectorGridFunctionSpace>
130 
131  public:
132 
133  typedef typename ordering_transformation::Type Ordering;
134 
136  template<typename E>
138  {
139  typedef typename std::conditional<
140  std::is_same<
141  Constraints,
143  >::value,
146  typename Ordering::Traits::DOFIndex,
147  typename Ordering::Traits::ContainerIndex,
148  E
149  >
150  >::type Type;
151  };
152 
155 
156  private:
157 
158  // Preconstruct children - it is important that the children are set before entering the constructor
159  // of ImplementationBase!
160  static typename BaseT::NodeStorage create_components(const typename Traits::EntitySet& es,
161  std::shared_ptr<const FEM> fem_ptr,
162  const LeafBackend& leaf_backend,
163  const LeafOrderingTag& leaf_ordering_tag)
164  {
165  typename BaseT::NodeStorage r;
166  for (std::size_t i = 0; i < k; ++i)
167  r[i] = std::make_shared<LeafGFS>(es,fem_ptr,leaf_backend,leaf_ordering_tag);
168  return r;
169  }
170 
171  public:
172 
173  VectorGridFunctionSpace(const typename Traits::GridView& gv, const FEM& fem,
174  const Backend& backend = Backend(), const LeafBackend& leaf_backend = LeafBackend(),
175  const OrderingTag& ordering_tag = OrderingTag(), const LeafOrderingTag& leaf_ordering_tag = LeafOrderingTag())
176  : BaseT(create_components(typename Traits::EntitySet(gv),stackobject_to_shared_ptr(fem),leaf_backend,leaf_ordering_tag))
177  , ImplementationBase(backend,ordering_tag)
178  {}
179 
180  VectorGridFunctionSpace(const typename Traits::EntitySet& es, const FEM& fem,
181  const Backend& backend = Backend(), const LeafBackend& leaf_backend = LeafBackend(),
182  const OrderingTag& ordering_tag = OrderingTag(), const LeafOrderingTag& leaf_ordering_tag = LeafOrderingTag())
183  : BaseT(create_components(es,stackobject_to_shared_ptr(fem),leaf_backend,leaf_ordering_tag))
184  , ImplementationBase(backend,ordering_tag)
185  {}
186 
187  VectorGridFunctionSpace(const typename Traits::GridView& gv, std::shared_ptr<const FEM> fem,
188  const Backend& backend = Backend(), const LeafBackend& leaf_backend = LeafBackend(),
189  const OrderingTag& ordering_tag = OrderingTag(), const LeafOrderingTag& leaf_ordering_tag = LeafOrderingTag())
190  : BaseT(create_components(typename Traits::EntitySet(gv), fem, leaf_backend, leaf_ordering_tag))
191  , ImplementationBase(backend,ordering_tag)
192  {}
193 
194  VectorGridFunctionSpace(const typename Traits::EntitySet& es, std::shared_ptr<const FEM> fem,
195  const Backend& backend = Backend(), const LeafBackend& leaf_backend = LeafBackend(),
196  const OrderingTag& ordering_tag = OrderingTag(), const LeafOrderingTag& leaf_ordering_tag = LeafOrderingTag())
197  : BaseT(create_components(es, fem, leaf_backend, leaf_ordering_tag))
198  , ImplementationBase(backend,ordering_tag)
199  {}
200 
201  std::string name() const
202  {
203  return ImplementationBase::name();
204  }
205 
206  void name(std::string name)
207  {
209  for (std::size_t i = 0; i < k; ++i)
210  {
211  std::stringstream ns;
212  ns << name << "_" << i;
213  this->child(i).name(ns.str());
214  }
215  }
216 
218  const Ordering &ordering() const
219  {
220  if (!this->isRootSpace())
221  {
223  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
224  }
225  if (!_ordering)
226  {
227  create_ordering();
228  this->update(*_ordering);
229  }
230  return *_ordering;
231  }
232 
235  {
236  if (!this->isRootSpace())
237  {
239  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
240  }
241  if (!_ordering)
242  {
243  create_ordering();
244  this->update(*_ordering);
245  }
246  return *_ordering;
247  }
248 
250  std::shared_ptr<const Ordering> orderingStorage() const
251  {
252  if (!this->isRootSpace())
253  {
255  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
256  }
257  if (!_ordering)
258  {
259  create_ordering();
260  _ordering->update();
261  }
262  return _ordering;
263  }
264 
266  std::shared_ptr<Ordering> orderingStorage()
267  {
268  if (!this->isRootSpace())
269  {
271  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
272  }
273  if (!_ordering)
274  {
275  create_ordering();
276  _ordering->update();
277  }
278  return _ordering;
279  }
280 
281  private:
282 
283  // This method here is to avoid a double update of the Ordering when the user calls
284  // GFS::update() before GFS::ordering().
285  void create_ordering() const
286  {
287  _ordering = std::make_shared<Ordering>(ordering_transformation::transform(*this));
288  }
289 
290  mutable std::shared_ptr<Ordering> _ordering;
291 
292  };
293 
294  } // namespace PDELab
295 } // namespace Dune
296 
297 #endif // DUNE_PDELAB_GRIDFUNCTIONSPACE_VECTORGRIDFUNCTIONSPACE_HH
Dune::PDELab::PowerCompositeGridFunctionSpaceBase
Mixin class providing common functionality of PowerGridFunctionSpace and CompositeGridFunctionSpace.
Definition: powercompositegridfunctionspacebase.hh:68
Dune::PDELab::VectorGridFunctionSpace::name
void name(std::string name)
Definition: vectorgridfunctionspace.hh:206
powergridfunctionspace.hh
Dune::PDELab::GridFunctionSpaceBase< GridFunctionSpace, PowerCompositeGridFunctionSpaceTraits< GV, B, O, k > >::name
const std::string & name() const
Definition: gridfunctionspacebase.hh:216
Dune::PDELab::VectorGridFunctionSpace::ordering
Ordering & ordering()
Direct access to the DOF ordering.
Definition: vectorgridfunctionspace.hh:234
Dune::PDELab::VectorGridFunctionSpace::ordering
const Ordering & ordering() const
Direct access to the DOF ordering.
Definition: vectorgridfunctionspace.hh:218
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::VectorGridFunctionSpace::ImplementationTag
VectorGridFunctionSpaceTag ImplementationTag
Definition: vectorgridfunctionspace.hh:109
Dune::PDELab::PowerCompositeGridFunctionSpaceTraits
Trait class for the multi component grid function spaces.
Definition: powercompositegridfunctionspacebase.hh:34
Dune::PDELab::GridFunctionSpaceHierarchyError
Definition: exceptions.hh:34
Dune::PDELab::VectorGridFunctionSpace::ConstraintsContainer
extract type for storing constraints
Definition: vectorgridfunctionspace.hh:137
Dune::PDELab::VectorGridFunctionSpace::Traits
ImplementationBase::Traits Traits
export traits class
Definition: vectorgridfunctionspace.hh:154
Dune::PDELab::LexicographicOrderingTag
Indicate lexicographic ordering of the unknowns of non-leaf grid function spaces.
Definition: gridfunctionspace/tags.hh:63
Dune
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
Dune::PDELab::LeafOrderingTag
Tag indicating a standard ordering for a leaf GridfunctionSpace.
Definition: gridfunctionspace/tags.hh:183
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::ConstraintsTransformation
a class holding transformation for constrained spaces
Definition: constraintstransformation.hh:18
Dune::PDELab::GridFunctionSpaceBase
Definition: gridfunctionspacebase.hh:134
Dune::PDELab::VectorGridFunctionSpace
tensorproduct space representing a vector valued function space
Definition: vectorgridfunctionspace.hh:58
Dune::PDELab::VectorGridFunctionSpace::name
std::string name() const
Definition: vectorgridfunctionspace.hh:201
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::NoConstraints
Definition: noconstraints.hh:18
tags.hh
Dune::PDELab::DefaultLeafOrderingTag
LeafOrderingTag< EmptyParams > DefaultLeafOrderingTag
Definition: gridfunctionspace/tags.hh:187
value
static const unsigned int value
Definition: gridfunctionspace/tags.hh:139
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:173
Dune::PDELab::VectorGridFunctionSpace::ConstraintsContainer::Type
std::conditional< std::is_same< Constraints, NoConstraints >::value, EmptyTransformation, ConstraintsTransformation< typename Ordering::Traits::DOFIndex, typename Ordering::Traits::ContainerIndex, E > >::type Type
Definition: vectorgridfunctionspace.hh:150
Dune::PDELab::GridFunctionSpace
A grid function space.
Definition: gridfunctionspace.hh:178
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:180
Dune::PDELab::PowerCompositeGridFunctionSpaceTraits::GridView
typename EntitySet::GridView GridView
Definition: powercompositegridfunctionspacebase.hh:47
Dune::PDELab::VectorGridFunctionSpace::VectorGridFunctionSpace
VectorGridFunctionSpace(const typename Traits::EntitySet &es, std::shared_ptr< 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:194
Dune::PDELab::VectorGridFunctionSpace::VectorGridFunctionSpace
VectorGridFunctionSpace(const typename Traits::GridView &gv, std::shared_ptr< 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:187
Dune::PDELab::VectorGridFunctionSpace::ordering_transformation
TypeTree::TransformTree< VectorGridFunctionSpace, gfs_to_ordering< VectorGridFunctionSpace > > ordering_transformation
Definition: vectorgridfunctionspace.hh:129
Dune::PDELab::EmptyTransformation
Definition: constraintstransformation.hh:111
Dune::PDELab::VectorGridFunctionSpace::Ordering
ordering_transformation::Type Ordering
Definition: vectorgridfunctionspace.hh:133
Dune::PDELab::VectorGridFunctionSpace::orderingStorage
std::shared_ptr< Ordering > orderingStorage()
Direct access to the storage of the DOF ordering.
Definition: vectorgridfunctionspace.hh:266
Dune::PDELab::DataHandleProvider
Definition: datahandleprovider.hh:188
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::orderingStorage
std::shared_ptr< const Ordering > orderingStorage() const
Direct access to the storage of the DOF ordering.
Definition: vectorgridfunctionspace.hh:250
powercompositegridfunctionspacebase.hh
gridfunctionspace.hh
Dune::PDELab::GridFunctionOutputParameters
Mixin base class for specifying output hints to I/O routines like VTK.
Definition: function.hh:125
Dune::PDELab::VectorGridFunctionSpaceTag
Definition: gridfunctionspace/tags.hh:28
Dune::PDELab::VectorGridFunctionSpace::ImplementationBase
PowerCompositeGridFunctionSpaceBase< VectorGridFunctionSpace, impl::EntitySet< GV >, Backend, OrderingTag, k > ImplementationBase
Definition: vectorgridfunctionspace.hh:118
Dune::PDELab::VectorGridFunctionSpace::BaseT
TypeTree::PowerNode< LeafGFS, k > BaseT
Definition: vectorgridfunctionspace.hh:111
Dune::PDELab::PowerCompositeGridFunctionSpaceTraits::EntitySet
G EntitySet
Definition: powercompositegridfunctionspacebase.hh:45