DUNE PDELab (2.8)

vectorgridfunctionspace.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_VECTORGRIDFUNCTIONSPACE_HH
5#define DUNE_PDELAB_GRIDFUNCTIONSPACE_VECTORGRIDFUNCTIONSPACE_HH
6
7#include <algorithm>
8#include <cstddef>
9#include <memory>
10
12
13#include <dune/typetree/powernode.hh>
14
15#include <dune/pdelab/gridfunctionspace/powercompositegridfunctionspacebase.hh>
16#include <dune/pdelab/gridfunctionspace/tags.hh>
17#include <dune/pdelab/gridfunctionspace/gridfunctionspace.hh>
18#include <dune/pdelab/gridfunctionspace/powergridfunctionspace.hh>
19
20namespace 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
109 typedef VectorGridFunctionSpaceTag ImplementationTag;
110
111 typedef TypeTree::PowerNode<LeafGFS,k> BaseT;
112
115 impl::EntitySet<GV>,
116 Backend,
119
122 impl::EntitySet<GV>,
123 Backend,
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,
142 NoConstraints
143 >::value,
144 EmptyTransformation,
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 {
208 ImplementationBase::name(name);
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
234 Ordering &ordering()
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 this->update(*_ordering);
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 this->update(*_ordering);
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
a class holding transformation for constrained spaces
Definition: constraintstransformation.hh:20
Mixin base class for specifying output hints to I/O routines like VTK.
Definition: function.hh:126
A grid function space.
Definition: gridfunctionspace.hh:191
Mixin class providing common functionality of PowerGridFunctionSpace and CompositeGridFunctionSpace.
Definition: powercompositegridfunctionspacebase.hh:73
tensorproduct space representing a vector valued function space
Definition: vectorgridfunctionspace.hh:94
std::shared_ptr< Ordering > orderingStorage()
Direct access to the storage of the DOF ordering.
Definition: vectorgridfunctionspace.hh:266
ImplementationBase::Traits Traits
export traits class
Definition: vectorgridfunctionspace.hh:154
Ordering & ordering()
Direct access to the DOF ordering.
Definition: vectorgridfunctionspace.hh:234
const Ordering & ordering() const
Direct access to the DOF ordering.
Definition: vectorgridfunctionspace.hh:218
std::shared_ptr< const Ordering > orderingStorage() const
Direct access to the storage of the DOF ordering.
Definition: vectorgridfunctionspace.hh:250
Collect k instances of type T within a dune-typetree.
Definition: powernode.hh:50
std::array< std::shared_ptr< T >, k > NodeStorage
The type used for storing the children.
Definition: powernode.hh:78
GridFunctionSpace< impl::EntitySet< GV >, FEM, NoConstraints, LeafBackend, DefaultLeafOrderingTag > & child(index_constant< i >={})
Returns the i-th child.
Definition: powernode.hh:103
#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
typename std::decay_t< T >::ImplementationTag ImplementationTag
Returns the implementation tag of the given Node.
Definition: nodeinterface.hh:71
Dune namespace.
Definition: alignedallocator.hh:11
std::shared_ptr< T > stackobject_to_shared_ptr(T &t)
Create a shared_ptr for a stack-allocated object.
Definition: shared_ptr.hh:70
This file implements several utilities related to std::shared_ptr.
Tag indicating a standard ordering for a leaf GridfunctionSpace.
Definition: tags.hh:185
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: vectorgridfunctionspace.hh:138
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 (Jul 27, 22:29, 2024)