4#ifndef DUNE_PDELAB_ORDERING_LEAFORDERINGBASE_HH
5#define DUNE_PDELAB_ORDERING_LEAFORDERINGBASE_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/directleaflocalordering.hh>
20 template<
typename LocalOrdering>
23 ,
public VirtualOrderingBase<typename LocalOrdering::Traits::DOFIndex,
24 typename LocalOrdering::Traits::ContainerIndex>
25 ,
public OrderingBase<typename LocalOrdering::Traits::DOFIndex,
26 typename LocalOrdering::Traits::ContainerIndex>
29 typedef typename LocalOrdering::Traits Traits;
31 static const bool has_dynamic_ordering_children =
false;
33 static const bool consume_tree_index =
false;
39 typedef OrderingBase<
typename LocalOrdering::Traits::DOFIndex,
40 typename LocalOrdering::Traits::ContainerIndex> BaseT;
44 LocalOrdering& localOrdering()
46 return this->
template child<0>();
49 const LocalOrdering& localOrdering()
const
51 return this->
template child<0>();
56 :
NodeT(local_ordering)
57 , BaseT(*
this,container_blocked,gfs_data,
this)
66 :
NodeT(r.nodeStorage())
68 , _gt_dof_offsets(r._gt_dof_offsets)
70 this->setDelegate(
this);
74 :
NodeT(r.nodeStorage())
76 , _gt_dof_offsets(std::move(r._gt_dof_offsets))
78 this->setDelegate(
this);
85 virtual void map_index_dynamic(
typename Traits::DOFIndexView di,
typename Traits::ContainerIndex& ci)
const override
90 typename Traits::ContainerIndex mapIndex(
const typename Traits::DOFIndex& di)
const
92 typename Traits::ContainerIndex ci;
93 mapIndex(di.view(),ci);
97 void mapIndex(
typename Traits::DOFIndexView di,
typename Traits::ContainerIndex& ci)
const
100 const typename Traits::SizeType geometry_type_index = Traits::DOFIndexAccessor::geometryType(di);
101 const typename Traits::SizeType entity_index = Traits::DOFIndexAccessor::entityIndex(di);
102 assert (di.treeIndex().size() == 1);
103 ci.push_back(di.treeIndex().back());
105 if (localOrdering()._fixed_size)
107 if (_container_blocked)
111 if (ci.size() < ci.capacity())
112 ci.push_back(_gt_dof_offsets[geometry_type_index] + entity_index);
120 ci.back() += _gt_dof_offsets[geometry_type_index] + entity_index * localOrdering()._gt_dof_sizes[geometry_type_index];
125 if (_container_blocked)
129 if (ci.size() < ci.capacity())
130 ci.push_back(localOrdering()._gt_entity_offsets[geometry_type_index] + entity_index);
138 ci.back() += localOrdering()._entity_dof_offsets[localOrdering()._gt_entity_offsets[geometry_type_index] + entity_index];
144 template<
typename ItIn,
typename ItOut>
145 void map_lfs_indices(
const ItIn begin,
const ItIn end, ItOut out)
const
147 typedef typename Traits::SizeType size_type;
149 if (localOrdering()._fixed_size)
151 if (_container_blocked)
153 for (ItIn in = begin; in != end; ++in, ++out)
155 assert(in->treeIndex().size() == 1);
156 out->push_back(in->treeIndex().back());
157 const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(*in);
158 const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(*in);
159 assert(localOrdering()._gt_used[geometry_type_index]);
160 out->push_back(_gt_dof_offsets[geometry_type_index] + entity_index);
165 for (ItIn in = begin; in != end; ++in, ++out)
167 assert(in->treeIndex().size() == 1);
168 out->push_back(in->treeIndex().back());
169 const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(*in);
170 const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(*in);
171 assert(localOrdering()._gt_used[geometry_type_index]);
172 out->back() += _gt_dof_offsets[geometry_type_index] + entity_index * localOrdering()._gt_dof_sizes[geometry_type_index];
178 if (_container_blocked)
180 for (ItIn in = begin; in != end; ++in, ++out)
182 assert(in->treeIndex().size() == 1);
183 out->push_back(in->treeIndex().back());
184 const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(*in);
185 const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(*in);
186 assert(localOrdering()._gt_used[geometry_type_index]);
187 out->push_back(localOrdering()._gt_entity_offsets[geometry_type_index] + entity_index);
192 for (ItIn in = begin; in != end; ++in, ++out)
194 assert(in->treeIndex().size() == 1);
195 out->push_back(in->treeIndex().back());
196 const size_type geometry_type_index = Traits::DOFIndexAccessor::geometryType(*in);
197 const size_type entity_index = Traits::DOFIndexAccessor::entityIndex(*in);
198 assert(localOrdering()._gt_used[geometry_type_index]);
199 out->back() += localOrdering()._entity_dof_offsets[localOrdering()._gt_entity_offsets[geometry_type_index] + entity_index];
205 template<
typename CIOutIterator>
206 typename Traits::SizeType
207 extract_entity_indices(
const typename Traits::DOFIndex::EntityIndex& ei,
208 typename Traits::SizeType child_index,
209 CIOutIterator ci_out,
const CIOutIterator ci_end)
const
211 typedef typename Traits::SizeType size_type;
213 const size_type geometry_type_index = Traits::DOFIndexAccessor::GeometryIndex::geometryType(ei);
214 const size_type entity_index = Traits::DOFIndexAccessor::GeometryIndex::entityIndex(ei);
216 if (!localOrdering()._gt_used[geometry_type_index])
219 if (localOrdering()._fixed_size)
221 size_type size = localOrdering()._gt_dof_sizes[geometry_type_index];
222 if (_container_blocked)
224 for (size_type i = 0; i < size; ++i, ++ci_out)
226 ci_out->push_back(i);
227 ci_out->push_back(_gt_dof_offsets[geometry_type_index] + entity_index);
232 for (size_type i = 0; i < size; ++i, ++ci_out)
234 ci_out->push_back(i);
235 ci_out->back() += _gt_dof_offsets[geometry_type_index] + entity_index * localOrdering()._gt_dof_sizes[geometry_type_index];
242 size_type index = localOrdering()._gt_entity_offsets[geometry_type_index] + entity_index;
243 size_type size = localOrdering()._entity_dof_offsets[index+1] - localOrdering()._entity_dof_offsets[index];
244 if (_container_blocked)
246 for (size_type i = 0; i < size; ++i, ++ci_out)
248 ci_out->push_back(i);
249 ci_out->push_back(index);
254 for (size_type i = 0; i < size; ++i, ++ci_out)
256 ci_out->push_back(i);
257 ci_out->back() += localOrdering()._entity_dof_offsets[index];
273 using BaseT::_max_local_size;
275 using BaseT::_block_count;
276 using BaseT::_container_blocked;
277 using BaseT::_fixed_size;
278 using BaseT::_codim_used;
279 using BaseT::_codim_fixed_size;
281 std::vector<typename Traits::SizeType> _gt_dof_offsets;
Base class for Dune-Exceptions.
Definition: exceptions.hh:96
Generic infrastructure for orderings for leaf spaces.
Definition: leaforderingbase.hh:27
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
std::size_t fixedSize
The number of data items per index if it is fixed, 0 otherwise.
Definition: variablesizecommunicator.hh:264