dune-pdelab  2.0.0
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_VECTORGRIDFUNCTIONSPACE_HH
5 #define DUNE_PDELAB_VECTORGRIDFUNCTIONSPACE_HH
6 
7 #include <cstddef>
8 
9 #include <dune/common/shared_ptr.hh>
10 
11 #include <dune/typetree/powernode.hh>
12 
17 
18 namespace Dune {
19  namespace PDELab {
20 
21  //=======================================
22  // power grid function space
23  //=======================================
24 
39  template<typename GV,
40  typename FEM,
41  std::size_t k,
42  typename Backend,
43  typename LeafBackend,
44  typename Constraints = NoConstraints,
45  typename OrderingTag = LexicographicOrderingTag,
46  typename LeafOrderingTag = DefaultLeafOrderingTag>
48  : public TypeTree::PowerNode<GridFunctionSpace<
49  GV,
50  FEM,
51  Constraints,
52  LeafBackend,
53  LeafOrderingTag
54  >,
55  k>
56  , public PowerCompositeGridFunctionSpaceBase<VectorGridFunctionSpace<
57  GV,
58  FEM,
59  k,
60  Backend,
61  LeafBackend,
62  Constraints,
63  OrderingTag,
64  LeafOrderingTag
65  >,
66  GV,
67  Backend,
68  OrderingTag,
69  k>
70 
71  , public DataHandleProvider<VectorGridFunctionSpace<
72  GV,
73  FEM,
74  k,
75  Backend,
76  LeafBackend,
77  Constraints,
78  OrderingTag,
79  LeafOrderingTag
80  > >
81 
83  {
84 
85  typedef GridFunctionSpace<
86  GV,
87  FEM,
88  Constraints,
89  LeafBackend,
91  > LeafGFS;
92 
93  template<typename,typename>
94  friend class GridFunctionSpaceBase;
95 
96  public:
97 
99 
100  typedef TypeTree::PowerNode<LeafGFS,k> BaseT;
101 
104  GV,
105  Backend,
106  OrderingTag,
108 
111  GV,
112  Backend,
113  OrderingTag,
114  k>;
115 
116  typedef TypeTree::TransformTree<VectorGridFunctionSpace,
117  gfs_to_ordering<VectorGridFunctionSpace>
119 
120  public:
121 
122  typedef typename ordering_transformation::Type Ordering;
123 
126 
127  private:
128 
129  // Preconstruct children - it is important that the children are set before entering the constructor
130  // of ImplementationBase!
131  static typename BaseT::NodeStorage create_components(const GV& gv,
132  shared_ptr<const FEM> fem_ptr,
133  const LeafBackend& leaf_backend,
134  const LeafOrderingTag& leaf_ordering_tag)
135  {
136  typename BaseT::NodeStorage r;
137  for (std::size_t i = 0; i < k; ++i)
138  r[i] = make_shared<LeafGFS>(gv,fem_ptr,leaf_backend,leaf_ordering_tag);
139  return r;
140  }
141 
142  public:
143 
144  VectorGridFunctionSpace(const GV& gv, const FEM& fem,
145  const Backend& backend = Backend(), const LeafBackend& leaf_backend = LeafBackend(),
146  const OrderingTag& ordering_tag = OrderingTag(), const LeafOrderingTag& leaf_ordering_tag = LeafOrderingTag())
147  : BaseT(create_components(gv,stackobject_to_shared_ptr(fem),leaf_backend,leaf_ordering_tag))
148  , ImplementationBase(backend,ordering_tag)
149  {}
150 
151  std::string name() const
152  {
153  return ImplementationBase::name();
154  }
155 
156  void name(std::string name)
157  {
159  for (std::size_t i = 0; i < k; ++i)
160  {
161  std::stringstream ns;
162  ns << name << "_" << i;
163  this->child(i).name(ns.str());
164  }
165  }
166 
168  const Ordering &ordering() const
169  {
170  if (!this->isRootSpace())
171  {
173  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
174  }
175  if (!_ordering)
176  {
177  create_ordering();
178  this->update(*_ordering);
179  }
180  return *_ordering;
181  }
182 
185  {
186  if (!this->isRootSpace())
187  {
189  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
190  }
191  if (!_ordering)
192  {
193  create_ordering();
194  this->update(*_ordering);
195  }
196  return *_ordering;
197  }
198 
200  shared_ptr<const Ordering> orderingStorage() const
201  {
202  if (!this->isRootSpace())
203  {
205  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
206  }
207  if (!_ordering)
208  {
209  create_ordering();
210  _ordering->update();
211  }
212  return _ordering;
213  }
214 
216  shared_ptr<Ordering> orderingStorage()
217  {
218  if (!this->isRootSpace())
219  {
221  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
222  }
223  if (!_ordering)
224  {
225  create_ordering();
226  _ordering->update();
227  }
228  return _ordering;
229  }
230 
231  private:
232 
233  // This method here is to avoid a double update of the Ordering when the user calls
234  // GFS::update() before GFS::ordering().
235  void create_ordering() const
236  {
237  _ordering = make_shared<Ordering>(ordering_transformation::transform(*this));
238  }
239 
240  mutable shared_ptr<Ordering> _ordering;
241 
242  };
243 
244  } // namespace PDELab
245 } // namespace Dune
246 
247 #endif // DUNE_PDELAB_VECTORGRIDFUNCTIONSPACE_HH
TypeTree::PowerNode< LeafGFS, k > BaseT
Definition: vectorgridfunctionspace.hh:100
shared_ptr< const Ordering > orderingStorage() const
Direct access to the storage of the DOF ordering.
Definition: vectorgridfunctionspace.hh:200
Tag indicating a standard ordering for a leaf GridfunctionSpace.
Definition: gridfunctionspace/tags.hh:216
Ordering & ordering()
Direct access to the DOF ordering.
Definition: vectorgridfunctionspace.hh:184
Mixin base class for specifying output hints to I/O routines like VTK.
Definition: function.hh:124
Definition: gridfunctionspacebase.hh:137
const Ordering & ordering() const
Direct access to the DOF ordering.
Definition: vectorgridfunctionspace.hh:168
ImplementationBase::Traits Traits
export traits class
Definition: vectorgridfunctionspace.hh:125
shared_ptr< Ordering > orderingStorage()
Direct access to the storage of the DOF ordering.
Definition: vectorgridfunctionspace.hh:216
PowerCompositeGridFunctionSpaceBase< VectorGridFunctionSpace, GV, Backend, OrderingTag, k > ImplementationBase
Definition: vectorgridfunctionspace.hh:107
void name(std::string name)
Definition: vectorgridfunctionspace.hh:156
Definition: gridfunctionspace/tags.hh:24
Definition: datahandleprovider.hh:189
Mixin class providing common functionality of PowerGridFunctionSpace and CompositeGridFunctionSpace.
Definition: powercompositegridfunctionspacebase.hh:65
ordering_transformation::Type Ordering
Definition: vectorgridfunctionspace.hh:122
std::string name() const
Definition: vectorgridfunctionspace.hh:151
A grid function space.
Definition: gridfunctionspace.hh:109
LeafOrderingTag< DefaultLeafOrderingParams > DefaultLeafOrderingTag
Default ordering tag for a MultiIndex-based ordering with standard behavior.
Definition: gridfunctionspace/tags.hh:252
TypeTree::TransformTree< VectorGridFunctionSpace, gfs_to_ordering< VectorGridFunctionSpace > > ordering_transformation
Definition: vectorgridfunctionspace.hh:118
VectorGridFunctionSpaceTag ImplementationTag
Definition: vectorgridfunctionspace.hh:98
Trait class for the multi component grid function spaces.
Definition: powercompositegridfunctionspacebase.hh:33
VectorGridFunctionSpace(const GV &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:144
base class for tuples of grid function spaces product of identical grid function spaces base class th...
Definition: vectorgridfunctionspace.hh:47