3 #ifndef DUNE_PDELAB_ORDERING_INTERLEAVEDORDERING_HH 4 #define DUNE_PDELAB_ORDERING_INTERLEAVEDORDERING_HH 8 #include <dune/typetree/compositenode.hh> 9 #include <dune/typetree/powernode.hh> 23 namespace interleaved_ordering {
26 template<
typename DI,
typename CI,
typename Node>
47 Base(Node& node,
bool container_blocked,
const OrderingTag& ordering_tag,
typename BaseT::GFSData* gfs_data)
48 : BaseT(node,container_blocked,ordering_tag.offsets(),gfs_data,nullptr)
53 if (node.CHILDREN != ordering_tag.
offsets().size() - 1)
55 "Invalid block structure for InterleavedOrdering: " 56 << node.CHILDREN <<
" children, but " 57 << (ordering_tag.
offsets().size() - 1) <<
" block sizes.");
60 template<
typename ItIn,
typename ItOut>
66 for (ItIn in = begin; in != end; ++in, ++out)
68 size_type child_index = in->treeIndex().back();
71 size_type
index = out->back();
72 size_type block_index = index / child_block_size;
73 size_type
offset = index % child_block_size;
74 out->back() = child_block_offset +
offset;
75 out->push_back(block_index);
80 for (ItIn in = begin; in != end; ++in, ++out)
82 size_type child_index = in->treeIndex().back();
86 size_type
index = out->back();
87 size_type block_index = index / child_block_size;
88 size_type
offset = index % child_block_size;
89 out->back() = block_index * block_size + child_block_offset +
offset;
94 template<
typename CIOutIterator,
typename DIOutIterator = DummyDOFIndexIterator>
98 CIOutIterator ci_out,
const CIOutIterator ci_end)
const 103 for (; ci_out != ci_end; ++ci_out)
107 size_type
index = ci_out->back();
108 size_type block_index = index / child_block_size;
109 size_type
offset =index % child_block_size;
110 ci_out->back() = child_block_offset +
offset;
111 ci_out->push_back(block_index);
116 for (; ci_out != ci_end; ++ci_out)
121 size_type
index = ci_out->back();
122 size_type block_index = index / child_block_size;
123 size_type
offset =index % child_block_size;
124 ci_out->back() = block_index * block_size + child_block_offset +
offset;
137 template<
typename DI,
typename CI,
typename Child, std::
size_t k>
139 :
public TypeTree::PowerNode<Child, k>
142 PowerInterleavedOrdering<DI,CI,Child,k>
145 typedef TypeTree::PowerNode<Child, k> Node;
165 , Base(*this,container_blocked,ordering_tag,gfs_data)
170 for (std::size_t i = 0; i < k; ++i)
172 this->child(i).update();
177 std::string
name()
const {
return "PowerInterleavedOrdering"; }
181 template<
typename GFS,
typename Transformation>
185 static const bool recursive =
true;
187 template<
typename TC>
192 typename Transformation::DOFIndex,
193 typename Transformation::ContainerIndex,
202 template<
typename TC>
205 return typename result<TC>::type(gfs.backend().blocked(gfs),gfs.orderingTag(),children,
const_cast<GFS*
>(&gfs));
208 template<
typename TC>
211 return std::make_shared<typename result<TC>::type>(gfs->backend().blocked(*gfs),gfs->orderingTag(),children,
const_cast<GFS*
>(gfs.get()));
216 template<
typename GFS,
typename Transformation>
222 template<
typename DI,
typename CI,
typename... Children>
224 public TypeTree::CompositeNode<Children...>,
227 CompositeInterleavedOrdering<
234 typedef TypeTree::CompositeNode<Children...> Node;
258 ,
Base(*this,backend_blocked,ordering_tag,gfs_data)
261 std::string
name()
const {
return "CompositeInterleavedOrdering"; }
265 TypeTree::applyToTree(*
this,ordering::update_direct_children());
270 template<
typename GFS,
typename Transformation>
274 static const bool recursive =
true;
276 template<
typename... TC>
281 typename Transformation::DOFIndex,
282 typename Transformation::ContainerIndex,
290 template<
typename... TC>
291 static typename result<TC...>::type
transform(
const GFS& gfs,
const Transformation& t, std::shared_ptr<TC>... children)
293 return typename result<TC...>::type(gfs.backend().blocked(gfs),gfs.orderingTag(),
const_cast<GFS*
>(&gfs),children...);
296 template<
typename... TC>
297 static typename result<TC...>::storage_type
transform_storage(std::shared_ptr<const GFS> gfs,
const Transformation& t, std::shared_ptr<TC>... children)
299 return std::make_shared<
typename result<TC...>::type>(gfs->backend().blocked(*gfs),gfs.orderingTag(),
const_cast<GFS*
>(gfs.get()),children...);
304 template<
typename GFS,
typename Transformation>
312 #endif // DUNE_PDELAB_ORDERING_INTERLEAVEDORDERING_HH static result< TC... >::storage_type transform_storage(std::shared_ptr< const GFS > gfs, const Transformation &t, std::shared_ptr< TC >... children)
Definition: interleavedordering.hh:297
std::string name() const
Definition: interleavedordering.hh:177
PowerInterleavedOrdering< typename Transformation::DOFIndex, typename Transformation::ContainerIndex, TC, TypeTree::StaticDegree< GFS >::value > type
Definition: interleavedordering.hh:196
std::shared_ptr< type > storage_type
Definition: interleavedordering.hh:198
DI::size_type SizeType
Definition: ordering/utility.hh:201
void map_lfs_indices(const ItIn begin, const ItIn end, ItOut out) const
Definition: interleavedordering.hh:61
OrderingBase< DI, CI >::Traits Traits
Definition: interleavedordering.hh:35
std::shared_ptr< type > storage_type
Definition: interleavedordering.hh:286
void update()
Definition: interleavedordering.hh:263
Definition: interleavedordering.hh:223
InterleavedOrderingTag OrderingTag
Definition: interleavedordering.hh:37
Dune::PDELab::impl::GridFunctionSpaceOrderingData< typename Traits::SizeType > GFSData
Definition: orderingbase.hh:32
const std::size_t offset
Definition: localfunctionspace.hh:74
Definition: interleavedordering.hh:138
For backward compatibility – Do not use this!
Definition: adaptivity.hh:27
void update()
Definition: orderingbase.hh:97
Definition: orderingbase.hh:20
void update()
Definition: interleavedordering.hh:168
composite_gfs_to_entityblocked_ordering_descriptor< GFS, Transformation > register_composite_gfs_to_ordering_descriptor(GFS *, Transformation *, EntityBlockedOrderingTag *)
Error related to the logical structure of an Ordering.
Definition: exceptions.hh:44
const std::vector< std::size_t > & offsets() const
Returns a list of offsets for the child blocks.
Definition: gridfunctionspace/tags.hh:115
const bool _container_blocked
Definition: orderingbase.hh:270
Definition: interleavedordering.hh:277
Definition: interleavedordering.hh:188
PDELab-specific exceptions.
static result< TC >::type transform(const GFS &gfs, const Transformation &t, const array< std::shared_ptr< TC >, TypeTree::StaticDegree< GFS >::value > &children)
Definition: interleavedordering.hh:203
PowerInterleavedOrdering(bool container_blocked, const InterleavedOrderingTag &ordering_tag, const typename Node::NodeStorage &children, typename Base::GFSData *gfs_data)
Construct ordering object.
Definition: interleavedordering.hh:163
std::string name() const
Definition: interleavedordering.hh:261
Interface for merging index spaces.
Definition: interleavedordering.hh:27
CompositeInterleavedOrdering< typename Transformation::DOFIndex, typename Transformation::ContainerIndex, TC... > type
Definition: interleavedordering.hh:284
static result< TC... >::type transform(const GFS &gfs, const Transformation &t, std::shared_ptr< TC >... children)
Definition: interleavedordering.hh:291
Definition: interleavedordering.hh:271
Definition: interleavedordering.hh:182
power_gfs_to_entityblocked_ordering_descriptor< GFS, Transformation > register_power_gfs_to_ordering_descriptor(GFS *, Transformation *, EntityBlockedOrderingTag *)
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: interleavedordering.hh:96
Definition: ordering/utility.hh:186
std::vector< typename Traits::SizeType > _child_block_merge_offsets
Definition: orderingbase.hh:278
static result< TC >::storage_type transform_storage(std::shared_ptr< const GFS > gfs, const Transformation &t, const array< std::shared_ptr< TC >, TypeTree::StaticDegree< GFS >::value > &children)
Definition: interleavedordering.hh:209
std::size_t index
Definition: interpolate.hh:118
Indicate interleaved ordering of the unknowns of non-leaf grid function spaces according to a given b...
Definition: gridfunctionspace/tags.hh:78
static const unsigned int value
Definition: gridfunctionspace/tags.hh:139
static const bool consume_tree_index
Definition: interleavedordering.hh:39
CompositeInterleavedOrdering(bool backend_blocked, const InterleavedOrderingTag &ordering_tag, typename Base::GFSData *gfs_data, std::shared_ptr< Children >... children)
Construct ordering object.
Definition: interleavedordering.hh:256
Base(Node &node, bool container_blocked, const OrderingTag &ordering_tag, typename BaseT::GFSData *gfs_data)
Construct ordering object.
Definition: interleavedordering.hh:47