dune-pdelab  2.4-dev
powergridfunctionspace.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_POWERGRIDFUNCTIONSPACE_HH
5 #define DUNE_PDELAB_POWERGRIDFUNCTIONSPACE_HH
6 
7 #include <cstddef>
8 #include <memory>
9 
10 #include <dune/typetree/powernode.hh>
11 
15 
16 namespace Dune {
17  namespace PDELab {
18 
19  //=======================================
20  // power grid function space
21  //=======================================
22 
37  template<typename T, std::size_t k,
38  typename Backend,
39  typename OrderingTag = LexicographicOrderingTag>
41  : public TypeTree::PowerNode<T,k>
43  PowerGridFunctionSpace<T, k, Backend, OrderingTag>,
44  typename T::Traits::GridViewType,
45  Backend,
46  OrderingTag,
47  k>
48  , public DataHandleProvider<PowerGridFunctionSpace<T,k,Backend,OrderingTag> >
49  {
50 
51  public:
52 
54 
55  typedef TypeTree::PowerNode<T,k> BaseT;
56 
57  private:
58 
61  typename T::Traits::GridViewType,
62  Backend,
64  k
66 
68  PowerGridFunctionSpace,
69  typename T::Traits::GridViewType,
70  Backend,
71  OrderingTag,
72  k>;
73 
74  template<typename,typename>
75  friend class GridFunctionSpaceBase;
76 
77  typedef TypeTree::TransformTree<PowerGridFunctionSpace,
78  gfs_to_ordering<PowerGridFunctionSpace>
79  > ordering_transformation;
80 
81  public:
82 
83  typedef typename ordering_transformation::Type Ordering;
84 
87 
88 
89  PowerGridFunctionSpace(T& c, const Backend& backend = Backend(), const OrderingTag ordering_tag = OrderingTag())
90  : BaseT(c)
91  , ImplementationBase(backend,ordering_tag)
92  {}
93 
95  T& c1,
96  const Backend& backend = Backend(),
97  const OrderingTag ordering_tag = OrderingTag())
98  : BaseT(c0,c1)
99  , ImplementationBase(backend,ordering_tag)
100  {}
101 
103  T& c1,
104  T& c2,
105  const Backend& backend = Backend(),
106  const OrderingTag ordering_tag = OrderingTag())
107  : BaseT(c0,c1,c2)
108  , ImplementationBase(backend,ordering_tag)
109  {}
110 
112  T& c1,
113  T& c2,
114  T& c3,
115  const Backend& backend = Backend(),
116  const OrderingTag ordering_tag = OrderingTag())
117  : BaseT(c0,c1,c2,c3)
118  , ImplementationBase(backend,ordering_tag)
119  {}
120 
122  T& c1,
123  T& c2,
124  T& c3,
125  T& c4,
126  const Backend& backend = Backend(),
127  const OrderingTag ordering_tag = OrderingTag())
128  : BaseT(c0,c1,c2,c3,c4)
129  , ImplementationBase(backend,ordering_tag)
130  {}
131 
133  T& c1,
134  T& c2,
135  T& c3,
136  T& c4,
137  T& c5,
138  const Backend& backend = Backend(),
139  const OrderingTag ordering_tag = OrderingTag())
140  : BaseT(c0,c1,c2,c3,c4,c5)
141  , ImplementationBase(backend,ordering_tag)
142  {}
143 
145  T& c1,
146  T& c2,
147  T& c3,
148  T& c4,
149  T& c5,
150  T& c6,
151  const Backend& backend = Backend(),
152  const OrderingTag ordering_tag = OrderingTag())
153  : BaseT(c0,c1,c2,c3,c4,c5,c6)
154  , ImplementationBase(backend,ordering_tag)
155  {}
156 
158  T& c1,
159  T& c2,
160  T& c3,
161  T& c4,
162  T& c5,
163  T& c6,
164  T& c7,
165  const Backend& backend = Backend(),
166  const OrderingTag ordering_tag = OrderingTag())
167  : BaseT(c0,c1,c2,c3,c4,c5,c6,c7)
168  , ImplementationBase(backend,ordering_tag)
169  {}
170 
172  T& c1,
173  T& c2,
174  T& c3,
175  T& c4,
176  T& c5,
177  T& c6,
178  T& c7,
179  T& c8,
180  const Backend& backend = Backend(),
181  const OrderingTag ordering_tag = OrderingTag())
182  : BaseT(c0,c1,c2,c3,c4,c5,c6,c7,c8)
183  , ImplementationBase(backend,ordering_tag)
184  {}
185 
187  T& c1,
188  T& c2,
189  T& c3,
190  T& c4,
191  T& c5,
192  T& c6,
193  T& c7,
194  T& c8,
195  T& c9,
196  const Backend& backend = Backend(),
197  const OrderingTag ordering_tag = OrderingTag())
198  : BaseT(c0,c1,c2,c3,c4,c5,c6,c7,c8,c9)
199  , ImplementationBase(backend,ordering_tag)
200  {}
201 
202  template<typename Child0, typename... Children>
203  PowerGridFunctionSpace(std::shared_ptr<Child0> child0, std::shared_ptr<Children>... children)
204  : BaseT(child0, children...)
205  , ImplementationBase(Backend(),OrderingTag())
206  {}
207 
209  const Ordering &ordering() const
210  {
211  if (!this->isRootSpace())
212  {
214  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
215  }
216  if (!_ordering)
217  {
218  create_ordering();
219  this->update(*_ordering);
220  }
221  return *_ordering;
222  }
223 
226  {
227  if (!this->isRootSpace())
228  {
230  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
231  }
232  if (!_ordering)
233  {
234  create_ordering();
235  this->update(*_ordering);
236  }
237  return *_ordering;
238  }
239 
241  std::shared_ptr<const Ordering> orderingStorage() const
242  {
243  if (!this->isRootSpace())
244  {
246  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
247  }
248  if (!_ordering)
249  {
250  create_ordering();
251  this->update(*_ordering);
252  }
253  return _ordering;
254  }
255 
257  std::shared_ptr<Ordering> orderingStorage()
258  {
259  if (!this->isRootSpace())
260  {
262  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
263  }
264  if (!_ordering)
265  {
266  create_ordering();
267  this->update(*_ordering);
268  }
269  return _ordering;
270  }
271 
272  private:
273 
274  // This method here is to avoid a double update of the Ordering when the user calls
275  // GFS::update() before GFS::ordering().
276  void create_ordering() const
277  {
278  _ordering = std::make_shared<Ordering>(ordering_transformation::transform(*this));
279  }
280 
281  mutable std::shared_ptr<Ordering> _ordering;
282 
283  };
284 
285  } // namespace PDELab
286 } // namespace Dune
287 
288 #endif // DUNE_PDELAB_POWERGRIDFUNCTIONSPACE_HH
PowerGridFunctionSpace(T &c0, T &c1, T &c2, T &c3, T &c4, T &c5, T &c6, const Backend &backend=Backend(), const OrderingTag ordering_tag=OrderingTag())
Definition: powergridfunctionspace.hh:144
Definition: gridfunctionspacebase.hh:137
Ordering & ordering()
Direct access to the DOF ordering.
Definition: powergridfunctionspace.hh:225
PowerGridFunctionSpace(T &c0, T &c1, T &c2, T &c3, T &c4, T &c5, T &c6, T &c7, T &c8, T &c9, const Backend &backend=Backend(), const OrderingTag ordering_tag=OrderingTag())
Definition: powergridfunctionspace.hh:186
Mixin class providing common functionality of PowerGridFunctionSpace and CompositeGridFunctionSpace.
Definition: powercompositegridfunctionspacebase.hh:66
const Ordering & ordering() const
Direct access to the DOF ordering.
Definition: powergridfunctionspace.hh:209
std::shared_ptr< Ordering > orderingStorage()
Direct access to the storage of the DOF ordering.
Definition: powergridfunctionspace.hh:257
PowerGridFunctionSpace(T &c0, T &c1, T &c2, T &c3, T &c4, const Backend &backend=Backend(), const OrderingTag ordering_tag=OrderingTag())
Definition: powergridfunctionspace.hh:121
PowerGridFunctionSpace(T &c0, T &c1, T &c2, T &c3, const Backend &backend=Backend(), const OrderingTag ordering_tag=OrderingTag())
Definition: powergridfunctionspace.hh:111
PowerGridFunctionSpace(T &c0, T &c1, T &c2, T &c3, T &c4, T &c5, const Backend &backend=Backend(), const OrderingTag ordering_tag=OrderingTag())
Definition: powergridfunctionspace.hh:132
Trait class for the multi component grid function spaces.
Definition: powercompositegridfunctionspacebase.hh:34
PowerGridFunctionSpace(T &c0, T &c1, T &c2, T &c3, T &c4, T &c5, T &c6, T &c7, T &c8, const Backend &backend=Backend(), const OrderingTag ordering_tag=OrderingTag())
Definition: powergridfunctionspace.hh:171
PowerGridFunctionSpace(T &c0, T &c1, const Backend &backend=Backend(), const OrderingTag ordering_tag=OrderingTag())
Definition: powergridfunctionspace.hh:94
Definition: adaptivity.hh:27
std::shared_ptr< const Ordering > orderingStorage() const
Direct access to the storage of the DOF ordering.
Definition: powergridfunctionspace.hh:241
Definition: datahandleprovider.hh:188
Definition: gridfunctionspace/tags.hh:26
PowerGridFunctionSpaceTag ImplementationTag
Definition: powergridfunctionspace.hh:53
PowerGridFunctionSpace(std::shared_ptr< Child0 > child0, std::shared_ptr< Children >...children)
Definition: powergridfunctionspace.hh:203
TypeTree::PowerNode< T, k > BaseT
Definition: powergridfunctionspace.hh:55
PowerGridFunctionSpace(T &c0, T &c1, T &c2, T &c3, T &c4, T &c5, T &c6, T &c7, const Backend &backend=Backend(), const OrderingTag ordering_tag=OrderingTag())
Definition: powergridfunctionspace.hh:157
PowerGridFunctionSpace(T &c0, T &c1, T &c2, const Backend &backend=Backend(), const OrderingTag ordering_tag=OrderingTag())
Definition: powergridfunctionspace.hh:102
ordering_transformation::Type Ordering
Definition: powergridfunctionspace.hh:83
PowerGridFunctionSpace(T &c, const Backend &backend=Backend(), const OrderingTag ordering_tag=OrderingTag())
Definition: powergridfunctionspace.hh:89
base class for tuples of grid function spaces product of identical grid function spaces base class th...
Definition: powergridfunctionspace.hh:40
G GridViewType
the grid view where grid function is defined upon
Definition: powercompositegridfunctionspacebase.hh:46