4#ifndef DUNE_PDELAB_ORDERING_CHUNKEDBLOCKORDERING_HH
5#define DUNE_PDELAB_ORDERING_CHUNKEDBLOCKORDERING_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 tag_base(std::size_t block_size)
26 : _block_size(block_size)
29 std::size_t blockSize()
const
36 const std::size_t _block_size;
40 template<std::
size_t i>
45 base_holder(std::size_t block_size)
46 : tag_base(block_size)
65 template<
typename OrderingTag>
67 :
public chunked::base_holder<decorated_ordering_tag<Chunked<OrderingTag>,OrderingTag>::level>
68 ,
public decorated_ordering_tag<Chunked<OrderingTag>,OrderingTag>
72 : chunked::base_holder<decorated_ordering_tag<Chunked<OrderingTag>,OrderingTag>::level>(block_size)
75 Chunked(std::size_t block_size,
const OrderingTag& tag)
76 : chunked::base_holder<decorated_ordering_tag<Chunked<OrderingTag>,OrderingTag>::level>(block_size)
80 Chunked(std::size_t block_size, OrderingTag&& tag)
81 : chunked::base_holder<decorated_ordering_tag<Chunked<OrderingTag>,OrderingTag>::level>(block_size)
85 template<std::
size_t i>
86 const chunked::base_holder<i>& chunked()
const
91 template<std::
size_t i>
92 chunked::base_holder<i>& chunked()
99 template<
typename Decorated>
111 template<
typename Ordering>
114 ,
public VirtualOrderingBase<typename Ordering::Traits::DOFIndex,
115 typename Ordering::Traits::ContainerIndex>
116 ,
public OrderingBase<typename Ordering::Traits::DOFIndex,
117 typename Ordering::Traits::ContainerIndex>
120 typedef typename Ordering::Traits Traits;
122 static const bool consume_tree_index =
false;
128 typedef OrderingBase<
129 typename Ordering::Traits::DOFIndex,
130 typename Ordering::Traits::ContainerIndex
137 return this->
template child<0>();
140 const Ordering& ordering()
const
142 return this->
template child<0>();
148 , BaseT(*
this,
true,
nullptr,
this)
153 :
NodeT(r.nodeStorage())
157 this->setDelegate(
this);
161 :
NodeT(r.nodeStorage())
162 , BaseT(std::move(r))
165 this->setDelegate(
this);
170 virtual void map_index_dynamic(
typename Traits::DOFIndexView di,
typename Traits::ContainerIndex& ci)
const override
172 ordering().mapIndex(di,ci);
173 std::size_t flat_index = ci.back();
174 std::size_t block_index = flat_index / _tag.blockSize();
175 std::size_t inner_index = flat_index % _tag.blockSize();
176 ci.back() = inner_index;
177 ci.push_back(block_index);
180 template<
typename ItIn,
typename ItOut>
181 void map_lfs_indices(ItIn in,
const ItIn end, ItOut out)
const
183 for (; in != end; ++in, ++out)
185 std::size_t flat_index = out->back();
186 std::size_t block_index = flat_index / _tag.blockSize();
187 std::size_t inner_index = flat_index % _tag.blockSize();
188 out->back() = inner_index;
189 out->push_back(block_index);
193 template<
typename CIOutIterator>
194 typename Traits::SizeType
195 extract_entity_indices(
const typename Traits::DOFIndex::EntityIndex& ei,
196 typename Traits::SizeType child_index,
197 CIOutIterator ci_out,
const CIOutIterator ci_end)
const
199 for (; ci_out != ci_end; ++ci_out)
201 std::size_t flat_index = ci_out->back();
202 std::size_t block_index = flat_index / _tag.blockSize();
203 std::size_t inner_index = flat_index % _tag.blockSize();
204 ci_out->back() = inner_index;
205 ci_out->push_back(block_index);
214 if (ordering().blockCount() % _tag.blockSize() != 0)
216 "Block size of chunked block ordering does not divide the block count "
217 "of the underlying ordering: "
218 << ordering().blockCount()
223 this->_block_count = ordering().blockCount() / _tag.blockSize();
228 typename Traits::SizeType size(
typename Traits::ContainerIndex suffix)
const
230 if (suffix.size() == 0)
231 return this->_block_count;
232 if (suffix.size() == 1)
233 return _tag.blockSize();
235 auto block_index = suffix.back();
237 auto inner_index = suffix.back();
239 suffix.back() = _tag.blockSize() * block_index + inner_index;
240 return ordering().size(suffix);
245 const ordering::chunked::tag_base& _tag;
253 template<
typename GFS,
typename Transformation,
typename Undecorated,
typename Tag>
254 struct gfs_to_chunked
258 typedef std::shared_ptr<transformed_type> transformed_storage_type;
260 static transformed_type transform(
const GFS& gfs,
const Transformation& t, std::shared_ptr<Undecorated> undecorated)
262 return transformed_type(make_tuple(undecorated),gfs.orderingTag().template chunked<Tag::level>());
265 static transformed_storage_type transform_storage(std::shared_ptr<const GFS> gfs_pointer,
const Transformation& t, std::shared_ptr<Undecorated> undecorated)
267 return std::make_shared<transformed_type>(make_tuple(undecorated),gfs_pointer->orderingTag().template chunked<Tag::level>());
272 template<
typename GFS,
typename Transformation,
typename Undecorated,
typename GlueTag,
typename UndecoratedTag>
273 gfs_to_chunked<GFS,Transformation,Undecorated,GlueTag>
274 register_gfs_to_decorator_descriptor(GFS*,Transformation*,Undecorated*,GlueTag*,Chunked<UndecoratedTag>*);
280 template<
typename GFS,
typename Transformation,
typename U>
281 struct power_gfs_to_local_ordering_descriptor<GFS,Transformation,ordering::Chunked<U> >
282 :
public power_gfs_to_local_ordering_descriptor<GFS,Transformation,U>
286 template<
typename GFS,
typename Transformation,
typename U>
287 struct composite_gfs_to_local_ordering_descriptor<GFS,Transformation,ordering::Chunked<U> >
288 :
public composite_gfs_to_local_ordering_descriptor<GFS,Transformation,U>
The block size of a ChunkedBlockOrdering does not divide the block count of the underlying ordering.
Definition: exceptions.hh:56
Ordering that permutes top-level ContainerIndex entries.
Definition: chunkedblockordering.hh:118
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
Definition: chunkedblockordering.hh:69