3 #ifndef DUNE_PDELAB_ORDERING_INTERLEAVEDORDERING_HH 4 #define DUNE_PDELAB_ORDERING_INTERLEAVEDORDERING_HH 9 #include <dune/typetree/compositenode.hh> 10 #include <dune/typetree/powernode.hh> 24 namespace interleaved_ordering {
27 template<
typename DI,
typename CI,
typename Node>
48 Base(Node& node,
bool container_blocked,
const OrderingTag& ordering_tag,
typename BaseT::GFSData* gfs_data)
49 : BaseT(node,container_blocked,ordering_tag.offsets(),gfs_data,nullptr)
54 if (node.CHILDREN != ordering_tag.
offsets().size() - 1)
56 "Invalid block structure for InterleavedOrdering: " 57 << node.CHILDREN <<
" children, but " 58 << (ordering_tag.
offsets().size() - 1) <<
" block sizes.");
61 template<
typename ItIn,
typename ItOut>
67 for (ItIn in = begin; in != end; ++in, ++out)
69 size_type child_index = in->treeIndex().back();
72 size_type
index = out->back();
73 size_type block_index = index / child_block_size;
74 size_type
offset = index % child_block_size;
75 out->back() = child_block_offset +
offset;
76 out->push_back(block_index);
81 for (ItIn in = begin; in != end; ++in, ++out)
83 size_type child_index = in->treeIndex().back();
87 size_type
index = out->back();
88 size_type block_index = index / child_block_size;
89 size_type
offset = index % child_block_size;
90 out->back() = block_index * block_size + child_block_offset +
offset;
95 template<
typename CIOutIterator,
typename DIOutIterator = DummyDOFIndexIterator>
99 CIOutIterator ci_out,
const CIOutIterator ci_end)
const 104 for (; ci_out != ci_end; ++ci_out)
108 size_type
index = ci_out->back();
109 size_type block_index = index / child_block_size;
110 size_type
offset =index % child_block_size;
111 ci_out->back() = child_block_offset +
offset;
112 ci_out->push_back(block_index);
117 for (; ci_out != ci_end; ++ci_out)
122 size_type
index = ci_out->back();
123 size_type block_index = index / child_block_size;
124 size_type
offset =index % child_block_size;
125 ci_out->back() = block_index * block_size + child_block_offset +
offset;
138 template<
typename DI,
typename CI,
typename Child, std::
size_t k>
140 :
public TypeTree::PowerNode<Child, k>
143 PowerInterleavedOrdering<DI,CI,Child,k>
146 typedef TypeTree::PowerNode<Child, k> Node;
166 , Base(*this,container_blocked,ordering_tag,gfs_data)
171 for (std::size_t i = 0; i < k; ++i)
173 this->child(i).update();
178 std::string
name()
const {
return "PowerInterleavedOrdering"; }
182 template<
typename GFS,
typename Transformation>
186 static const bool recursive =
true;
188 template<
typename TC>
193 typename Transformation::DOFIndex,
194 typename Transformation::ContainerIndex,
203 template<
typename TC>
206 return typename result<TC>::type(gfs.backend().blocked(gfs),gfs.orderingTag(),children,
const_cast<GFS*
>(&gfs));
209 template<
typename TC>
212 return std::make_shared<typename result<TC>::type>(gfs->backend().blocked(*gfs),gfs->orderingTag(),children,
const_cast<GFS*
>(gfs.get()));
217 template<
typename GFS,
typename Transformation>
223 template<
typename DI,
typename CI,
typename... Children>
225 public TypeTree::CompositeNode<Children...>,
228 CompositeInterleavedOrdering<
235 typedef TypeTree::CompositeNode<Children...> Node;
259 ,
Base(*this,backend_blocked,ordering_tag,gfs_data)
262 std::string
name()
const {
return "CompositeInterleavedOrdering"; }
266 TypeTree::applyToTree(*
this,ordering::update_direct_children());
271 template<
typename GFS,
typename Transformation>
275 static const bool recursive =
true;
277 template<
typename... TC>
282 typename Transformation::DOFIndex,
283 typename Transformation::ContainerIndex,
291 template<
typename... TC>
292 static typename result<TC...>::type
transform(
const GFS& gfs,
const Transformation& t, std::shared_ptr<TC>... children)
294 return typename result<TC...>::type(gfs.backend().blocked(gfs),gfs.orderingTag(),
const_cast<GFS*
>(&gfs),children...);
297 template<
typename... TC>
298 static typename result<TC...>::storage_type
transform_storage(std::shared_ptr<const GFS> gfs,
const Transformation& t, std::shared_ptr<TC>... children)
300 return std::make_shared<
typename result<TC...>::type>(gfs->backend().blocked(*gfs),gfs.orderingTag(),
const_cast<GFS*
>(gfs.get()),children...);
305 template<
typename GFS,
typename Transformation>
313 #endif // DUNE_PDELAB_ORDERING_INTERLEAVEDORDERING_HH Definition: interleavedordering.hh:189
Interface for merging index spaces.
Definition: interleavedordering.hh:28
power_gfs_to_entityblocked_ordering_descriptor< GFS, Transformation > register_power_gfs_to_ordering_descriptor(GFS *, Transformation *, EntityBlockedOrderingTag *)
void update()
Definition: interleavedordering.hh:264
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:97
Definition: interleavedordering.hh:272
void map_lfs_indices(const ItIn begin, const ItIn end, ItOut out) const
Definition: interleavedordering.hh:62
PowerInterleavedOrdering(bool container_blocked, const InterleavedOrderingTag &ordering_tag, const typename Node::NodeStorage &children, typename Base::GFSData *gfs_data)
Construct ordering object.
Definition: interleavedordering.hh:164
static const unsigned int value
Definition: gridfunctionspace/tags.hh:139
const std::size_t offset
Definition: localfunctionspace.hh:74
std::string name() const
Definition: interleavedordering.hh:262
InterleavedOrderingTag OrderingTag
Definition: interleavedordering.hh:38
OrderingBase< DI, CI >::Traits Traits
Definition: interleavedordering.hh:36
std::string name() const
Definition: interleavedordering.hh:178
Base(Node &node, bool container_blocked, const OrderingTag &ordering_tag, typename BaseT::GFSData *gfs_data)
Construct ordering object.
Definition: interleavedordering.hh:48
std::shared_ptr< type > storage_type
Definition: interleavedordering.hh:287
CompositeInterleavedOrdering< typename Transformation::DOFIndex, typename Transformation::ContainerIndex, TC... > type
Definition: interleavedordering.hh:285
static const bool consume_tree_index
Definition: interleavedordering.hh:40
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
static result< TC... >::storage_type transform_storage(std::shared_ptr< const GFS > gfs, const Transformation &t, std::shared_ptr< TC >... children)
Definition: interleavedordering.hh:298
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: interleavedordering.hh:210
Definition: interleavedordering.hh:183
PDELab-specific exceptions.
const bool _container_blocked
Definition: orderingbase.hh:270
Definition: interleavedordering.hh:224
Definition: ordering/utility.hh:186
std::shared_ptr< type > storage_type
Definition: interleavedordering.hh:199
static result< TC >::type transform(const GFS &gfs, const Transformation &t, const std::array< std::shared_ptr< TC >, TypeTree::StaticDegree< GFS >::value > &children)
Definition: interleavedordering.hh:204
void update()
Definition: interleavedordering.hh:169
Dune::PDELab::impl::GridFunctionSpaceOrderingData< typename Traits::SizeType > GFSData
Definition: orderingbase.hh:32
PowerInterleavedOrdering< typename Transformation::DOFIndex, typename Transformation::ContainerIndex, TC, TypeTree::StaticDegree< GFS >::value > type
Definition: interleavedordering.hh:197
composite_gfs_to_entityblocked_ordering_descriptor< GFS, Transformation > register_composite_gfs_to_ordering_descriptor(GFS *, Transformation *, EntityBlockedOrderingTag *)
Indicate interleaved ordering of the unknowns of non-leaf grid function spaces according to a given b...
Definition: gridfunctionspace/tags.hh:78
Definition: interleavedordering.hh:139
std::size_t index
Definition: interpolate.hh:118
DI::size_type SizeType
Definition: ordering/utility.hh:201
void update()
Definition: orderingbase.hh:97
Definition: orderingbase.hh:20
const std::vector< std::size_t > & offsets() const
Returns a list of offsets for the child blocks.
Definition: gridfunctionspace/tags.hh:115
CompositeInterleavedOrdering(bool backend_blocked, const InterleavedOrderingTag &ordering_tag, typename Base::GFSData *gfs_data, std::shared_ptr< Children >... children)
Construct ordering object.
Definition: interleavedordering.hh:257
Error related to the logical structure of an Ordering.
Definition: exceptions.hh:44
static result< TC... >::type transform(const GFS &gfs, const Transformation &t, std::shared_ptr< TC >... children)
Definition: interleavedordering.hh:292
std::vector< typename Traits::SizeType > _child_block_merge_offsets
Definition: orderingbase.hh:278
Definition: interleavedordering.hh:278