DUNE PDELab (2.8)

powergridfunctionspace.hh
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_POWERGRIDFUNCTIONSPACE_HH
5#define DUNE_PDELAB_GRIDFUNCTIONSPACE_POWERGRIDFUNCTIONSPACE_HH
6
7#include <cstddef>
8#include <memory>
9
10#include <dune/typetree/powernode.hh>
11
12#include <dune/pdelab/gridfunctionspace/powercompositegridfunctionspacebase.hh>
13#include <dune/pdelab/gridfunctionspace/datahandleprovider.hh>
14#include <dune/pdelab/gridfunctionspace/tags.hh>
15
16namespace 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::EntitySet,
45 Backend,
46 OrderingTag,
47 k>
48 , public DataHandleProvider<PowerGridFunctionSpace<T,k,Backend,OrderingTag> >
49 {
50
51 public:
52
53 typedef PowerGridFunctionSpaceTag ImplementationTag;
54
55 typedef TypeTree::PowerNode<T,k> BaseT;
56
57 private:
58
61 typename T::Traits::EntitySet,
62 Backend,
64 k
66
69 typename T::Traits::EntitySet,
70 Backend,
72 k>;
73
74 template<typename,typename>
75 friend class GridFunctionSpaceBase;
76
77 typedef TypeTree::TransformTree<PowerGridFunctionSpace,
78 gfs_to_ordering<PowerGridFunctionSpace>
80
81 public:
82
83 typedef typename ordering_transformation::Type Ordering;
84
86 template<typename E>
88 {
89 typedef typename std::conditional<
90 std::is_same<
91 typename T::template ConstraintsContainer<E>::Type,
92 EmptyTransformation
93 >::value,
94 EmptyTransformation,
96 typename Ordering::Traits::DOFIndex,
97 typename Ordering::Traits::ContainerIndex,
98 E
99 >
100 >::type Type;
101 };
102
105
113 PowerGridFunctionSpace(const std::array<std::shared_ptr<T>,k>& container, const Backend& backend = Backend(), const OrderingTag ordering_tag = OrderingTag())
114 : BaseT(container)
115 , ImplementationBase(backend,ordering_tag)
116 {}
117
118 PowerGridFunctionSpace(T& c, const Backend& backend = Backend(), const OrderingTag ordering_tag = OrderingTag())
119 : BaseT(c)
120 , ImplementationBase(backend,ordering_tag)
121 {}
122
124 T& c1,
125 const Backend& backend = Backend(),
126 const OrderingTag ordering_tag = OrderingTag())
127 : BaseT(c0,c1)
128 , ImplementationBase(backend,ordering_tag)
129 {}
130
132 T& c1,
133 T& c2,
134 const Backend& backend = Backend(),
135 const OrderingTag ordering_tag = OrderingTag())
136 : BaseT(c0,c1,c2)
137 , ImplementationBase(backend,ordering_tag)
138 {}
139
141 T& c1,
142 T& c2,
143 T& c3,
144 const Backend& backend = Backend(),
145 const OrderingTag ordering_tag = OrderingTag())
146 : BaseT(c0,c1,c2,c3)
147 , ImplementationBase(backend,ordering_tag)
148 {}
149
151 T& c1,
152 T& c2,
153 T& c3,
154 T& c4,
155 const Backend& backend = Backend(),
156 const OrderingTag ordering_tag = OrderingTag())
157 : BaseT(c0,c1,c2,c3,c4)
158 , ImplementationBase(backend,ordering_tag)
159 {}
160
162 T& c1,
163 T& c2,
164 T& c3,
165 T& c4,
166 T& c5,
167 const Backend& backend = Backend(),
168 const OrderingTag ordering_tag = OrderingTag())
169 : BaseT(c0,c1,c2,c3,c4,c5)
170 , ImplementationBase(backend,ordering_tag)
171 {}
172
174 T& c1,
175 T& c2,
176 T& c3,
177 T& c4,
178 T& c5,
179 T& c6,
180 const Backend& backend = Backend(),
181 const OrderingTag ordering_tag = OrderingTag())
182 : BaseT(c0,c1,c2,c3,c4,c5,c6)
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 const Backend& backend = Backend(),
195 const OrderingTag ordering_tag = OrderingTag())
196 : BaseT(c0,c1,c2,c3,c4,c5,c6,c7)
197 , ImplementationBase(backend,ordering_tag)
198 {}
199
201 T& c1,
202 T& c2,
203 T& c3,
204 T& c4,
205 T& c5,
206 T& c6,
207 T& c7,
208 T& c8,
209 const Backend& backend = Backend(),
210 const OrderingTag ordering_tag = OrderingTag())
211 : BaseT(c0,c1,c2,c3,c4,c5,c6,c7,c8)
212 , ImplementationBase(backend,ordering_tag)
213 {}
214
216 T& c1,
217 T& c2,
218 T& c3,
219 T& c4,
220 T& c5,
221 T& c6,
222 T& c7,
223 T& c8,
224 T& c9,
225 const Backend& backend = Backend(),
226 const OrderingTag ordering_tag = OrderingTag())
227 : BaseT(c0,c1,c2,c3,c4,c5,c6,c7,c8,c9)
228 , ImplementationBase(backend,ordering_tag)
229 {}
230
231 template<typename Child0, typename... Children>
232 PowerGridFunctionSpace(std::shared_ptr<Child0> child0, std::shared_ptr<Children>... children)
233 : BaseT(child0, children...)
234 , ImplementationBase(Backend(),OrderingTag())
235 {}
236
238 const Ordering &ordering() const
239 {
240 if (!this->isRootSpace())
241 {
243 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
244 }
245 if (!_ordering)
246 {
247 create_ordering();
248 this->update(*_ordering);
249 }
250 return *_ordering;
251 }
252
254 Ordering &ordering()
255 {
256 if (!this->isRootSpace())
257 {
259 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
260 }
261 if (!_ordering)
262 {
263 create_ordering();
264 this->update(*_ordering);
265 }
266 return *_ordering;
267 }
268
270 std::shared_ptr<const Ordering> orderingStorage() const
271 {
272 if (!this->isRootSpace())
273 {
275 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
276 }
277 if (!_ordering)
278 {
279 create_ordering();
280 this->update(*_ordering);
281 }
282 return _ordering;
283 }
284
286 std::shared_ptr<Ordering> orderingStorage()
287 {
288 if (!this->isRootSpace())
289 {
291 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
292 }
293 if (!_ordering)
294 {
295 create_ordering();
296 this->update(*_ordering);
297 }
298 return _ordering;
299 }
300
301 private:
302
303 // This method here is to avoid a double update of the Ordering when the user calls
304 // GFS::update() before GFS::ordering().
305 void create_ordering() const
306 {
307 _ordering = std::make_shared<Ordering>(ordering_transformation::transform(*this));
308 }
309
310 mutable std::shared_ptr<Ordering> _ordering;
311
312 };
313
314 } // namespace PDELab
315} // namespace Dune
316
317#endif // DUNE_PDELAB_GRIDFUNCTIONSPACE_POWERGRIDFUNCTIONSPACE_HH
a class holding transformation for constrained spaces
Definition: constraintstransformation.hh:20
Mixin class providing common functionality of PowerGridFunctionSpace and CompositeGridFunctionSpace.
Definition: powercompositegridfunctionspacebase.hh:73
base class for tuples of grid function spaces product of identical grid function spaces base class th...
Definition: powergridfunctionspace.hh:49
Ordering & ordering()
Direct access to the DOF ordering.
Definition: powergridfunctionspace.hh:254
PowerGridFunctionSpace(const std::array< std::shared_ptr< T >, k > &container, const Backend &backend=Backend(), const OrderingTag ordering_tag=OrderingTag())
Construct a new Power Grid Function Space object.
Definition: powergridfunctionspace.hh:113
std::shared_ptr< const Ordering > orderingStorage() const
Direct access to the storage of the DOF ordering.
Definition: powergridfunctionspace.hh:270
ImplementationBase::Traits Traits
export traits class
Definition: powergridfunctionspace.hh:104
const Ordering & ordering() const
Direct access to the DOF ordering.
Definition: powergridfunctionspace.hh:238
std::shared_ptr< Ordering > orderingStorage()
Direct access to the storage of the DOF ordering.
Definition: powergridfunctionspace.hh:286
Collect k instances of type T within a dune-typetree.
Definition: powernode.hh:50
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
void update(bool force=false)
Update the indexing information of the GridFunctionSpace.
Definition: gridfunctionspacebase.hh:259
Dune namespace.
Definition: alignedallocator.hh:11
Indicate lexicographic ordering of the unknowns of non-leaf grid function spaces.
Definition: tags.hh:63
Trait class for the multi component grid function spaces.
Definition: powercompositegridfunctionspacebase.hh:35
extract type for storing constraints
Definition: powergridfunctionspace.hh:88
Transform a TypeTree.
Definition: transformation.hh:94
static transformed_type transform(const SourceTree &s, const Transformation &t=Transformation())
Apply transformation to an existing tree s.
Definition: transformation.hh:114
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)