4#ifndef DUNE_PDELAB_ORDERING_LEXICOGRAPHICORDERING_HH
5#define DUNE_PDELAB_ORDERING_LEXICOGRAPHICORDERING_HH
15#include <dune/typetree/compositenode.hh>
16#include <dune/typetree/powernode.hh>
17#include <dune/typetree/traversal.hh>
18#include <dune/typetree/visitor.hh>
20#include <dune/pdelab/gridfunctionspace/tags.hh>
21#include <dune/pdelab/ordering/utility.hh>
22#include <dune/pdelab/ordering/orderingbase.hh>
30 namespace lexicographic_ordering {
32 template<
typename DI,
typename CI,
typename Node>
34 :
public OrderingBase<DI,CI>
37 typedef OrderingBase<DI,CI> BaseT;
41 typedef typename OrderingBase<DI,CI>::Traits Traits;
43 typedef LexicographicOrderingTag OrderingTag;
45 static const bool consume_tree_index =
true;
53 Base(Node& node,
bool container_blocked,
typename BaseT::GFSData* gfs_data)
54 : BaseT(node,container_blocked,gfs_data,nullptr)
58 template<
typename ItIn,
typename ItOut>
59 void map_lfs_indices(
const ItIn begin,
const ItIn end, ItOut out)
const
61 if (this->_container_blocked)
63 for (ItIn in = begin; in != end; ++in, ++out)
64 out->push_back(in->treeIndex().back());
68 for (ItIn in = begin; in != end; ++in, ++out)
69 out->back() += (this->blockOffset(in->treeIndex().back()));
73 template<
typename CIOutIterator,
typename DIOutIterator = DummyDOFIndexIterator>
74 typename Traits::SizeType
75 extract_entity_indices(
const typename Traits::DOFIndex::EntityIndex& ei,
76 typename Traits::SizeType child_index,
77 CIOutIterator ci_out,
const CIOutIterator ci_end)
const
79 if (this->_container_blocked)
81 for (; ci_out != ci_end; ++ci_out)
83 ci_out->push_back(child_index);
88 for (; ci_out != ci_end; ++ci_out)
90 ci_out->back() += (this->blockOffset(child_index));
103 template<
typename DI,
typename CI,
typename Child, std::
size_t k>
104 class PowerLexicographicOrdering
105 :
public TypeTree::PowerNode<Child, k>
106 ,
public lexicographic_ordering::Base<DI,
108 PowerLexicographicOrdering<DI,CI,Child,k>
111 typedef TypeTree::PowerNode<Child, k> Node;
113 typedef lexicographic_ordering::Base<DI,
115 PowerLexicographicOrdering<DI,CI,Child,k>
129 PowerLexicographicOrdering(
bool container_blocked,
const typename Node::NodeStorage& children,
typename Base::GFSData* gfs_data)
131 , Base(*this,container_blocked,gfs_data)
136 for (std::size_t i = 0; i < k; ++i)
138 this->
child(i).update();
143 std::string name()
const {
return "PowerLexicographicOrdering"; }
147 template<
typename GFS,
typename Transformation>
148 struct power_gfs_to_lexicographic_ordering_descriptor
151 static const bool recursive =
true;
153 template<
typename TC>
157 typedef PowerLexicographicOrdering<
158 typename Transformation::DOFIndex,
159 typename Transformation::ContainerIndex,
161 TypeTree::StaticDegree<GFS>::value
164 typedef std::shared_ptr<type> storage_type;
168 template<
typename TC>
169 static typename result<TC>::type transform(
const GFS& gfs,
const Transformation& t,
const std::array<std::shared_ptr<TC>,TypeTree::StaticDegree<GFS>::value>& children)
171 return typename result<TC>::type(gfs.backend().blocked(gfs),children,
const_cast<GFS*
>(&gfs));
174 template<
typename TC>
175 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)
177 return std::make_shared<typename result<TC>::type>(gfs->backend().blocked(*gfs),children,
const_cast<GFS*
>(gfs.get()));
182 template<
typename GFS,
typename Transformation>
183 power_gfs_to_lexicographic_ordering_descriptor<GFS,Transformation>
184 register_power_gfs_to_ordering_descriptor(GFS*,Transformation*,LexicographicOrderingTag*);
190 template<
typename DI,
typename CI,
typename... Children>
193 public lexicographic_ordering::Base<DI,
195 CompositeLexicographicOrdering<
204 typedef lexicographic_ordering::Base<
226 , Base(*this,backend_blocked,gfs_data)
229 std::string name()
const {
return "CompositeLexicographicOrdering"; }
238 template<
typename GFS,
typename Transformation>
239 struct composite_gfs_to_lexicographic_ordering_descriptor
242 static const bool recursive =
true;
244 template<
typename... TC>
248 typedef CompositeLexicographicOrdering<
249 typename Transformation::DOFIndex,
250 typename Transformation::ContainerIndex,
254 typedef std::shared_ptr<type> storage_type;
258 template<
typename... TC>
259 static typename result<TC...>::type transform(
const GFS& gfs,
const Transformation& t, std::shared_ptr<TC>... children)
261 return typename result<TC...>::type(gfs.backend().blocked(gfs),
const_cast<GFS*
>(&gfs),children...);
264 template<
typename... TC>
265 static typename result<TC...>::storage_type transform_storage(std::shared_ptr<const GFS> gfs,
const Transformation& t, std::shared_ptr<TC>... children)
267 return std::make_shared<
typename result<TC...>::type>(gfs->backend().blocked(*gfs),
const_cast<GFS*
>(gfs.get()),children...);
273 template<
typename GFS,
typename Transformation>
274 composite_gfs_to_lexicographic_ordering_descriptor<GFS,Transformation>
275 register_composite_gfs_to_ordering_descriptor(GFS*,Transformation*,LexicographicOrderingTag*);
Interface for merging index spaces.
Definition: lexicographicordering.hh:201
CompositeLexicographicOrdering(bool backend_blocked, typename Base::GFSData *gfs_data, std::shared_ptr< Children >... children)
Construct ordering object.
Definition: lexicographicordering.hh:224
Base class for composite nodes based on variadic templates.
Definition: compositenode.hh:25
std::array< ChildStorageType, k > NodeStorage
The type used for storing the children.
Definition: powernode.hh:84
A free function to provide the demangled class name of a given object or type as a string.
A few common exception classes.
void applyToTree(Tree &&tree, Visitor &&visitor)
Apply visitor to TypeTree.
Definition: traversal.hh:213
Dune namespace.
Definition: alignedallocator.hh:14
Standard Dune debug streams.