DUNE PDELab (2.8)

compositegridfunctionspace.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_COMPOSITEGRIDFUNCTIONSPACE_HH
5#define DUNE_PDELAB_GRIDFUNCTIONSPACE_COMPOSITEGRIDFUNCTIONSPACE_HH
6
7#include <memory>
8
9#include <dune/typetree/compositenode.hh>
10#include <dune/typetree/utility.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 // composite grid function space
21 //=======================================
22
26
37 template<typename Backend,
38 typename OrderingTag,
39 typename... Children>
41 : public TypeTree::CompositeNode<Children...>
43 CompositeGridFunctionSpace<
44 Backend,
45 OrderingTag,
46 Children...>,
47 typename TypeTree::Child<TypeTree::CompositeNode<Children...>,0>::Traits::EntitySet,
48 Backend,
49 OrderingTag,
50 sizeof...(Children)
51 >
52 , public DataHandleProvider<CompositeGridFunctionSpace<Backend,OrderingTag,Children...> >
53 {
54 typedef TypeTree::CompositeNode<Children...> NodeT;
55
59 Backend,
60 OrderingTag,
61 sizeof...(Children)> ImplementationBase;
62
65 typename TypeTree::Child<NodeT,0>::Traits::EntitySet,
66 Backend,
67 OrderingTag,
68 sizeof...(Children)>;
69
70 typedef TypeTree::TransformTree<CompositeGridFunctionSpace,
71 gfs_to_ordering<CompositeGridFunctionSpace>
73
74 template<typename,typename>
75 friend class GridFunctionSpaceBase;
76
77 public:
78 typedef CompositeGridFunctionSpaceTag ImplementationTag;
79
80 typedef typename ordering_transformation::Type Ordering;
81
83 template<typename E>
85 {
86 typedef typename std::conditional<
87 // check against all children.
88 // Use EmptyTransformation, iif all Children use EmptyTransformation
89 std::conjunction_v<
90 std::is_same<
91 EmptyTransformation,
92 typename Children::template ConstraintsContainer<E>::Type>...>,
93 EmptyTransformation,
95 typename Ordering::Traits::DOFIndex,
96 typename Ordering::Traits::ContainerIndex,
97 E
98 >
99 >::type Type;
100 };
101
102 typedef typename ImplementationBase::Traits Traits;
103
104 // ********************************************************************************
105 // constructors for stack-constructed children passed in by reference
106 // ********************************************************************************
107
108 CompositeGridFunctionSpace(const Backend& backend, Children&... children)
109 : NodeT(TypeTree::assertGridViewType<typename NodeT::template Child<0>::Type>(children)...)
110 , ImplementationBase(backend,OrderingTag())
111 { }
112
113 CompositeGridFunctionSpace(const OrderingTag& ordering_tag, Children&... children)
114 : NodeT(TypeTree::assertGridViewType<typename NodeT::template Child<0>::Type>(children)...)
115 , ImplementationBase(Backend(),ordering_tag)
116 { }
117
118 CompositeGridFunctionSpace(const Backend& backend, const OrderingTag& ordering_tag, Children&... children)
119 : NodeT(TypeTree::assertGridViewType<typename NodeT::template Child<0>::Type>(children)...)
120 , ImplementationBase(backend,ordering_tag)
121 { }
122
123 CompositeGridFunctionSpace(Children&... children)
124 : NodeT(TypeTree::assertGridViewType<typename NodeT::template Child<0>::Type>(children)...)
125 , ImplementationBase(Backend(),OrderingTag())
126 { }
127
128 // ********************************************************************************
129 // constructors for heap-constructed children passed in as shared_ptrs
130 // ********************************************************************************
131
132 CompositeGridFunctionSpace(const Backend& backend, std::shared_ptr<Children>... children)
133 : NodeT(children...)
134 , ImplementationBase(backend,OrderingTag())
135 { }
136
137 CompositeGridFunctionSpace(const OrderingTag& ordering_tag, std::shared_ptr<Children>... children)
138 : NodeT(children...)
139 , ImplementationBase(Backend(),ordering_tag)
140 { }
141
142 CompositeGridFunctionSpace(const Backend& backend, const OrderingTag& ordering_tag, std::shared_ptr<Children>... children)
143 : NodeT(children...)
144 , ImplementationBase(backend,ordering_tag)
145 { }
146
147 CompositeGridFunctionSpace(std::shared_ptr<Children>... children)
148 : NodeT(children...)
149 , ImplementationBase(Backend(),OrderingTag())
150 { }
151
152
154 const Ordering &ordering() const
155 {
156 if (!this->isRootSpace())
157 {
159 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
160 }
161 if (!_ordering)
162 {
163 create_ordering();
164 this->update(*_ordering);
165 }
166 return *_ordering;
167 }
168
170 Ordering &ordering()
171 {
172 if (!this->isRootSpace())
173 {
175 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
176 }
177 if (!_ordering)
178 {
179 create_ordering();
180 this->update(*_ordering);
181 }
182 return *_ordering;
183 }
184
186 std::shared_ptr<const Ordering> orderingStorage() const
187 {
188 if (!this->isRootSpace())
189 {
191 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
192 }
193 if (!_ordering)
194 {
195 create_ordering();
196 this->update(*_ordering);
197 }
198 return _ordering;
199 }
200
202 std::shared_ptr<Ordering> orderingStorage()
203 {
204 if (!this->isRootSpace())
205 {
207 "Ordering can only be obtained for root space in GridFunctionSpace tree.");
208 }
209 if (!_ordering)
210 {
211 create_ordering();
212 this->update(*_ordering);
213 }
214 return _ordering;
215 }
216
217
218 private:
219
220 // This method here is to avoid a double update of the Ordering when the user calls
221 // GFS::update() before GFS::ordering().
222 void create_ordering() const
223 {
224 _ordering = std::make_shared<Ordering>(ordering_transformation::transform(*this));
225 }
226
227 mutable std::shared_ptr<Ordering> _ordering;
228
229 };
230
232
233 } // namespace PDELab
234} // namespace Dune
235
236#endif // DUNE_PDELAB_GRIDFUNCTIONSPACE_COMPOSITEGRIDFUNCTIONSPACE_HH
base class for tuples of grid function spaces base class that holds implementation of the methods thi...
Definition: compositegridfunctionspace.hh:53
std::shared_ptr< Ordering > orderingStorage()
Direct access to the storage of the DOF ordering.
Definition: compositegridfunctionspace.hh:202
const Ordering & ordering() const
Direct access to the DOF ordering.
Definition: compositegridfunctionspace.hh:154
std::shared_ptr< const Ordering > orderingStorage() const
Direct access to the storage of the DOF ordering.
Definition: compositegridfunctionspace.hh:186
Ordering & ordering()
Direct access to the DOF ordering.
Definition: compositegridfunctionspace.hh:170
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 composite nodes based on variadic templates.
Definition: compositenode.hh:26
#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 impl::_Child< Node, indices... >::type Child
Template alias for the type of a child node given by a list of child indices.
Definition: childextraction.hh:223
Dune namespace.
Definition: alignedallocator.hh:11
extract type for storing constraints
Definition: compositegridfunctionspace.hh:85
Trait class for the multi component grid function spaces.
Definition: powercompositegridfunctionspacebase.hh:35
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)