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> 
   45      struct update_direct_children
 
   50        template<
typename GFS, 
typename Child, 
typename TreePath, 
typename ChildIndex>
 
   51        void afterChild(
const GFS& gfs, 
Child& 
child, TreePath tp, ChildIndex childIndex)
 const 
   63    struct DefaultDOFIndexAccessor
 
   66      template<
typename DOFIndex, 
typename SizeType, 
typename IndexType>
 
   67      static typename std::enable_if<
 
   68        std::is_integral<IndexType>::value
 
   70      store(DOFIndex& dof_index, 
const GeometryType& 
gt, SizeType entity_index, IndexType tree_index)
 
   74        dof_index.entityIndex()[1] = entity_index;
 
   75        dof_index.treeIndex().push_back(tree_index);
 
   78      template<
typename DOFIndex, 
typename SizeType, 
typename IndexType>
 
   79      static typename std::enable_if<
 
   80        !std::is_integral<IndexType>::value
 
   82      store(DOFIndex& dof_index, 
const GeometryType& 
gt, SizeType entity_index, IndexType tree_index)
 
   85        dof_index.entityIndex()[1] = entity_index;
 
   86        dof_index.treeIndex() = tree_index;
 
   89      template<
typename DOFIndex, 
typename SizeType, 
typename IndexType>
 
   90      static typename std::enable_if<
 
   91        std::is_integral<IndexType>::value
 
   93      store(DOFIndex& dof_index, SizeType gt_index, SizeType entity_index, IndexType tree_index)
 
   96        dof_index.entityIndex()[0] = gt_index;
 
   97        dof_index.entityIndex()[1] = entity_index;
 
   98        dof_index.treeIndex().push_back(tree_index);
 
  101      template<
typename DOFIndex, 
typename SizeType, 
typename IndexType>
 
  102      static typename std::enable_if<
 
  103        !std::is_integral<IndexType>::value
 
  105      store(DOFIndex& dof_index, SizeType gt_index, SizeType entity_index, IndexType tree_index)
 
  107        dof_index.entityIndex()[0] = gt_index;
 
  108        dof_index.entityIndex()[1] = entity_index;
 
  109        dof_index.treeIndex() = tree_index;
 
  116        template<
typename Index>
 
  117        static std::size_t 
geometryType(
const Index& geometry_index)
 
  119          return geometry_index[0];
 
  122        template<
typename Index>
 
  123        static std::size_t entityIndex(
const Index& geometry_index)
 
  125          return geometry_index[1];
 
  128        template<
typename Index, 
typename SizeType>
 
  129        static void store(Index& index, 
const GeometryType& 
gt, SizeType entity_index)
 
  132          index[1] = entity_index;
 
  135        template<
typename Index, 
typename SizeType>
 
  136        static void store(Index& index, SizeType geometry_index, SizeType entity_index)
 
  138          index[0] = geometry_index;
 
  139          index[1] = entity_index;
 
  144      template<
typename DOFIndex>
 
  145      static std::size_t 
geometryType(
const DOFIndex& dof_index)
 
  147        return GeometryIndex::geometryType(dof_index.entityIndex());
 
  150      template<
typename DOFIndex>
 
  151      static std::size_t entityIndex(
const DOFIndex& dof_index)
 
  153        return GeometryIndex::entityIndex(dof_index.entityIndex());
 
  158    struct SimpleDOFIndexAccessor
 
  161      template<
typename DOFIndex, 
typename SizeType>
 
  162      static void store(DOFIndex& dof_index, 
const GeometryType& 
gt, SizeType entity_index, SizeType tree_index)
 
  164        dof_index = entity_index;
 
  170    template<
typename DI, 
typename CI, MultiIndexOrder CIOrder = MultiIndexOrder::Inner2Outer>
 
  171    struct SimpleOrderingTraits
 
  176      typedef CI ContainerIndex;
 
  178      typedef std::size_t SizeType;
 
  180      typedef DefaultDOFIndexAccessor DOFIndexAccessor;
 
  187    template<
typename SizeType_, 
typename CI, MultiIndexOrder CIOrder>
 
  188    struct SimpleOrderingTraits<SimpleDOFIndex<SizeType_>,CI,CIOrder>
 
  191      typedef SimpleDOFIndex<SizeType_> DOFIndex;
 
  193      typedef CI ContainerIndex;
 
  195      typedef SizeType_ SizeType;
 
  197      typedef SimpleDOFIndexAccessor DOFIndexAccessor;
 
  203    template <
typename DI, 
typename CI,
 
  205    struct OrderingTraits : 
