4#ifndef DUNE_PDELAB_ORDERING_DECORATOR_HH
5#define DUNE_PDELAB_ORDERING_DECORATOR_HH
9#include <dune/typetree/typetree.hh>
11#include <dune/pdelab/common/typetraits.hh>
12#include <dune/pdelab/ordering/utility.hh>
13#include <dune/pdelab/ordering/orderingbase.hh>
26 template<
typename D,
typename U>
27 struct decorated_ordering_tag;
34 template<
typename DecoratedOrderingTag, std::
size_t level>
35 struct basetag_access_provider
40 template<
typename D,
typename U>
41 struct basetag_access_provider<decorated_ordering_tag<D,U>,0>
46 const BaseTag& baseTag()
const
48 return static_cast<decorated_ordering_tag<D,U>&
>(*this);
53 return static_cast<decorated_ordering_tag<D,U>&
>(*this);
58 template<
typename T, T v>
61 typedef std::integral_constant<T,v> type;
67 typedef std::integral_constant<std::size_t,D::level> type;
71 struct decoration_level
72 :
public std::conditional<
73 std::is_base_of<is_decorated, D>::value,
75 lazy_constant<std::size_t,0>
83 template<
typename D,
typename U>
84 struct decorated_ordering_tag
86 , impl::basetag_access_provider<decorated_ordering_tag<D,U>,impl::decoration_level<U>::value>
90 typedef U Undecorated;
92 static const std::size_t level = impl::decoration_level<U>::value + 1;
94 decorated_ordering_tag()
97 decorated_ordering_tag(
const Undecorated& u)
101 decorated_ordering_tag(Undecorated&& u)
102 : Undecorated(
std::move(u))
113 template<
typename Ordering>
114 const Ordering& _unwind_decorators(
const Ordering& ordering, std::integral_constant<std::size_t,0>)
121 template<
typename Ordering, std::
size_t level>
122 auto _unwind_decorators(
const Ordering& ordering, std::integral_constant<std::size_t,level>)
125 ordering.template child<0>(),
126 std::integral_constant<std::size_t,level-1>()
130 return _unwind_decorators(
131 ordering.template child<0>(),
132 std::integral_constant<std::size_t,level-1>()
143 template<
typename GFS>
144 auto undecorated_ordering(
const GFS& gfs)
148 impl::decoration_level<typename GFS::OrderingTag>()
152 return _unwind_decorators(
154 impl::decoration_level<typename GFS::OrderingTag>()
159 template<
typename GFS,
typename Transformation,
typename Undecorated,
typename GlueTag,
typename Tag>
160 struct gfs_to_decorator_descriptor
161 :
public TypeTree::meta_function
164 register_gfs_to_decorator_descriptor(
165 TypeTree::declptr<GFS>(),
166 TypeTree::declptr<Transformation>(),
167 TypeTree::declptr<Undecorated>(),
168 TypeTree::declptr<GlueTag>(),
169 TypeTree::declptr<Tag>()
175 template<
typename GFS,
typename Transformation,
typename OrderingTag>
176 struct leaf_gfs_to_decorated
179 static const bool recursive =
false;
181 typedef typename leaf_gfs_to_ordering_descriptor<
184 typename OrderingTag::Undecorated
185 >::type undecorated_descriptor;
187 typedef typename undecorated_descriptor::transformed_type undecorated_type;
189 typedef typename gfs_to_decorator_descriptor<
194 typename OrderingTag::Decorator
195 >::type decorator_descriptor;
197 typedef typename decorator_descriptor::transformed_type transformed_type;
198 typedef typename decorator_descriptor::transformed_storage_type transformed_storage_type;
200 static transformed_type transform(
const GFS& gfs,
const Transformation& t)
202 return decorator_descriptor::transform(gfs,t,std::make_shared<undecorated_type>(undecorated_descriptor::transform(gfs,t)));
205 static transformed_storage_type transform(std::shared_ptr<const GFS>& gfs_pointer,
const Transformation& t)
207 return decorator_descriptor::transform(gfs_pointer,t,undecorated_descriptor::transform(gfs_pointer,t));
212 template<
typename GFS,
typename Transformation,
typename D,
typename U>
213 leaf_gfs_to_decorated<GFS,Transformation,decorated_ordering_tag<D,U> >
214 register_leaf_gfs_to_ordering_descriptor(GFS*,Transformation*,decorated_ordering_tag<D,U>*);
217 template<
typename GFS,
typename Transformation,
typename OrderingTag>
218 struct recursive_power_gfs_to_decorated
221 static const bool recursive =
true;
223 template<
typename TC>
227 typedef typename power_gfs_to_ordering_descriptor<
230 typename OrderingTag::Undecorated
231 >::type undecorated_descriptor;
233 typedef typename undecorated_descriptor::template result<TC>::type undecorated_type;
234 typedef typename gfs_to_decorator_descriptor<
239 typename OrderingTag::Decorator
240 >::type decorator_descriptor;
242 typedef typename decorator_descriptor::transformed_type type;
243 typedef typename decorator_descriptor::transformed_storage_type storage_type;
247 template<
typename TC>
248 static typename result<TC>::type transform(
const GFS& gfs,
const Transformation& t,
const std::array<std::shared_ptr<TC>,TypeTree::StaticDegree<GFS>::value>& children)
250 return result<TC>::decorator_descriptor::transform(gfs,t,std::make_shared<
typename result<TC>::undecorated_type>(result<TC>::undecorated_descriptor::transform(gfs,t,children)));
253 template<
typename TC>
254 static typename result<TC>::storage_type transform_storage(std::shared_ptr<const GFS> gfs_pointer,
const Transformation& t,
const std::array<std::shared_ptr<TC>,TypeTree::StaticDegree<GFS>::value>& children)
256 return result<TC>::decorator_descriptor::transform(gfs_pointer,t,result<TC>::undecorated_descriptor::transform_storage(gfs_pointer,t,children));
262 template<
typename GFS,
typename Transformation,
typename OrderingTag>
263 struct nonrecursive_power_gfs_to_decorated
266 static const bool recursive =
false;
268 typedef typename power_gfs_to_ordering_descriptor<
271 typename OrderingTag::Undecorated
272 >::type undecorated_descriptor;
274 typedef typename undecorated_descriptor::transformed_type undecorated_type;
276 typedef typename gfs_to_decorator_descriptor<
281 typename OrderingTag::Decorator
282 >::type decorator_descriptor;
284 typedef typename decorator_descriptor::transformed_type transformed_type;
285 typedef typename decorator_descriptor::transformed_storage_type transformed_storage_type;
287 static transformed_type transform(
const GFS& gfs,
const Transformation& t)
289 return decorator_descriptor::transform(gfs,t,std::make_shared<undecorated_type>(undecorated_descriptor::transform(gfs,t)));
292 static transformed_storage_type transform_storage(std::shared_ptr<const GFS>& gfs_pointer,
const Transformation& t)
294 return decorator_descriptor::transform_storage(gfs_pointer,t,undecorated_descriptor::transform_storage(gfs_pointer,t));
300 template<
typename GFS,
typename Transformation,
typename OrderingTag>
301 struct power_gfs_to_decorated
302 :
public std::conditional<
303 power_gfs_to_ordering_descriptor<
306 typename OrderingTag::Undecorated
308 recursive_power_gfs_to_decorated<
313 nonrecursive_power_gfs_to_decorated<
320 template<
typename GFS,
typename Transformation,
typename D,
typename U>
321 power_gfs_to_decorated<
324 decorated_ordering_tag<D,U>
326 register_power_gfs_to_ordering_descriptor(GFS*,Transformation*,decorated_ordering_tag<D,U>*);
333 template<
typename GFS,
typename Transformation,
typename OrderingTag>
334 struct recursive_composite_gfs_to_decorated
337 static const bool recursive =
true;
339 template<
typename... TC>
343 typedef typename composite_gfs_to_ordering_descriptor<
346 typename OrderingTag::Undecorated
347 >::type undecorated_descriptor;
349 typedef typename undecorated_descriptor::template result<TC...>::type undecorated_type;
350 typedef typename gfs_to_decorator_descriptor<
355 typename OrderingTag::Decorator
356 >::type decorator_descriptor;
358 typedef typename decorator_descriptor::transformed_type type;
359 typedef typename decorator_descriptor::transformed_storage_type storage_type;
363 template<
typename... TC>
364 static typename result<TC...>::type transform(
const GFS& gfs,
const Transformation& t, std::shared_ptr<TC>... children)
366 return result<TC...>::decorator_descriptor::transform(gfs,t,std::make_shared<
typename result<TC...>::undecorated_type>(result<TC...>::undecorated_descriptor::transform(gfs,t,children...)));
369 template<
typename... TC>
370 static typename result<TC...>::storage_type transform_storage(std::shared_ptr<const GFS> gfs_pointer,
const Transformation& t, std::shared_ptr<TC>... children)
372 return result<TC...>::decorator_descriptor::transform_storage(gfs_pointer,t,result<TC...>::undecorated_descriptor::transform(gfs_pointer,t,children...));
378 template<
typename GFS,
typename Transformation,
typename OrderingTag>
379 struct nonrecursive_composite_gfs_to_decorated
382 static const bool recursive =
false;
384 typedef typename composite_gfs_to_ordering_descriptor<
387 typename OrderingTag::Undecorated
388 >::type undecorated_descriptor;
390 typedef typename undecorated_descriptor::transformed_type undecorated_type;
392 typedef typename gfs_to_decorator_descriptor<
397 typename OrderingTag::Decorator
398 >::type decorator_descriptor;
400 typedef typename decorator_descriptor::transformed_type transformed_type;
401 typedef typename decorator_descriptor::transformed_storage_type transformed_storage_type;
403 static transformed_type transform(
const GFS& gfs,
const Transformation& t)
405 return decorator_descriptor::transform(gfs,t,std::make_shared<undecorated_type>(undecorated_descriptor::transform(gfs,t)));
408 static transformed_storage_type transform_storage(std::shared_ptr<const GFS>& gfs_pointer,
const Transformation& t)
410 return decorator_descriptor::transform_storage(gfs_pointer,t,undecorated_descriptor::transform(gfs_pointer,t));
416 template<
typename GFS,
typename Transformation,
typename OrderingTag>
417 struct composite_gfs_to_decorated
418 :
public std::conditional<
419 composite_gfs_to_ordering_descriptor<
422 typename OrderingTag::Undecorated
424 recursive_composite_gfs_to_decorated<
429 nonrecursive_composite_gfs_to_decorated<
437 template<
typename GFS,
typename Transformation,
typename D,
typename U>
438 composite_gfs_to_decorated<GFS,Transformation,decorated_ordering_tag<D,U> >
439 register_composite_gfs_to_ordering_descriptor(GFS*,Transformation*,decorated_ordering_tag<D,U>*);
Dune namespace.
Definition: alignedallocator.hh:13