4#ifndef DUNE_PDELAB_ORDERING_UTILITY_HH
5#define DUNE_PDELAB_ORDERING_UTILITY_HH
10#include <dune/pdelab/common/dofindex.hh>
11#include <dune/pdelab/common/globaldofindex.hh>
36 struct update_direct_children
41 template<
typename GFS,
typename Child,
typename TreePath,
typename ChildIndex>
42 void afterChild(
const GFS& gfs,
Child&
child, TreePath tp, ChildIndex childIndex)
const
54 struct DefaultDOFIndexAccessor
57 template<
typename DOFIndex,
typename SizeType,
typename IndexType>
58 static typename std::enable_if<
59 std::is_integral<IndexType>::value
61 store(DOFIndex& dof_index,
const GeometryType&
gt, SizeType entity_index, IndexType tree_index)
65 dof_index.entityIndex()[1] = entity_index;
66 dof_index.treeIndex().push_back(tree_index);
69 template<
typename DOFIndex,
typename SizeType,
typename IndexType>
70 static typename std::enable_if<
71 !std::is_integral<IndexType>::value
73 store(DOFIndex& dof_index,
const GeometryType&
gt, SizeType entity_index, IndexType tree_index)
76 dof_index.entityIndex()[1] = entity_index;
77 dof_index.treeIndex() = tree_index;
80 template<
typename DOFIndex,
typename SizeType,
typename IndexType>
81 static typename std::enable_if<
82 std::is_integral<IndexType>::value
84 store(DOFIndex& dof_index, SizeType gt_index, SizeType entity_index, IndexType tree_index)
87 dof_index.entityIndex()[0] = gt_index;
88 dof_index.entityIndex()[1] = entity_index;
89 dof_index.treeIndex().push_back(tree_index);
92 template<
typename DOFIndex,
typename SizeType,
typename IndexType>
93 static typename std::enable_if<
94 !std::is_integral<IndexType>::value
96 store(DOFIndex& dof_index, SizeType gt_index, SizeType entity_index, IndexType tree_index)
98 dof_index.entityIndex()[0] = gt_index;
99 dof_index.entityIndex()[1] = entity_index;
100 dof_index.treeIndex() = tree_index;
107 template<
typename Index>
108 static std::size_t
geometryType(
const Index& geometry_index)
110 return geometry_index[0];
113 template<
typename Index>
114 static std::size_t entityIndex(
const Index& geometry_index)
116 return geometry_index[1];
119 template<
typename Index,
typename SizeType>
120 static void store(Index& index,
const GeometryType&
gt, SizeType entity_index)
123 index[1] = entity_index;
128 template<
typename DOFIndex>
129 static std::size_t
geometryType(
const DOFIndex& dof_index)
131 return GeometryIndex::geometryType(dof_index.entityIndex());
134 template<
typename DOFIndex>
135 static std::size_t entityIndex(
const DOFIndex& dof_index)
137 return GeometryIndex::entityIndex(dof_index.entityIndex());
142 struct SimpleDOFIndexAccessor
145 template<
typename DOFIndex,
typename SizeType>
146 static void store(DOFIndex& dof_index,
const GeometryType&
gt, SizeType entity_index, SizeType tree_index)
148 dof_index = entity_index;
154 template<
typename DI,
typename CI>
155 struct SimpleOrderingTraits
160 typedef CI ContainerIndex;
162 typedef std::size_t SizeType;
164 typedef DefaultDOFIndexAccessor DOFIndexAccessor;
169 template<
typename SizeType_,
typename CI>
170 struct SimpleOrderingTraits<SimpleDOFIndex<SizeType_>,CI>
173 typedef SimpleDOFIndex<SizeType_> DOFIndex;
175 typedef CI ContainerIndex;
177 typedef SizeType_ SizeType;
179 typedef SimpleDOFIndexAccessor DOFIndexAccessor;
185 template<
typename DI,
typename CI>
186 struct OrderingTraits
187 :
public SimpleOrderingTraits<DI,CI>
192 static const std::size_t max_dim = 32;
194 typedef std::bitset<max_dim> CodimFlag;
196 typedef typename DI::TreeIndex TreeIndex;
198 typedef typename DI::View DOFIndexView;
199 typedef typename DI::View::TreeIndex TreeIndexView;
201 typedef typename DI::size_type SizeType;
202 typedef typename DI::size_type size_type;
207 template<
typename ES,
typename DI,
typename CI>
208 struct LocalOrderingTraits
209 :
public OrderingTraits<DI,
214 using EntitySet = ES;
215 using GridView =
typename ES::GridView;
219 template<
typename ES,
typename DI,
typename CI>
220 struct GridViewOrderingTraits
221 :
public LocalOrderingTraits<ES,DI,CI>
224 typedef typename DI::EntityIndex EntityIndex;
225 typedef typename DI::View::EntityIndex EntityIndexView;
230 template<
typename DI,
typename CI>
231 class VirtualOrderingBase
235 typedef OrderingTraits<DI,CI> Traits;
237 VirtualOrderingBase() {}
238 virtual ~VirtualOrderingBase() =
default;
240 virtual void map_index_dynamic(
typename Traits::DOFIndexView di,
typename Traits::ContainerIndex& ci)
const = 0;
244 template<
typename child_type>
245 struct extract_child_bases
246 :
public TypeTree::DirectChildrenVisitor
247 ,
public TypeTree::DynamicTraversal
250 template<
typename Node,
typename Child,
typename TreePath,
typename ChildIndex>
253 extract_child(node,
child,child_index);
256 template<
typename Node,
typename Child,
typename ChildIndex>
257 typename std::enable_if<Node::has_dynamic_ordering_children>::type
258 extract_child(
const Node& node,
Child&
child, ChildIndex child_index)
260 _children[child_index] = &
child;
263 template<
typename Node,
typename Child,
typename ChildIndex>
264 typename std::enable_if<!Node::has_dynamic_ordering_children>::type
265 extract_child(
const Node& node,
Child&
child, ChildIndex child_index)
269 extract_child_bases(std::vector<child_type*>& children)
270 : _children(children)
274 std::vector<child_type*>& _children;
292 typedef std::size_t size_type;
326 return !operator==(r);
329 void push_back(size_type i)
static constexpr std::size_t index(const GeometryType >)
Compute the index for the given geometry type over all dimensions.
Definition: typeindex.hh:133
GeometryType geometryType(const Dune::GeometryType &t)
mapping from GeometryType to VTKGeometryType
Definition: common.hh:199
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:156
Dune namespace.
Definition: alignedallocator.hh:14
Dummy iterator type over DOF indices.
Definition: utility.hh:290
Index merging algorithm for global orderings.
Definition: utility.hh:22
type
Definition: utility.hh:24
@ interleaved
Indices are interleaved according to a user-supplied pattern ([i1,i2],[j1,j2] -> [i1,...
Definition: utility.hh:26
@ lexicographic
Lexicographically ordered ([i1,i2],[j1,j2] -> [i1,i2,j1,j2]).
Definition: utility.hh:25
void afterChild(T &&t, Child &&child, TreePath treePath, ChildIndex childIndex) const
Method for child-parent traversal.
Definition: visitor.hh:119
Convenience base class for visiting the direct children of a node.
Definition: visitor.hh:339
Mixin base class for visitors that only need a dynamic TreePath during traversal.
Definition: visitor.hh:324