4#ifndef DUNE_PDELAB_ORDERING_ENTITYBLOCKEDLOCALORDERING_HH
5#define DUNE_PDELAB_ORDERING_ENTITYBLOCKEDLOCALORDERING_HH
16#include <dune/common/hybridutilities.hh>
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>
24#include <dune/pdelab/ordering/gridviewordering.hh>
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>
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;
47 static const bool consume_tree_index =
true;
49 typedef typename BaseT::Traits Traits;
51 PowerEntityBlockedLocalOrdering(
const typename NodeT::NodeStorage& child_storage,
bool container_blocked)
52 : NodeT(child_storage)
53 , BaseT(*this,container_blocked,nullptr)
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);
72 template<
typename GFS,
typename Transformation>
73 struct power_gfs_to_local_ordering_descriptor<GFS,Transformation,EntityBlockedOrderingTag>
76 static const bool recursive =
true;
81 typedef PowerEntityBlockedLocalOrdering<TC,TypeTree::StaticDegree<GFS>::value> type;
82 typedef std::shared_ptr<type> storage_type;
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)
88 return typename result<TC>::type(children,gfs.backend().blocked(gfs));
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)
94 return std::make_shared<typename result<TC>::type>(children,gfs->backend().blocked(*gfs));
101 template<
typename GFS,
typename Transformation>
102 struct power_gfs_to_entityblocked_ordering_descriptor
105 static const bool recursive =
false;
107 typedef TypeTree::TransformTree<GFS,gfs_to_local_ordering<Transformation> > LocalOrderingTransformation;
108 typedef typename LocalOrderingTransformation::Type LocalOrdering;
110 typedef GridViewOrdering<LocalOrdering> transformed_type;
112 typedef std::shared_ptr<transformed_type> transformed_storage_type;
114 using EntitySet =
typename GFS::Traits::EntitySet;
116 static transformed_type transform(
const GFS& gfs,
const Transformation& t)
119 auto es_visitor = impl::common_entity_set<EntitySet>{};
121 assert(es_visitor._entity_set);
122 auto& es = *es_visitor._entity_set;
125 bool blocked = gfs.backend().blocked(gfs);
127 transformed_type r(make_tuple(std::move(local_ordering)),blocked,
const_cast<GFS*
>(&gfs),es);
131 static transformed_storage_type transform_storage(std::shared_ptr<const GFS> gfs,
const Transformation& t)
134 auto es_visitor = impl::common_entity_set<EntitySet>{};
136 assert(es_visitor._entity_set);
137 auto& es = *es_visitor._entity_set;
140 bool blocked = gfs->backend().blocked(*gfs);
142 transformed_storage_type r(std::make_shared<transformed_type>(make_tuple(std::move(local_ordering)),blocked,
const_cast<GFS*
>(gfs.get()),es));
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*);
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>
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;
169 typedef typename Base::Traits Traits;
171 static const bool consume_tree_index =
true;
173 CompositeEntityBlockedLocalOrdering(
bool container_blocked, std::shared_ptr<Children>... children)
175 , Base(*this,container_blocked,nullptr)
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);
198 template<
typename GFS,
typename Transformation>
199 struct composite_gfs_to_local_ordering_descriptor<GFS,Transformation,EntityBlockedOrderingTag>
202 static const bool recursive =
true;
204 template<
typename... TC>
207 typedef CompositeEntityBlockedLocalOrdering<TC...> type;
208 typedef std::shared_ptr<type> storage_type;
211 template<
typename... TC>
212 static typename result<TC...>::type transform(
const GFS& gfs,
const Transformation& t, std::shared_ptr<TC>... children)
214 return typename result<TC...>::type(gfs.backend().blocked(gfs),children...);
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)
220 return std::make_shared<
typename result<TC...>::type>(gfs->backend().blocked(*gfs),children...);
225 template<
typename GFS,
typename Transformation>
226 struct composite_gfs_to_entityblocked_ordering_descriptor
228 static const bool recursive =
false;
230 typedef TypeTree::TransformTree<GFS,gfs_to_local_ordering<Transformation> > LocalOrderingTransformation;
231 typedef typename LocalOrderingTransformation::Type LocalOrdering;
233 typedef GridViewOrdering<LocalOrdering> transformed_type;
235 typedef std::shared_ptr<transformed_type> transformed_storage_type;
237 using EntitySet =
typename GFS::Traits::EntitySet;
239 static transformed_type transform(
const GFS& gfs,
const Transformation& t)
242 auto es_visitor = impl::common_entity_set<EntitySet>{};
244 assert(es_visitor._entity_set);
245 auto& es = *es_visitor._entity_set;
246 bool blocked = gfs.backend().blocked(gfs);
250 transformed_type r(make_tuple(std::move(local_ordering)),blocked,
const_cast<GFS*
>(&gfs),es);
254 static transformed_storage_type transform_storage(std::shared_ptr<const GFS> gfs,
const Transformation& t)
257 auto es_visitor = impl::common_entity_set<EntitySet>{};
259 assert(es_visitor._entity_set);
260 auto& es = *es_visitor._entity_set;
261 bool blocked = gfs->backend().blocked(*gfs);
265 transformed_storage_type r(std::make_shared<transformed_type>(std::move(local_ordering),blocked,
const_cast<GFS*
>(gfs.get()),es));
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*);
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.