DUNE PDELab (git)

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
181 template<typename ES, typename FEM, typename CE=NoConstraints,
182 typename B=ISTL::VectorBackend<>, typename O=DefaultLeafOrderingTag>
184 : public TypeTree::LeafNode
185 , public GridFunctionSpaceBase<
186 GridFunctionSpace<ES,FEM,CE,B,O>,
187 GridFunctionSpaceTraits<ES,FEM,CE,B,O>
188 >
190 , public DataHandleProvider<GridFunctionSpace<ES,FEM,CE,B,O> >
191 {
192
194
195 template<typename,typename>
196 friend class GridFunctionSpaceBase;
197
198 public:
201
202 private:
203
204 typedef GridFunctionSpaceBase<GridFunctionSpace,Traits> BaseT;
205
206 public:
207
208 typedef typename ES::Traits::template Codim<0>::Entity Element;
209 typedef typename ES::Traits::template Codim<0>::Iterator ElementIterator;
210
211 [[deprecated]]
212 typedef O SizeTag;
213
214 typedef O OrderingTag;
215
216 typedef LeafGridFunctionSpaceTag ImplementationTag;
217
218 typedef typename ordering_transformation::Type Ordering;
219
221 template<typename E>
223 {
224
226 typedef typename std::conditional<
227 std::is_same<
228 CE,
229 NoConstraints
230 >::value,
231 EmptyTransformation,
233 >::type Type;
234
235 private:
237 };
238
239 // ****************************************************************************************************
240 // Construct from GridView
241 // ****************************************************************************************************
242
244 GridFunctionSpace (const typename Traits::GridView& gridview, const FEM& fem, const CE& ce, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
245#if DUNE_PDELAB_WARN_ON_GRIDVIEW_BASED_GFS
246 [[deprecated("GridFunctionSpaces now internally use an EntitySet instead of a GridView, please replace the template parameter and the first constructor parameter by an EntitySet.")]]
247#endif
248 : BaseT(backend,ordering_tag)
249 , pfem(stackobject_to_shared_ptr(fem))
250 , _pce(stackobject_to_shared_ptr(ce))
251 {
252 this->setEntitySet(typename Traits::EntitySet{gridview});
253 }
254
256 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())
257#if DUNE_PDELAB_WARN_ON_GRIDVIEW_BASED_GFS
258 [[deprecated("GridFunctionSpaces now internally use an EntitySet instead of a GridView, please replace the template parameter and the first constructor parameter by an EntitySet.")]]
259#endif
260 : BaseT(backend,ordering_tag)
261 , pfem(fem)
262 , _pce(ce)
263 {
264 this->setEntitySet(typename Traits::EntitySet{gridview});
265 }
266
268 GridFunctionSpace (const typename Traits::GridView& gridview, const FEM& fem, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
269#if DUNE_PDELAB_WARN_ON_GRIDVIEW_BASED_GFS
270 [[deprecated("GridFunctionSpaces now internally use an EntitySet instead of a GridView, please replace the template parameter and the first constructor parameter by an EntitySet.")]]
271#endif
272 : BaseT(backend,ordering_tag)
273 , pfem(stackobject_to_shared_ptr(fem))
274 , _pce(std::make_shared<CE>())
275 {
276 this->setEntitySet(typename Traits::EntitySet{gridview});
277 }
278
280 GridFunctionSpace (const typename Traits::GridView& gridview, const std::shared_ptr<const FEM>& fem, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
281#if DUNE_PDELAB_WARN_ON_GRIDVIEW_BASED_GFS
282 [[deprecated("GridFunctionSpaces now internally use an EntitySet instead of a GridView, please replace the template parameter and the first constructor parameter by an EntitySet.")]]
283#endif
284 : BaseT(backend,ordering_tag)
285 , pfem(fem)
286 , _pce(std::make_shared<CE>())
287 {
288 this->setEntitySet(typename Traits::EntitySet{gridview});
289 }
290
291
292 // ****************************************************************************************************
293 // Construct from EntitySet
294 // ****************************************************************************************************
295
296
312 const CE &ce, const B &backend = B(),
313 const OrderingTag &ordering_tag = OrderingTag())
314 : BaseT(backend, ordering_tag), pfem(stackobject_to_shared_ptr(fem)),
315 _pce(stackobject_to_shared_ptr(ce)) {
316 this->setEntitySet(std::move(entitySet));
317 }
318
331 const std::shared_ptr<const FEM> &fem,
332 const std::shared_ptr<const CE> &ce,
333 const B &backend = B(),
334 const OrderingTag &ordering_tag = OrderingTag())
335 : BaseT(backend, ordering_tag)
336 , pfem(fem)
337 , _pce(ce)
338 {
339 this->setEntitySet(entitySet);
340 }
341
356 const FEM &fem,
357 const B &backend = B(),
358 const OrderingTag &ordering_tag = OrderingTag())
359 : BaseT(backend, ordering_tag)
360 , pfem(stackobject_to_shared_ptr(fem))
361 , _pce(std::make_shared<CE>())
362 {
363 this->setEntitySet(entitySet);
364 }
365
377 const std::shared_ptr<const FEM> &fem,
378 const B &backend = B(),
379 const OrderingTag &ordering_tag = OrderingTag())
380 : BaseT(backend, ordering_tag)
381 , pfem(fem)
382 , _pce(std::make_shared<CE>())
383 {
384 this->setEntitySet(entitySet);
385 }
386
388 const FEM& finiteElementMap () const
389 {
390 return *pfem;
391 }
392
394 std::shared_ptr<const FEM> finiteElementMapStorage () const
395 {
396 return pfem;
397 }
398
400 const typename Traits::ConstraintsType& constraints () const
401 {
402 return *_pce;
403 }
404
406 std::shared_ptr<const CE> constraintsStorage () const
407 {
408 return _pce;
409 }
410
411 //------------------------------
412
414 const Ordering &ordering() const
415 {
416 if (!this->isRootSpace())
417 {
419 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
420 }
421 if (!_ordering)
422 {
423 create_ordering();
424 this->update(*_ordering);
425 }
426 return *_ordering;
427 }
428
430 Ordering &ordering()
431 {
432 if (!this->isRootSpace())
433 {
435 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
436 }
437 if (!_ordering)
438 {
439 create_ordering();
440 this->update(*_ordering);
441 }
442 return *_ordering;
443 }
444
446 std::shared_ptr<const Ordering> orderingStorage() const
447 {
448 if (!this->isRootSpace())
449 {
451 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
452 }
453 if (!_ordering)
454 {
455 create_ordering();
456 this->update(*_ordering);
457 }
458 return _ordering;
459 }
460
462 std::shared_ptr<Ordering> orderingStorage()
463 {
464 if (!this->isRootSpace())
465 {
467 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
468 }
469 if (!_ordering)
470 {
471 create_ordering();
472 this->update(*_ordering);
473 }
474 return _ordering;
475 }
476
477 private:
478
479 // This method here is to avoid a double update of the Ordering when the user calls
480 // GFS::update() before GFS::ordering().
481 void create_ordering() const
482 {
483 _ordering = std::make_shared<Ordering>(ordering_transformation::transform(*this));
484 }
485
486 std::shared_ptr<FEM const> pfem;
487 std::shared_ptr<CE const> _pce;
488
489 mutable std::shared_ptr<Ordering> _ordering;
490 };
491
492
493 } // namespace PDELab
494} // namespace Dune
495
496#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:191
Base class for leaf nodes in a dune-typetree.
Definition: leafnode.hh:28
Definition of the DUNE_NO_DEPRECATED_* macros.
A few common exception classes.
Traits for type conversions and type information.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
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:280
GridFunctionSpace(typename Traits::EntitySet entitySet, const FEM &fem, const CE &ce, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
Construct a new Grid Function Space object.
Definition: gridfunctionspace.hh:311
static const bool isComposite
True if this grid function space is composed of others.
Definition: gridfunctionspace.hh:127
GridFunctionSpace(const typename Traits::GridView &gridview, const FEM &fem, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:268
GridFunctionSpaceTraits< ES, FEM, CE, B, O > Traits
export Traits class
Definition: gridfunctionspace.hh:200
L FiniteElementMap
finite element map
Definition: gridfunctionspace.hh:149
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:256
const Traits::ConstraintsType & constraints() const
return constraints engine
Definition: gridfunctionspace.hh:400
std::shared_ptr< const FEM > finiteElementMapStorage() const
get finite element map
Definition: gridfunctionspace.hh:394
O OrderingTag
tag describing the ordering.
Definition: gridfunctionspace.hh:164
void setEntitySet(typename Traits::EntitySet entity_set)
Set the Entity Set object to this grid function space.
Definition: gridfunctionspacebase.hh:329
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
GridFunctionSpace(typename Traits::EntitySet entitySet, const std::shared_ptr< const FEM > &fem, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
Definition: gridfunctionspace.hh:376
void update(bool force=false)
Update the indexing information of the GridFunctionSpace.
Definition: gridfunctionspacebase.hh:259
std::shared_ptr< Ordering > orderingStorage()
Direct access to the storage of the DOF ordering.
Definition: gridfunctionspace.hh:462
std::shared_ptr< const Ordering > orderingStorage() const
Direct access to the storage of the DOF ordering.
Definition: gridfunctionspace.hh:446
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
const FEM & finiteElementMap() const
get finite element map
Definition: gridfunctionspace.hh:388
const Traits::EntitySet & entitySet() const
get entity set
Definition: gridfunctionspacebase.hh:298
GridFunctionSpace(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())
Definition: gridfunctionspace.hh:330
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:244
impl::EntitySet< G > EntitySet
the entity set of this function space.
Definition: gridfunctionspace.hh:133
Ordering & ordering()
Direct access to the DOF ordering.
Definition: gridfunctionspace.hh:430
const Ordering & ordering() const
Direct access to the DOF ordering.
Definition: gridfunctionspace.hh:414
std::shared_ptr< const CE > constraintsStorage() const
return storage of constraints engine
Definition: gridfunctionspace.hh:406
B BackendType
vector backend
Definition: gridfunctionspace.hh:138
GridFunctionSpace(typename Traits::EntitySet entitySet, const FEM &fem, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
Definition: gridfunctionspace.hh:355
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:233
C ConstraintsType
type representing constraints
Definition: gridfunctionspace.hh:157
typename std::decay_t< T >::ImplementationTag ImplementationTag
Returns the implementation tag of the given Node.
Definition: nodeinterface.hh:74
Dune namespace.
Definition: alignedallocator.hh:13
std::shared_ptr< T > stackobject_to_shared_ptr(T &t)
Create a shared_ptr for a stack-allocated object.
Definition: shared_ptr.hh:72
STL namespace.
This file implements several utilities related to std::shared_ptr.
Standard Dune debug streams.
Static tag representing a codimension.
Definition: dimension.hh:24
collect types exported by a leaf grid function space
Definition: gridfunctionspace.hh:125
extract type for storing constraints
Definition: gridfunctionspace.hh:223
Tag indicating a standard ordering for a leaf GridfunctionSpace.
Definition: tags.hh:185
Transform a TypeTree.
Definition: transformation.hh:96
static transformed_type transform(const SourceTree &s, const Transformation &t=Transformation())
Apply transformation to an existing tree s.
Definition: transformation.hh:116
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 (Nov 12, 23:30, 2024)