dune-pdelab 2.10-git
Loading...
Searching...
No Matches
gridfunctionspace.hh
Go to the documentation of this file.
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
20#include <dune/geometry/type.hh>
21
24
27
28#if DUNE_VERSION_GTE_REV(DUNE_COMMON,2,10,0)
29#include <dune-pdelab-config.hh>
30#endif
31
32// This alias should be removed after a PDELab 2.7 release.
33#if DUNE_VERSION_LT_REV(DUNE_TYPETREE,2,7,1)
34namespace Dune {
35 namespace TypeTree {
36 template<std::size_t... i>
37 using StaticTreePath = TreePath<i...>;
38 }
39}
40#endif
41
54
55namespace Dune {
56 namespace PDELab {
57
61
62#ifndef DOXYGEN
63
64 namespace impl {
65
66 // Helper structs to avoid compilation failures in the
67 // backwards compatibility mode where users stuff a
68 // GridView into a GridFunctionSpace.
69 // In that case, we cannot extract the GridView type from
70 // the GridView itself, so we use a std::conditional in the
71 // Traits class to pick either one of the following structs
72 // and then use the correct class to do the lookup.
73
74 struct _lazy_identity
75 {
76 template<typename T>
77 struct evaluate
78 {
79 using type = T;
80 };
81 };
82
83 struct _lazy_extract_gridview
84 {
85 template<typename T>
86 struct evaluate
87 {
88 using type = typename T::GridView;
89 };
90 };
91
92 // Returns a GridView, regardless of whether GV_or_ES is a GridView or an EntitySet
93 template<typename GV_or_ES>
94 using GridView = typename std::conditional<
95 isEntitySet<GV_or_ES>::value,
96 impl::_lazy_extract_gridview,
97 impl::_lazy_identity
98 >::type::template evaluate<GV_or_ES>::type;
99
100
101 // Returns an EntitySet, regardless of whether GV_or_ES is a GridView or an EntitySet
102 template<typename GV_or_ES>
103 using EntitySet = typename std::conditional<
104 isEntitySet<GV_or_ES>::value,
105 GV_or_ES,
106 AllEntitySet<GV_or_ES>
107 >::type;
108
109 }
110
111#endif // DOXYGEN
112
113 //=======================================
114 // grid function space : single component case
115 //=======================================
116
118
121 template<typename G, typename L, typename C, typename B, typename O>
123 {
125 static const bool isComposite = false;
126
128 using GridView = impl::GridView<G>;
129
131 using EntitySet = impl::EntitySet<G>;
132
134
136 typedef B BackendType;
137
138 typedef B Backend;
139
141 typedef typename B::size_type SizeType;
142
145
148
150 typedef typename L::Traits::FiniteElementType FiniteElementType;
151
152 typedef typename L::Traits::FiniteElementType FiniteElement;
153
156
158
162 typedef O OrderingTag;
163
164 };
165
179 template<typename ES, typename FEM, typename CE=NoConstraints,
180 typename B=ISTL::VectorBackend<>, typename O=DefaultLeafOrderingTag>
182 : public TypeTree::LeafNode
183 , public GridFunctionSpaceBase<
184 GridFunctionSpace<ES,FEM,CE,B,O>,
185 GridFunctionSpaceTraits<ES,FEM,CE,B,O>
186 >
188 , public DataHandleProvider<GridFunctionSpace<ES,FEM,CE,B,O> >
189 {
190
192
193 template<typename,typename>
195
196 public:
199
200 private:
201
203
204 public:
205
206 typedef typename ES::Traits::template Codim<0>::Entity Element;
207 typedef typename ES::Traits::template Codim<0>::Iterator ElementIterator;
208
209 [[deprecated]]
210 typedef O SizeTag;
211
212 typedef O OrderingTag;
213
215
217
219 template<typename E>
236
237 // ****************************************************************************************************
238 // Construct from GridView
239 // ****************************************************************************************************
240
242 GridFunctionSpace (const typename Traits::GridView& gridview, const FEM& fem, const CE& ce, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
243#if DUNE_PDELAB_WARN_ON_GRIDVIEW_BASED_GFS
244 [[deprecated("GridFunctionSpaces now internally use an EntitySet instead of a GridView, please replace the template parameter and the first constructor parameter by an EntitySet.")]]
245#endif
246 : BaseT(backend,ordering_tag)
247 , pfem(stackobject_to_shared_ptr(fem))
248 , _pce(stackobject_to_shared_ptr(ce))
249 {
250 this->setEntitySet(typename Traits::EntitySet{gridview});
251 }
252
254 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())
255#if DUNE_PDELAB_WARN_ON_GRIDVIEW_BASED_GFS
256 [[deprecated("GridFunctionSpaces now internally use an EntitySet instead of a GridView, please replace the template parameter and the first constructor parameter by an EntitySet.")]]
257#endif
258 : BaseT(backend,ordering_tag)
259 , pfem(fem)
260 , _pce(ce)
261 {
262 this->setEntitySet(typename Traits::EntitySet{gridview});
263 }
264
266 GridFunctionSpace (const typename Traits::GridView& gridview, const FEM& fem, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
267#if DUNE_PDELAB_WARN_ON_GRIDVIEW_BASED_GFS
268 [[deprecated("GridFunctionSpaces now internally use an EntitySet instead of a GridView, please replace the template parameter and the first constructor parameter by an EntitySet.")]]
269#endif
270 : BaseT(backend,ordering_tag)
271 , pfem(stackobject_to_shared_ptr(fem))
272 , _pce(std::make_shared<CE>())
273 {
274 this->setEntitySet(typename Traits::EntitySet{gridview});
275 }
276
278 GridFunctionSpace (const typename Traits::GridView& gridview, const std::shared_ptr<const FEM>& fem, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
279#if DUNE_PDELAB_WARN_ON_GRIDVIEW_BASED_GFS
280 [[deprecated("GridFunctionSpaces now internally use an EntitySet instead of a GridView, please replace the template parameter and the first constructor parameter by an EntitySet.")]]
281#endif
282 : BaseT(backend,ordering_tag)
283 , pfem(fem)
284 , _pce(std::make_shared<CE>())
285 {
286 this->setEntitySet(typename Traits::EntitySet{gridview});
287 }
288
289
290 // ****************************************************************************************************
291 // Construct from EntitySet
292 // ****************************************************************************************************
293
294
310 const CE &ce, const B &backend = B(),
311 const OrderingTag &ordering_tag = OrderingTag())
312 : BaseT(backend, ordering_tag), pfem(stackobject_to_shared_ptr(fem)),
313 _pce(stackobject_to_shared_ptr(ce)) {
314 this->setEntitySet(std::move(entitySet));
315 }
316
331 const B &backend = B(),
332 const OrderingTag &ordering_tag = OrderingTag())
333 : BaseT(backend, ordering_tag)
334 , pfem(fem)
335 , _pce(ce)
336 {
337 this->setEntitySet(entitySet);
338 }
339
354 const FEM &fem,
355 const B &backend = B(),
356 const OrderingTag &ordering_tag = OrderingTag())
357 : BaseT(backend, ordering_tag)
358 , pfem(stackobject_to_shared_ptr(fem))
359 , _pce(std::make_shared<CE>())
360 {
361 this->setEntitySet(entitySet);
362 }
363
376 const B &backend = B(),
377 const OrderingTag &ordering_tag = OrderingTag())
378 : BaseT(backend, ordering_tag)
379 , pfem(fem)
380 , _pce(std::make_shared<CE>())
381 {
382 this->setEntitySet(entitySet);
383 }
384
386 const FEM& finiteElementMap () const
387 {
388 return *pfem;
389 }
390
393 {
394 return pfem;
395 }
396
398 const typename Traits::ConstraintsType& constraints () const
399 {
400 return *_pce;
401 }
402
405 {
406 return _pce;
407 }
408
409 //------------------------------
410
412 const Ordering &ordering() const
413 {
414 if (!this->isRootSpace())
415 {
417 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
418 }
419 if (!_ordering)
420 {
421 create_ordering();
422 this->update(*_ordering);
423 }
424 return *_ordering;
425 }
426
429 {
430 if (!this->isRootSpace())
431 {
433 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
434 }
435 if (!_ordering)
436 {
437 create_ordering();
438 this->update(*_ordering);
439 }
440 return *_ordering;
441 }
442
445 {
446 if (!this->isRootSpace())
447 {
449 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
450 }
451 if (!_ordering)
452 {
453 create_ordering();
454 this->update(*_ordering);
455 }
456 return _ordering;
457 }
458
461 {
462 if (!this->isRootSpace())
463 {
465 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
466 }
467 if (!_ordering)
468 {
469 create_ordering();
470 this->update(*_ordering);
471 }
472 return _ordering;
473 }
474
475 private:
476
477 // This method here is to avoid a double update of the Ordering when the user calls
478 // GFS::update() before GFS::ordering().
479 void create_ordering() const
480 {
481 _ordering = std::make_shared<Ordering>(ordering_transformation::transform(*this));
482 }
483
486
487 mutable std::shared_ptr<Ordering> _ordering;
488 };
489
490
491 } // namespace PDELab
492} // namespace Dune
493
494#endif // DUNE_PDELAB_GRIDFUNCTIONSPACE_GRIDFUNCTIONSPACE_HH
HybridTreePath< Dune::index_constant< i >... > StaticTreePath
#define DUNE_THROW(E,...)
Dune::HybridMultiIndex< T... > TreePath
std::shared_ptr< T > stackobject_to_shared_ptr(T &t)
ordering_transformation::Type Ordering
Definition gridfunctionspace.hh:216
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:278
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:309
static const bool isComposite
True if this grid function space is composed of others.
Definition gridfunctionspace.hh:125
GridFunctionSpace(const typename Traits::GridView &gridview, const FEM &fem, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition gridfunctionspace.hh:266
Traits::Backend & backend()
Definition gridfunctionspacebase.hh:281
LeafGridFunctionSpaceTag ImplementationTag
Definition gridfunctionspace.hh:214
O SizeTag
Definition gridfunctionspace.hh:210
ES::Traits::template Codim< 0 >::Entity Element
Definition gridfunctionspace.hh:206
O OrderingTag
Definition gridfunctionspace.hh:212
GridFunctionSpaceTraits< ES, FEM, CE, B, O > Traits
export Traits class
Definition gridfunctionspace.hh:198
L FiniteElementMap
finite element map
Definition gridfunctionspace.hh:147
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:254
const Traits::ConstraintsType & constraints() const
return constraints engine
Definition gridfunctionspace.hh:398
std::shared_ptr< const FEM > finiteElementMapStorage() const
get finite element map
Definition gridfunctionspace.hh:392
O OrderingTag
tag describing the ordering.
Definition gridfunctionspace.hh:162
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:141
L FiniteElementMapType
finite element map
Definition gridfunctionspace.hh:144
ES::Traits::template Codim< 0 >::Iterator ElementIterator
Definition gridfunctionspace.hh:207
GridFunctionSpace(typename Traits::EntitySet entitySet, const std::shared_ptr< const FEM > &fem, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
Definition gridfunctionspace.hh:374
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:460
std::shared_ptr< const Ordering > orderingStorage() const
Direct access to the storage of the DOF ordering.
Definition gridfunctionspace.hh:444
impl::GridView< G > GridView
the grid view where grid function is defined upon
Definition gridfunctionspace.hh:128
L::Traits::FiniteElementType FiniteElementType
finite element
Definition gridfunctionspace.hh:150
const FEM & finiteElementMap() const
get finite element map
Definition gridfunctionspace.hh:386
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:328
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:242
impl::EntitySet< G > EntitySet
the entity set of this function space.
Definition gridfunctionspace.hh:131
L::Traits::FiniteElementType FiniteElement
Definition gridfunctionspace.hh:152
Ordering & ordering()
Direct access to the DOF ordering.
Definition gridfunctionspace.hh:428
bool isRootSpace() const
Definition gridfunctionspacebase.hh:346
const Ordering & ordering() const
Direct access to the DOF ordering.
Definition gridfunctionspace.hh:412
B Backend
Definition gridfunctionspace.hh:138
std::shared_ptr< const CE > constraintsStorage() const
return storage of constraints engine
Definition gridfunctionspace.hh:404
B BackendType
vector backend
Definition gridfunctionspace.hh:136
GridFunctionSpace(typename Traits::EntitySet entitySet, const FEM &fem, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
Definition gridfunctionspace.hh:353
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:231
C ConstraintsType
type representing constraints
Definition gridfunctionspace.hh:155
GridView GridViewType
Definition gridfunctionspace.hh:133
STL namespace.
For backward compatibility – Do not use this!
Implementation & impl()
GridView(const Implementation &imp)
static transformed_type transform(const SourceTree &s, const Transformation &t=Transformation())
Definition istl/descriptors.hh:48
Mixin base class for specifying output hints to I/O routines like VTK.
Definition function.hh:126
a class holding transformation for constrained spaces
Definition constraintstransformation.hh:20
Definition constraintstransformation.hh:112
Definition noconstraints.hh:20
Definition datahandleprovider.hh:189
collect types exported by a leaf grid function space
Definition gridfunctionspace.hh:123
A grid function space.
Definition gridfunctionspace.hh:189
extract type for storing constraints
Definition gridfunctionspace.hh:221
Definition gridfunctionspacebase.hh:190
Definition gridfunctionspace/tags.hh:32
Tag indicating a standard ordering for a leaf GridfunctionSpace.
Definition gridfunctionspace/tags.hh:185
static const unsigned int value
Definition gridfunctionspace/tags.hh:139