DUNE PDELab (2.8)

entityblockedlocalordering.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_ORDERING_ENTITYBLOCKEDLOCALORDERING_HH
5#define DUNE_PDELAB_ORDERING_ENTITYBLOCKEDLOCALORDERING_HH
6
7#include <cstddef>
8#include <ostream>
9#include <string>
10
16#include <dune/common/hybridutilities.hh>
17
18#include <dune/typetree/compositenode.hh>
19#include <dune/typetree/powernode.hh>
20#include <dune/typetree/traversal.hh>
21#include <dune/typetree/visitor.hh>
22#include <dune/typetree/typetraits.hh>
23
24#include <dune/pdelab/ordering/gridviewordering.hh>
25
26namespace Dune {
27 namespace PDELab {
28
31
32 template<typename ChildOrdering, std::size_t k>
33 class PowerEntityBlockedLocalOrdering
34 : public TypeTree::PowerNode<ChildOrdering,k>
35 , public LocalOrderingBase<typename ChildOrdering::Traits::EntitySet,
36 typename ChildOrdering::Traits::DOFIndex,
37 typename ChildOrdering::Traits::ContainerIndex>
38 {
39
40 typedef TypeTree::PowerNode<ChildOrdering,k> NodeT;
41 typedef LocalOrderingBase<typename ChildOrdering::Traits::EntitySet,
42 typename ChildOrdering::Traits::DOFIndex,
43 typename ChildOrdering::Traits::ContainerIndex> BaseT;
44
45 public:
46
47 static const bool consume_tree_index = true;
48
49 typedef typename BaseT::Traits Traits;
50
51 PowerEntityBlockedLocalOrdering(const typename NodeT::NodeStorage& child_storage, bool container_blocked)
52 : NodeT(child_storage)
53 , BaseT(*this,container_blocked,nullptr)
54 {}
55
56 using BaseT::size;
57
64 typename Traits::SizeType
65 size(const typename Traits::ContainerIndex& suffix,
66 const typename Traits::DOFIndex::EntityIndex &index) const {
67 return this->node_size(*this,suffix,index);
68 }
69 };
70
71
72 template<typename GFS, typename Transformation>
73 struct power_gfs_to_local_ordering_descriptor<GFS,Transformation,EntityBlockedOrderingTag>
74 {
75
76 static const bool recursive = true;
77
78 template<typename TC>
79 struct result
80 {
81 typedef PowerEntityBlockedLocalOrdering<TC,TypeTree::StaticDegree<GFS>::value> type;
82 typedef std::shared_ptr<type> storage_type;
83 };
84
85 template<typename TC>
86 static typename result<TC>::type transform(const GFS& gfs, const Transformation& t, const std::array<std::shared_ptr<TC>,TypeTree::StaticDegree<GFS>::value>& children)
87 {
88 return typename result<TC>::type(children,gfs.backend().blocked(gfs));
89 }
90
91 template<typename TC>
92 static typename result<TC>::storage_type transform_storage(std::shared_ptr<const GFS> gfs, const Transformation& t, const std::array<std::shared_ptr<TC>,TypeTree::StaticDegree<GFS>::value>& children)
93 {
94 return std::make_shared<typename result<TC>::type>(children,gfs->backend().blocked(*gfs));
95 }
96
97 };
98
99
100
101 template<typename GFS, typename Transformation>
102 struct power_gfs_to_entityblocked_ordering_descriptor
103 {
104
105 static const bool recursive = false;
106
107 typedef TypeTree::TransformTree<GFS,gfs_to_local_ordering<Transformation> > LocalOrderingTransformation;
108 typedef typename LocalOrderingTransformation::Type LocalOrdering;
109
110 typedef GridViewOrdering<LocalOrdering> transformed_type;
111
112 typedef std::shared_ptr<transformed_type> transformed_storage_type;
113
114 using EntitySet = typename GFS::Traits::EntitySet;
115
116 static transformed_type transform(const GFS& gfs, const Transformation& t)
117 {
118 // check and extract common entity set on leaf nodes
119 auto es_visitor = impl::common_entity_set<EntitySet>{};
120 TypeTree::applyToTree(gfs, es_visitor);
121 assert(es_visitor._entity_set);
122 auto& es = *es_visitor._entity_set;
123 // build local ordering tree
124 auto local_ordering = std::make_shared<LocalOrdering>(LocalOrderingTransformation::transform(gfs,gfs_to_local_ordering<Transformation>()));
125 bool blocked = gfs.backend().blocked(gfs);
126 // create grid view ordering
127 transformed_type r(make_tuple(std::move(local_ordering)),blocked,const_cast<GFS*>(&gfs),es);
128 return r;
129 }
130
131 static transformed_storage_type transform_storage(std::shared_ptr<const GFS> gfs, const Transformation& t)
132 {
133 // check and extract common entity set on leaf nodes
134 auto es_visitor = impl::common_entity_set<EntitySet>{};
135 TypeTree::applyToTree(*gfs, es_visitor);
136 assert(es_visitor._entity_set);
137 auto& es = *es_visitor._entity_set;
138 // build local ordering tree
139 auto local_ordering = LocalOrderingTransformation::transform_storage(gfs,gfs_to_local_ordering<Transformation>());
140 bool blocked = gfs->backend().blocked(*gfs);
141 // create grid view ordering
142 transformed_storage_type r(std::make_shared<transformed_type>(make_tuple(std::move(local_ordering)),blocked,const_cast<GFS*>(gfs.get()),es));
143 return r;
144 }
145
146 };
147
148 template<typename GFS, typename Transformation>
149 power_gfs_to_entityblocked_ordering_descriptor<GFS,Transformation>
150 register_power_gfs_to_ordering_descriptor(GFS*,Transformation*,EntityBlockedOrderingTag*);
151
152
153
154 template<typename... Children>
155 class CompositeEntityBlockedLocalOrdering
156 : public TypeTree::CompositeNode<Children...>
157 , public LocalOrderingBase<typename first_type<Children...>::type::Traits::EntitySet,
158 typename first_type<Children...>::type::Traits::DOFIndex,
159 typename first_type<Children...>::type::Traits::ContainerIndex>
160 {
161
162 typedef TypeTree::CompositeNode<Children...> Node;
163 typedef LocalOrderingBase<typename first_type<Children...>::type::Traits::EntitySet,
164 typename first_type<Children...>::type::Traits::DOFIndex,
165 typename first_type<Children...>::type::Traits::ContainerIndex> Base;
166
167 public:
168
169 typedef typename Base::Traits Traits;
170
171 static const bool consume_tree_index = true;
172
173 CompositeEntityBlockedLocalOrdering(bool container_blocked, std::shared_ptr<Children>... children)
174 : Node(children...)
175 , Base(*this,container_blocked,nullptr)
176 {}
177
178 using Base::size;
179
189 typename Traits::SizeType
190 size(const typename Traits::ContainerIndex &suffix,
191 const typename Traits::DOFIndex::EntityIndex &index) const {
192 return this->node_size(*this,suffix,index);
193 }
194
195 };
196
197
198 template<typename GFS, typename Transformation>
199 struct composite_gfs_to_local_ordering_descriptor<GFS,Transformation,EntityBlockedOrderingTag>
200 {
201
202 static const bool recursive = true;
203
204 template<typename... TC>
205 struct result
206 {
207 typedef CompositeEntityBlockedLocalOrdering<TC...> type;
208 typedef std::shared_ptr<type> storage_type;
209 };
210
211 template<typename... TC>
212 static typename result<TC...>::type transform(const GFS& gfs, const Transformation& t, std::shared_ptr<TC>... children)
213 {
214 return typename result<TC...>::type(gfs.backend().blocked(gfs),children...);
215 }
216
217 template<typename... TC>
218 static typename result<TC...>::storage_type transform_storage(std::shared_ptr<const GFS> gfs, const Transformation& t, std::shared_ptr<TC>... children)
219 {
220 return std::make_shared<typename result<TC...>::type>(gfs->backend().blocked(*gfs),children...);
221 }
222
223 };
224
225 template<typename GFS, typename Transformation>
226 struct composite_gfs_to_entityblocked_ordering_descriptor
227 {
228 static const bool recursive = false;
229
230 typedef TypeTree::TransformTree<GFS,gfs_to_local_ordering<Transformation> > LocalOrderingTransformation;
231 typedef typename LocalOrderingTransformation::Type LocalOrdering;
232
233 typedef GridViewOrdering<LocalOrdering> transformed_type;
234
235 typedef std::shared_ptr<transformed_type> transformed_storage_type;
236
237 using EntitySet = typename GFS::Traits::EntitySet;
238
239 static transformed_type transform(const GFS& gfs, const Transformation& t)
240 {
241 // check and extract common entity set on leaf nodes
242 auto es_visitor = impl::common_entity_set<EntitySet>{};
243 TypeTree::applyToTree(gfs, es_visitor);
244 assert(es_visitor._entity_set);
245 auto& es = *es_visitor._entity_set;
246 bool blocked = gfs.backend().blocked(gfs);
247 // build local ordering tree
248 auto local_ordering = std::make_shared<LocalOrdering>(LocalOrderingTransformation::transform(gfs,gfs_to_local_ordering<Transformation>()));
249 // create grid view ordering
250 transformed_type r(make_tuple(std::move(local_ordering)),blocked,const_cast<GFS*>(&gfs),es);
251 return r;
252 }
253
254 static transformed_storage_type transform_storage(std::shared_ptr<const GFS> gfs, const Transformation& t)
255 {
256 // check and extract common entity set on leaf nodes
257 auto es_visitor = impl::common_entity_set<EntitySet>{};
258 TypeTree::applyToTree(*gfs, es_visitor);
259 assert(es_visitor._entity_set);
260 auto& es = *es_visitor._entity_set;
261 bool blocked = gfs->backend().blocked(*gfs);
262 // build local ordering tree
263 auto local_ordering = make_tuple(LocalOrderingTransformation::transform_storage(gfs,gfs_to_local_ordering<Transformation>()));
264 // create grid view ordering
265 transformed_storage_type r(std::make_shared<transformed_type>(std::move(local_ordering),blocked,const_cast<GFS*>(gfs.get()),es));
266 return r;
267 }
268
269 };
270
271 template<typename GFS, typename Transformation>
272 composite_gfs_to_entityblocked_ordering_descriptor<GFS,Transformation>
273 register_composite_gfs_to_ordering_descriptor(GFS*,Transformation*,EntityBlockedOrderingTag*);
274
275
277 } // namespace PDELab
278} // namespace Dune
279
280#endif // DUNE_PDELAB_ORDERING_ENTITYBLOCKEDLOCALORDERING_HH
Traits::SizeType node_size(const Node &node, typename Traits::ContainerIndex suffix, const typename Traits::DOFIndex::EntityIndex &index) const
Gives the size for a given entity and suffix.
Definition: localorderingbase.hh:287
std::array< std::shared_ptr< ChildOrdering >, k > NodeStorage
The type used for storing the children.
Definition: powernode.hh:78
A free function to provide the demangled class name of a given object or type as a string.
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.
void applyToTree(Tree &&tree, Visitor &&visitor)
Apply visitor to TypeTree.
Definition: traversal.hh:237
Dune namespace.
Definition: alignedallocator.hh:11
Standard Dune debug streams.
static transformed_type transform(const SourceTree &s, const Transformation &t=Transformation())
Apply transformation to an existing tree s.
Definition: transformation.hh:114
static transformed_storage_type transform_storage(std::shared_ptr< const SourceTree > sp, const Transformation &t=Transformation())
Definition: transformation.hh:139
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 22, 23:30, 2024)