4#ifndef DUNE_PDELAB_ORDERING_LEXICOGRAPHICORDERING_HH
5#define DUNE_PDELAB_ORDERING_LEXICOGRAPHICORDERING_HH
11#include <dune/common/classname.hh>
12#include <dune/common/exceptions.hh>
13#include <dune/common/stdstreams.hh>
14#include <dune/common/hybridutilities.hh>
16#include <dune/typetree/compositenode.hh>
17#include <dune/typetree/powernode.hh>
18#include <dune/typetree/traversal.hh>
19#include <dune/typetree/visitor.hh>
31 namespace lexicographic_ordering {
33 template<
typename DI,
typename CI,
typename Node>
55 :
BaseT(node,container_blocked,gfs_data,nullptr)
59 template<
typename ItIn,
typename ItOut>
64 for (ItIn in = begin; in != end; ++in, ++out)
65 out->push_back(in->treeIndex().back());
69 for (ItIn in = begin; in != end; ++in, ++out)
70 out->back() += (this->
blockOffset(in->treeIndex().back()));
74 template<
typename CIOutIterator,
typename DIOutIterator = DummyDOFIndexIterator>
78 CIOutIterator ci_out,
const CIOutIterator ci_end)
const
82 for (; ci_out != ci_end; ++ci_out)
84 ci_out->push_back(child_index);
89 for (; ci_out != ci_end; ++ci_out)
104 template<
typename DI,
typename CI,
typename Child, std::
size_t k>
106 :
public TypeTree::PowerNode<Child, k>
109 PowerLexicographicOrdering<DI,CI,Child,k>
112 typedef TypeTree::PowerNode<Child, k> Node;
134 ,
Base(*this,container_blocked,gfs_data)
139 for (std::size_t i = 0; i < k; ++i)
141 this->child(i).update();
146 std::string
name()
const {
return "PowerLexicographicOrdering"; }
155 typename Traits::SizeType
size(
typename Traits::ContainerIndex suffix)
const {
156 if (suffix.size() == Traits::ContainerIndex::max_depth)
159 if (suffix.size() == 0)
163 auto child = suffix.back();
164 assert(this->degree() > child);
166 return this->child(child).size(suffix);
168 auto it = std::upper_bound(this->
_child_block_offsets.begin(), this->_child_block_offsets.end(), suffix.back());
169 std::size_t child = *std::prev(it);
170 return this->child(child).size(suffix);
177 template<
typename GFS,
typename Transformation>
183 template<
typename TC>
188 typename Transformation::DOFIndex,
189 typename Transformation::ContainerIndex,
191 TypeTree::StaticDegree<GFS>::value
198 template<
typename TC>
199 static typename result<TC>::type transform(
const GFS& gfs,
const Transformation& t,
const std::array<std::shared_ptr<TC>,TypeTree::StaticDegree<GFS>::value>& children)
201 return typename result<TC>::type(gfs.backend().blocked(gfs),children,
const_cast<GFS*
>(&gfs));
204 template<
typename TC>
207 return std::make_shared<typename result<TC>::type>(gfs->backend().blocked(*gfs),children,
const_cast<GFS*
>(gfs.get()));
212 template<
typename GFS,
typename Transformation>
213 power_gfs_to_lexicographic_ordering_descriptor<GFS,Transformation>
220 template<
typename DI,
typename CI,
typename... Children>
222 public TypeTree::CompositeNode<Children...>,
225 CompositeLexicographicOrdering<
232 typedef TypeTree::CompositeNode<Children...> Node;
258 ,
Base(*this,backend_blocked,gfs_data)
261 std::string
name()
const {
return "CompositeLexicographicOrdering"; }
265 TypeTree::applyToTree(*
this,ordering::update_direct_children());
276 typename Traits::SizeType
size(
typename Traits::ContainerIndex suffix)
const {
277 if (suffix.size() == Traits::ContainerIndex::max_depth)
280 if (suffix.size() == 0)
283 auto indices = std::make_index_sequence<Node::degree()>{};
284 typename Traits::SizeType
_size;
288 _child = suffix.back();
289 assert(this->degree() > _child);
292 auto it = std::upper_bound(this->
_child_block_offsets.begin(), this->_child_block_offsets.end(), suffix.back());
293 _child = *std::prev(it);
296 Hybrid::forEach(indices, [&](
auto i){
298 _size = this->
template child<i>().
size(suffix);
304 template<
typename GFS,
typename Transformation>
310 template<
typename... TC>
315 typename Transformation::DOFIndex,
316 typename Transformation::ContainerIndex,
324 template<
typename... TC>
325 static typename result<TC...>::type
transform(
const GFS& gfs,
const Transformation& t, std::shared_ptr<TC>... children)
327 return typename result<TC...>::type(gfs.backend().blocked(gfs),
const_cast<GFS*
>(&gfs),children...);
330 template<
typename... TC>
331 static typename result<TC...>::storage_type
transform_storage(std::shared_ptr<const GFS> gfs,
const Transformation& t, std::shared_ptr<TC>... children)
333 return std::make_shared<
typename result<TC...>::type>(gfs->backend().blocked(*gfs),
const_cast<GFS*
>(gfs.get()),children...);
339 template<
typename GFS,
typename Transformation>
340 composite_gfs_to_lexicographic_ordering_descriptor<GFS,Transformation>
composite_gfs_to_entityblocked_ordering_descriptor< GFS, Transformation > register_composite_gfs_to_ordering_descriptor(GFS *, Transformation *, EntityBlockedOrderingTag *)
power_gfs_to_entityblocked_ordering_descriptor< GFS, Transformation > register_power_gfs_to_ordering_descriptor(GFS *, Transformation *, EntityBlockedOrderingTag *)
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
Indicate lexicographic ordering of the unknowns of non-leaf grid function spaces.
Definition: gridfunctionspace/tags.hh:63
Definition: lexicographicordering.hh:36
Traits::SizeType extract_entity_indices(const typename Traits::DOFIndex::EntityIndex &ei, typename Traits::SizeType child_index, CIOutIterator ci_out, const CIOutIterator ci_end) const
Definition: lexicographicordering.hh:76
LexicographicOrderingTag OrderingTag
Definition: lexicographicordering.hh:44
OrderingBase< DI, CI >::Traits Traits
Definition: lexicographicordering.hh:42
static const bool consume_tree_index
Definition: lexicographicordering.hh:46
Base(Node &node, bool container_blocked, typename BaseT::GFSData *gfs_data)
Construct ordering object.
Definition: lexicographicordering.hh:54
void map_lfs_indices(const ItIn begin, const ItIn end, ItOut out) const
Definition: lexicographicordering.hh:60
Definition: lexicographicordering.hh:111
void update()
Definition: lexicographicordering.hh:137
Traits::SizeType size(typename Traits::ContainerIndex suffix) const
Gives the size for a given suffix.
Definition: lexicographicordering.hh:155
typename Base::Traits Traits
Definition: lexicographicordering.hh:121
PowerLexicographicOrdering(bool container_blocked, const typename Node::NodeStorage &children, typename Base::GFSData *gfs_data)
Construct ordering object.
Definition: lexicographicordering.hh:132
std::string name() const
Definition: lexicographicordering.hh:146
Definition: lexicographicordering.hh:179
static const bool recursive
Definition: lexicographicordering.hh:181
static 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)
Definition: lexicographicordering.hh:205
static result< TC >::type transform(const GFS &gfs, const Transformation &t, const std::array< std::shared_ptr< TC >, TypeTree::StaticDegree< GFS >::value > &children)
Definition: lexicographicordering.hh:199
Definition: lexicographicordering.hh:185
std::shared_ptr< type > storage_type
Definition: lexicographicordering.hh:194
PowerLexicographicOrdering< typename Transformation::DOFIndex, typename Transformation::ContainerIndex, TC, TypeTree::StaticDegree< GFS >::value > type
Definition: lexicographicordering.hh:192
Interface for merging index spaces.
Definition: lexicographicordering.hh:231
CompositeLexicographicOrdering(bool backend_blocked, typename Base::GFSData *gfs_data, std::shared_ptr< Children >... children)
Construct ordering object.
Definition: lexicographicordering.hh:256
Traits::SizeType size(typename Traits::ContainerIndex suffix) const
Gives the size for a given suffix.
Definition: lexicographicordering.hh:276
void update()
Definition: lexicographicordering.hh:263
std::string name() const
Definition: lexicographicordering.hh:261
typename Base::Traits Traits
Definition: lexicographicordering.hh:245
Definition: lexicographicordering.hh:306
static result< TC... >::storage_type transform_storage(std::shared_ptr< const GFS > gfs, const Transformation &t, std::shared_ptr< TC >... children)
Definition: lexicographicordering.hh:331
static result< TC... >::type transform(const GFS &gfs, const Transformation &t, std::shared_ptr< TC >... children)
Definition: lexicographicordering.hh:325
static const bool recursive
Definition: lexicographicordering.hh:308
Definition: lexicographicordering.hh:312
std::shared_ptr< type > storage_type
Definition: lexicographicordering.hh:320
CompositeLexicographicOrdering< typename Transformation::DOFIndex, typename Transformation::ContainerIndex, TC... > type
Definition: lexicographicordering.hh:318
Definition: orderingbase.hh:21
Dune::PDELab::impl::GridFunctionSpaceOrderingData< typename Traits::SizeType > GFSData
Definition: orderingbase.hh:32
Traits::SizeType blockOffset(const typename Traits::SizeType child_index) const
Definition: orderingbase.hh:81
bool containerBlocked() const
Definition: orderingbase.hh:184
std::size_t _size
Definition: orderingbase.hh:288
void update()
Definition: orderingbase.hh:97
Traits::SizeType blockCount() const
Definition: orderingbase.hh:66
Traits::SizeType size() const
Definition: orderingbase.hh:61
std::vector< typename Traits::SizeType > _child_block_offsets
Definition: orderingbase.hh:282
const bool _container_blocked
Definition: orderingbase.hh:275
Definition: ordering/utility.hh:205
DI::size_type SizeType
Definition: ordering/utility.hh:218