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