DUNE PDELab (2.7)

gridfunctionspace.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_PDELAB_GRIDFUNCTIONSPACE_GRIDFUNCTIONSPACE_HH
4#define DUNE_PDELAB_GRIDFUNCTIONSPACE_GRIDFUNCTIONSPACE_HH
5
6#include <cstddef>
7#include <map>
8#include <ostream>
9#include <set>
10#include <vector>
11#include <memory>
12
18
19#include <dune/geometry/referenceelements.hh>
20#include <dune/geometry/type.hh>
21
22#include <dune/localfunctions/common/interfaceswitch.hh>
23#include <dune/localfunctions/common/localkey.hh>
24
26#include <dune/typetree/typetree.hh>
27
28// This alias should be removed after a PDELab 2.7 release.
29#if DUNE_VERSION_LT_REV(DUNE_TYPETREE,2,7,1)
30namespace Dune {
31 namespace TypeTree {
32 template<std::size_t... i>
33 using StaticTreePath = TreePath<i...>;
34 }
35}
36#endif
37
38#include <dune/pdelab/common/partitionviewentityset.hh>
39#include <dune/pdelab/backend/interface.hh>
40
41// we just want the descriptors here, so we temporarily switch off the warning for
42// directly including ISTL backend headers
43#define _DUNE_PDELAB_SUPPRESS_ISTL_HH_WARNING
44#include <dune/pdelab/backend/istl/descriptors.hh>
45#undef _DUNE_PDELAB_SUPPRESS_ISTL_HH_WARNING
46
47#include <dune/pdelab/constraints/noconstraints.hh>
48#include <dune/pdelab/gridfunctionspace/compositegridfunctionspace.hh>
49#include <dune/pdelab/gridfunctionspace/datahandleprovider.hh>
50#include <dune/pdelab/gridfunctionspace/gridfunctionspacebase.hh>
51#include <dune/pdelab/gridfunctionspace/gridfunctionspaceutilities.hh>
52#include <dune/pdelab/gridfunctionspace/powergridfunctionspace.hh>
53#include <dune/pdelab/gridfunctionspace/tags.hh>
54#include <dune/pdelab/ordering/gridviewordering.hh>
55#include <dune/pdelab/ordering/lexicographicordering.hh>
56
57namespace Dune {
58 namespace PDELab {
59
63
64#ifndef DOXYGEN
65
66 namespace impl {
67
68 // Helper structs to avoid compilation failures in the
69 // backwards compatibility mode where users stuff a
70 // GridView into a GridFunctionSpace.
71 // In that case, we cannot extract the GridView type from
72 // the GridView itself, so we use a std::conditional in the
73 // Traits class to pick either one of the following structs
74 // and then use the correct class to do the lookup.
75
76 struct _lazy_identity
77 {
78 template<typename T>
79 struct evaluate
80 {
81 using type = T;
82 };
83 };
84
85 struct _lazy_extract_gridview
86 {
87 template<typename T>
88 struct evaluate
89 {
90 using type = typename T::GridView;
91 };
92 };
93
94 // Returns a GridView, regardless of whether GV_or_ES is a GridView or an EntitySet
95 template<typename GV_or_ES>
96 using GridView = typename std::conditional<
97 isEntitySet<GV_or_ES>::value,
98 impl::_lazy_extract_gridview,
99 impl::_lazy_identity
100 >::type::template evaluate<GV_or_ES>::type;
101
102
103 // Returns an EntitySet, regardless of whether GV_or_ES is a GridView or an EntitySet
104 template<typename GV_or_ES>
105 using EntitySet = typename std::conditional<
106 isEntitySet<GV_or_ES>::value,
107 GV_or_ES,
108 AllEntitySet<GV_or_ES>
109 >::type;
110
111 }
112
113#endif // DOXYGEN
114
115 //=======================================
116 // grid function space : single component case
117 //=======================================
118
120
123 template<typename G, typename L, typename C, typename B, typename O>
125 {
127 static const bool isComposite = false;
128
130 using GridView = impl::GridView<G>;
131
133 using EntitySet = impl::EntitySet<G>;
134
135 using GridViewType = GridView;
136
138 typedef B BackendType;
139
140 typedef B Backend;
141
143 typedef typename B::size_type SizeType;
144
147
150
152 typedef typename L::Traits::FiniteElementType FiniteElementType;
153
154 typedef typename L::Traits::FiniteElementType FiniteElement;
155
158
160
164 typedef O OrderingTag;
165
166 };
167
176 template<typename GV, typename FEM, typename CE=NoConstraints,
177 typename B=ISTL::VectorBackend<>, typename O=DefaultLeafOrderingTag>
179 : public TypeTree::LeafNode
180 , public GridFunctionSpaceBase<
181 GridFunctionSpace<GV,FEM,CE,B,O>,
182 GridFunctionSpaceTraits<GV,FEM,CE,B,O>
183 >
185 , public DataHandleProvider<GridFunctionSpace<GV,FEM,CE,B,O> >
186 {
187
189
190 template<typename,typename>
191 friend class GridFunctionSpaceBase;
192
193 public:
196
197 private:
198
199 typedef GridFunctionSpaceBase<GridFunctionSpace,Traits> BaseT;
200
201 public:
202
203 typedef typename GV::Traits::template Codim<0>::Entity Element;
204 typedef typename GV::Traits::template Codim<0>::Iterator ElementIterator;
205
207 typedef O SizeTag;
208
209 typedef O OrderingTag;
210
211 typedef LeafGridFunctionSpaceTag ImplementationTag;
212
213 typedef typename ordering_transformation::Type Ordering;
214
216 template<typename E>
218 {
219
221 typedef typename std::conditional<
222 std::is_same<
223 CE,
224 NoConstraints
225 >::value,
226 EmptyTransformation,
228 >::type Type;
229
230 private:
232 };
233
234 // ****************************************************************************************************
235 // Construct from GridView
236 // ****************************************************************************************************
237
239 GridFunctionSpace (const typename Traits::GridView& gridview, const FEM& fem, const CE& ce, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
240#if DUNE_PDELAB_WARN_ON_GRIDVIEW_BASED_GFS
241 DUNE_DEPRECATED_MSG("GridFunctionSpaces now internally use an EntitySet instead of a GridView, please replace the template parameter and the first constructor parameter by an EntitySet").
242#endif
243 : BaseT(backend,ordering_tag)
244 , _es(gridview)
245 , pfem(stackobject_to_shared_ptr(fem))
246 , _pce(stackobject_to_shared_ptr(ce))
247 {
248 }
249
251 GridFunctionSpace (const typename Traits::GridView& gridview, const std::shared_ptr<const FEM>& fem, const std::shared_ptr<const CE>& ce, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
252#if DUNE_PDELAB_WARN_ON_GRIDVIEW_BASED_GFS
253 DUNE_DEPRECATED_MSG("GridFunctionSpaces now internally use an EntitySet instead of a GridView, please replace the template parameter and the first constructor parameter by an EntitySet").
254#endif
255 : BaseT(backend,ordering_tag)
256 , _es(gridview)
257 , pfem(fem)
258 , _pce(ce)
259 {}
260
262 GridFunctionSpace (const typename Traits::GridView& gridview, const FEM& fem, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
263#if DUNE_PDELAB_WARN_ON_GRIDVIEW_BASED_GFS
264 DUNE_DEPRECATED_MSG("GridFunctionSpaces now internally use an EntitySet instead of a GridView, please replace the template parameter and the first constructor parameter by an EntitySet").
265#endif
266 : BaseT(backend,ordering_tag)
267 , _es(gridview)
268 , pfem(stackobject_to_shared_ptr(fem))
269 , _pce(std::make_shared<CE>())
270 {}
271
273 GridFunctionSpace (const typename Traits::GridView& gridview, const std::shared_ptr<const FEM>& fem, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
274#if DUNE_PDELAB_WARN_ON_GRIDVIEW_BASED_GFS
275 DUNE_DEPRECATED_MSG("GridFunctionSpaces now internally use an EntitySet instead of a GridView, please replace the template parameter and the first constructor parameter by an EntitySet").
276#endif
277 : BaseT(backend,ordering_tag)
278 , _es(gridview)
279 , pfem(fem)
280 , _pce(std::make_shared<CE>())
281 {}
282
283
284 // ****************************************************************************************************
285 // Construct from EntitySet
286 // ****************************************************************************************************
287
288
290 GridFunctionSpace (const typename Traits::EntitySet& entitySet, const FEM& fem, const CE& ce, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
291 : BaseT(backend,ordering_tag)
292 , _es(entitySet)
293 , pfem(stackobject_to_shared_ptr(fem))
294 , _pce(stackobject_to_shared_ptr(ce))
295 {
296 }
297
299 GridFunctionSpace (const typename Traits::EntitySet& entitySet, const std::shared_ptr<const FEM>& fem, const std::shared_ptr<const CE>& ce, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
300 : BaseT(backend,ordering_tag)
301 , _es(entitySet)
302 , pfem(fem)
303 , _pce(ce)
304 {}
305
307 GridFunctionSpace (const typename Traits::EntitySet& entitySet, const FEM& fem, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
308 : BaseT(backend,ordering_tag)
309 , _es(entitySet)
310 , pfem(stackobject_to_shared_ptr(fem))
311 , _pce(std::make_shared<CE>())
312 {}
313
315 GridFunctionSpace (const typename Traits::EntitySet& entitySet, const std::shared_ptr<const FEM>& fem, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
316 : BaseT(backend,ordering_tag)
317 , _es(entitySet)
318 , pfem(fem)
319 , _pce(std::make_shared<CE>())
320 {}
321
322
324 const typename Traits::GridView& gridView () const
325 {
326 return _es.gridView();
327 }
328
330 const typename Traits::EntitySet& entitySet () const
331 {
332 return _es;
333 }
334
336 const FEM& finiteElementMap () const
337 {
338 return *pfem;
339 }
340
342 std::shared_ptr<const FEM> finiteElementMapStorage () const
343 {
344 return pfem;
345 }
346
348 const typename Traits::ConstraintsType& constraints () const
349 {
350 return *_pce;
351 }
352
354 std::shared_ptr<const CE> constraintsStorage () const
355 {
356 return _pce;
357 }
358
359 //------------------------------
360
362 const Ordering &ordering() const
363 {
364 if (!this->isRootSpace())
365 {
367 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
368 }
369 if (!_ordering)
370 {
371 create_ordering();
372 this->update(*_ordering);
373 }
374 return *_ordering;
375 }
376
378 Ordering &ordering()
379 {
380 if (!this->isRootSpace())
381 {
383 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
384 }
385 if (!_ordering)
386 {
387 create_ordering();
388 this->update(*_ordering);
389 }
390 return *_ordering;
391 }
392
394 std::shared_ptr<const Ordering> orderingStorage() const
395 {
396 if (!this->isRootSpace())
397 {
399 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
400 }
401 if (!_ordering)
402 {
403 create_ordering();
404 this->update(*_ordering);
405 }
406 return _ordering;
407 }
408
410 std::shared_ptr<Ordering> orderingStorage()
411 {
412 if (!this->isRootSpace())
413 {
415 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
416 }
417 if (!_ordering)
418 {
419 create_ordering();
420 this->update(*_ordering);
421 }
422 return _ordering;
423 }
424
425 private:
426
427 // This method here is to avoid a double update of the Ordering when the user calls
428 // GFS::update() before GFS::ordering().
429 void create_ordering() const
430 {
431 _ordering = std::make_shared<Ordering>(ordering_transformation::transform(*this));
432 }
433
434 typename Traits::EntitySet _es;
435 std::shared_ptr<FEM const> pfem;
436 std::shared_ptr<CE const> _pce;
437
438 mutable std::shared_ptr<Ordering> _ordering;
439 };
440
441
442 } // namespace PDELab
443} // namespace Dune
444
445#endif // DUNE_PDELAB_GRIDFUNCTIONSPACE_GRIDFUNCTIONSPACE_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:186
Base class for leaf nodes in a dune-typetree.
Definition: leafnode.hh:25
Definition of the DUNE_DEPRECATED macro for the case that config.h is not available.
A few common exception classes.
Traits for type conversions and type information.
#define DUNE_DEPRECATED_MSG(text)
Mark some entity as deprecated.
Definition: deprecated.hh:169
#define DUNE_DEPRECATED
Mark some entity as deprecated.
Definition: deprecated.hh:84
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
const Traits::GridView & gridView() const
get grid view
Definition: gridfunctionspace.hh:324
std::shared_ptr< const FEM > finiteElementMapStorage() const
get finite element map
Definition: gridfunctionspace.hh:342
GridFunctionSpace(const typename Traits::GridView &gridview, const FEM &fem, const CE &ce, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:239
GridFunctionSpace(const typename Traits::EntitySet &entitySet, const std::shared_ptr< const FEM > &fem, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:315
const Traits::EntitySet & entitySet() const
get EntitySet
Definition: gridfunctionspace.hh:330
static const bool isComposite
True if this grid function space is composed of others.
Definition: gridfunctionspace.hh:127
std::shared_ptr< Ordering > orderingStorage()
Direct access to the storage of the DOF ordering.
Definition: gridfunctionspace.hh:410
std::conditional< std::is_same< CE, NoConstraints >::value, EmptyTransformation, ConstraintsTransformation< typenameOrdering::Traits::DOFIndex, typenameOrdering::Traits::ContainerIndex, E > >::type Type
define Type as the Type of a container of E's
Definition: gridfunctionspace.hh:228
GridFunctionSpace(const typename Traits::GridView &gridview, const std::shared_ptr< const FEM > &fem, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:273
L FiniteElementMap
finite element map
Definition: gridfunctionspace.hh:149
const FEM & finiteElementMap() const
get finite element map
Definition: gridfunctionspace.hh:336
O OrderingTag
tag describing the ordering.
Definition: gridfunctionspace.hh:164
B::size_type SizeType
short cut for size type exported by Backend
Definition: gridfunctionspace.hh:143
L FiniteElementMapType
finite element map
Definition: gridfunctionspace.hh:146
void update(bool force=false)
Update the indexing information of the GridFunctionSpace.
Definition: gridfunctionspacebase.hh:205
const Ordering & ordering() const
Direct access to the DOF ordering.
Definition: gridfunctionspace.hh:362
GridFunctionSpace(const typename Traits::EntitySet &entitySet, const FEM &fem, const CE &ce, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:290
impl::GridView< G > GridView
the grid view where grid function is defined upon
Definition: gridfunctionspace.hh:130
L::Traits::FiniteElementType FiniteElementType
finite element
Definition: gridfunctionspace.hh:152
Ordering & ordering()
Direct access to the DOF ordering.
Definition: gridfunctionspace.hh:378
GridFunctionSpaceTraits< GV, FEM, CE, B, O > Traits
export Traits class
Definition: gridfunctionspace.hh:195
GridFunctionSpace(const typename Traits::EntitySet &entitySet, const std::shared_ptr< const FEM > &fem, const std::shared_ptr< const CE > &ce, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:299
std::shared_ptr< const Ordering > orderingStorage() const
Direct access to the storage of the DOF ordering.
Definition: gridfunctionspace.hh:394
GridFunctionSpace(const typename Traits::GridView &gridview, const std::shared_ptr< const FEM > &fem, const std::shared_ptr< const CE > &ce, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:251
impl::EntitySet< G > EntitySet
the entity set of this function space.
Definition: gridfunctionspace.hh:133
const Traits::ConstraintsType & constraints() const
return constraints engine
Definition: gridfunctionspace.hh:348
std::shared_ptr< const CE > constraintsStorage() const
return storage of constraints engine
Definition: gridfunctionspace.hh:354
O SizeTag
Definition: gridfunctionspace.hh:207
GridFunctionSpace(const typename Traits::GridView &gridview, const FEM &fem, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:262
B BackendType
vector backend
Definition: gridfunctionspace.hh:138
C ConstraintsType
type representing constraints
Definition: gridfunctionspace.hh:157
GridFunctionSpace(const typename Traits::EntitySet &entitySet, const FEM &fem, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:307
typename std::decay_t< T >::ImplementationTag ImplementationTag
Returns the implementation tag of the given Node.
Definition: nodeinterface.hh:66
Dune namespace.
Definition: alignedallocator.hh:14
shared_ptr< T > stackobject_to_shared_ptr(T &t)
Create a shared_ptr for a stack-allocated object.
Definition: shared_ptr.hh:75
STL namespace.
This file implements the class shared_ptr (a reference counting pointer), for those systems that don'...
Standard Dune debug streams.
Static tag representing a codimension.
Definition: dimension.hh:22
collect types exported by a leaf grid function space
Definition: gridfunctionspace.hh:125
extract type for storing constraints
Definition: gridfunctionspace.hh:218
Tag indicating a standard ordering for a leaf GridfunctionSpace.
Definition: tags.hh:185
Transform a TypeTree.
Definition: transformation.hh:93
static transformed_type transform(const SourceTree &s, const Transformation &t=Transformation())
Apply transformation to an existing tree s.
Definition: transformation.hh:113
A unique label for each type of element that can occur in a grid.
Various macros to work with Dune module version numbers.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)