4#ifndef DUNE_PDELAB_ORDERING_PERMUTEDORDERING_HH
5#define DUNE_PDELAB_ORDERING_PERMUTEDORDERING_HH
7#include <dune/typetree/typetree.hh>
9#include <dune/pdelab/ordering/utility.hh>
10#include <dune/pdelab/ordering/orderingbase.hh>
11#include <dune/pdelab/ordering/decorator.hh>
25 std::vector<std::size_t>& permutation()
30 const std::vector<std::size_t>& permutation()
const
37 std::vector<std::size_t> _permutation;
41 template<std::
size_t i>
62 template<
typename OrderingTag>
64 :
public permuted::base_holder<decorated_ordering_tag<Permuted<OrderingTag>,OrderingTag>::level>
65 ,
public decorated_ordering_tag<Permuted<OrderingTag>,OrderingTag>
72 : decorated_ordering_tag<Permuted<OrderingTag>,OrderingTag>(tag)
76 : decorated_ordering_tag<Permuted<OrderingTag>,OrderingTag>(std::move(tag))
79 template<std::
size_t i>
80 const permuted::base_holder<i>& permuted()
const
85 template<std::
size_t i>
86 permuted::base_holder<i>& permuted()
99 template<
typename Ordering>
102 ,
public VirtualOrderingBase<typename Ordering::Traits::DOFIndex,
103 typename Ordering::Traits::ContainerIndex>
104 ,
public OrderingBase<typename Ordering::Traits::DOFIndex,
105 typename Ordering::Traits::ContainerIndex>
108 typedef typename Ordering::Traits Traits;
110 static const bool has_dynamic_ordering_children =
true;
112 static const bool consume_tree_index =
false;
118 typedef OrderingBase<
typename Ordering::Traits::DOFIndex,
119 typename Ordering::Traits::ContainerIndex> BaseT;
125 return this->
template child<0>();
128 const Ordering& ordering()
const
130 return this->
template child<0>();
136 , BaseT(*
this,
false,
nullptr,
this)
141 :
NodeT(r.nodeStorage())
145 this->setDelegate(
this);
149 :
NodeT(r.nodeStorage())
150 , BaseT(std::move(r))
153 this->setDelegate(
this);
160 typename Traits::SizeType size(
typename Traits::ContainerIndex suffix)
const {
161 if (suffix.size() == 0)
162 return ordering().size(suffix);
164 suffix.back() = _tag.permutation()[suffix.back()];
165 return ordering().size(suffix);
168 virtual void map_index_dynamic(
typename Traits::DOFIndexView di,
typename Traits::ContainerIndex& ci)
const override
170 ordering().mapIndex(di,ci);
171 ci.back() = _tag.permutation()[ci.back()];
174 template<
typename ItIn,
typename ItOut>
175 void map_lfs_indices(ItIn in,
const ItIn end, ItOut out)
const
177 for (; in != end; ++in, ++out)
179 out->back() = _tag.permutation()[out->back()];
183 template<
typename CIOutIterator>
184 typename Traits::SizeType
185 extract_entity_indices(
const typename Traits::DOFIndex::EntityIndex& ei,
186 typename Traits::SizeType child_index,
187 CIOutIterator ci_out,
const CIOutIterator ci_end)
const
189 for (; ci_out != ci_end; ++ci_out)
191 ci_out->back() = _tag.permutation()[ci_out->back()];
200 if (!_tag.permutation().empty() && _tag.permutation().size() != this->blockCount())
202 "Size of permutation array does not match block count of ordering: "
203 << _tag.permutation().size()
205 << this->blockCount()
209 auto& mutable_tag =
const_cast<ordering::permuted::tag_base&
>(_tag);
210 mutable_tag.permutation().resize(this->blockCount());
212 mutable_tag.permutation().begin(),
213 mutable_tag.permutation().end(),
221 const ordering::permuted::tag_base& _tag;
229 template<
typename GFS,
typename Transformation,
typename Undecorated,
typename Tag>
230 struct gfs_to_permuted
234 typedef std::shared_ptr<transformed_type> transformed_storage_type;
236 static transformed_type transform(
const GFS& gfs,
const Transformation& t, std::shared_ptr<Undecorated> undecorated)
238 return transformed_type(make_tuple(undecorated),gfs.orderingTag().template permuted<Tag::level>());
241 static transformed_storage_type transform_storage(std::shared_ptr<const GFS> gfs_pointer,
const Transformation& t, std::shared_ptr<Undecorated> undecorated)
243 return std::make_shared<transformed_type>(make_tuple(undecorated),gfs_pointer->orderingTag().template permuted<Tag::level>());
248 template<
typename GFS,
typename Transformation,
typename Undecorated,
typename GlueTag,
typename UndecoratedTag>
249 gfs_to_permuted<GFS,Transformation,Undecorated,GlueTag>
250 register_gfs_to_decorator_descriptor(GFS*,Transformation*,Undecorated*,GlueTag*,Permuted<UndecoratedTag>*);
256 template<
typename GFS,
typename Transformation,
typename U>
257 struct power_gfs_to_local_ordering_descriptor<GFS,Transformation,ordering::Permuted<U> >
258 :
public power_gfs_to_local_ordering_descriptor<GFS,Transformation,U>
262 template<
typename GFS,
typename Transformation,
typename U>
263 struct composite_gfs_to_local_ordering_descriptor<GFS,Transformation,ordering::Permuted<U> >
264 :
public composite_gfs_to_local_ordering_descriptor<GFS,Transformation,U>
A PermutedOrdering got a permutation vector of the wrong size.
Definition: exceptions.hh:51
Ordering that permutes top-level ContainerIndex entries.
Definition: permutedordering.hh:106
Base class for composite nodes based on variadic templates.
Definition: compositenode.hh:28
std::tuple< std::shared_ptr< Children >... > NodeStorage
The type used for storing the children.
Definition: compositenode.hh:36
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Dune namespace.
Definition: alignedallocator.hh:13
Permute the ordering created from the passed-in tag based on a simple lookup table.
Definition: permutedordering.hh:66