public SimpleOrderingTraits<DI, CI, CIOrder> {
 
  209      static const std::size_t max_dim = 32;
 
  211      typedef std::bitset<max_dim> CodimFlag;
 
  213      typedef typename DI::TreeIndex TreeIndex;
 
  215      typedef typename DI::View DOFIndexView;
 
  216      typedef typename DI::View::TreeIndex TreeIndexView;
 
  218      typedef typename DI::size_type SizeType;
 
  219      typedef typename DI::size_type size_type;
 
  222    template <
typename ES, 
typename DI, 
typename CI,
 
  224    struct LocalOrderingTraits : 
public OrderingTraits<DI, CI, CIOrder> {
 
  226      using EntitySet = ES;
 
  227      using GridView = 
typename ES::GridView;
 
  230    template<
typename ES, 
typename DI, 
typename CI>
 
  231    struct GridViewOrderingTraits
 
  232      : 
public LocalOrderingTraits<ES,DI,CI>
 
  235      typedef typename DI::EntityIndex EntityIndex;
 
  236      typedef typename DI::View::EntityIndex EntityIndexView;
 
  241    template<
typename DI, 
typename CI>
 
  242    class VirtualOrderingBase
 
  246      typedef OrderingTraits<DI,CI> Traits;
 
  248      VirtualOrderingBase() {}
 
  249      virtual ~VirtualOrderingBase() = 
default;
 
  251      virtual void map_index_dynamic(
typename Traits::DOFIndexView di, 
typename Traits::ContainerIndex& ci) 
const = 0;
 
  255    template<
typename child_type>
 
  256    struct extract_child_bases
 
  257      : 
public TypeTree::DirectChildrenVisitor
 
  258      , 
public TypeTree::DynamicTraversal
 
  261      template<
typename Node, 
typename Child, 
typename TreePath, 
typename ChildIndex>
 
  264        extract_child(node,
child,child_index);
 
  267      template<
typename Node, 
typename Child, 
typename ChildIndex>
 
  268      typename std::enable_if<Node::has_dynamic_ordering_children>::type
 
  269      extract_child(
const Node& node, 
Child& 
child, ChildIndex child_index)
 
  271        _children[child_index] = &
child;
 
  274      template<
typename Node, 
typename Child, 
typename ChildIndex>
 
  275      typename std::enable_if<!Node::has_dynamic_ordering_children>::type
 
  276      extract_child(
const Node& node, 
Child& 
child, ChildIndex child_index)
 
  280      extract_child_bases(std::vector<child_type*>& children)
 
  281        : _children(children)
 
  285      std::vector<child_type*>& _children;
 
  303      typedef std::size_t size_type;
 
  337        return !operator==(r);
 
  340      void push_back(size_type i)
 
  362    template <
class Size, 
class ContainerIndex_, MultiIndexOrder OriginOrder>
 
  371      template <
class Ordering>
 
  373          : _size_provider([=](const ContainerIndex_ &partial_multiindex) {
 
  374              return ordering->size(partial_multiindex);
 
  376        static_assert(Ordering::Traits::ContainerIndexOrder == OriginOrder);
 
  400          suffix.resize(prefix.size());
 
  401          std::reverse_copy(prefix.begin(), prefix.end(),suffix.begin());
 
  403          return _size_provider(suffix);
 
  406          return _size_provider(prefix);
 
  416    template<
class Ordering>
 
  419                              typename Ordering::Traits::ContainerIndex,
 
  420                              Ordering::Traits::ContainerIndexOrder>;
 
static constexpr std::size_t index(const GeometryType >)
Compute the index for the given geometry type over all dimensions.
Definition: typeindex.hh:138
 
GeometryType geometryType(const Dune::GeometryType &t)
mapping from GeometryType to VTKGeometryType
Definition: common.hh:151
 
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:158
 
MultiIndexOrder
Information about order semantics on multi-indices.
Definition: utility.hh:32
 
SizeProviderAdapter(const std::shared_ptr< const Ordering > &ordering) -> SizeProviderAdapter< typename Ordering::Traits::SizeType, typename Ordering::Traits::ContainerIndex, Ordering::Traits::ContainerIndexOrder >
template deduction guide for orderings
 
@ Inner2Outer
indices are ordered from inner to outer container: {inner,...,outer}
 
@ Outer2Inner
indices are ordered from outer to inner container: {outer,...,inner}
 
Dune namespace.
Definition: alignedallocator.hh:13
 
Dummy iterator type over DOF indices.
Definition: utility.hh:301
 
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
 
Adapter to create a size provider from an ordering.
Definition: utility.hh:363
 
ContainerIndex SizePrefix
Partial MultiIndex of a ContainerIndex.
Definition: utility.hh:383
 
SizeType size(const SizePrefix &prefix) const
Gives the size for a given prefix.
Definition: utility.hh:396
 
SizeProviderAdapter(const std::shared_ptr< const Ordering > &ordering)
Construct a new Size Provider Adapter object.
Definition: utility.hh:372
 
Size SizeType
Type that refers to the size of containers.
Definition: utility.hh:386
 
ContainerIndex_ ContainerIndex
Partial MultiIndex of a ContainerIndex.
Definition: utility.hh:380
 
static constexpr MultiIndexOrder ContainerIndexOrder
Inform about ContainerIndex multi-index order semantics.
Definition: utility.hh:389
 
void afterChild(T &&, Child &&, TreePath, ChildIndex) const
Method for child-parent traversal.
Definition: visitor.hh:122
 
Convenience base class for visiting the direct children of a node.
Definition: visitor.hh:441
 
Mixin base class for visitors that only need a dynamic TreePath during traversal.
Definition: visitor.hh:426