4#ifndef DUNE_PDELAB_ORDERING_LEAFGRIDVIEWORDERING_HH 
    5#define DUNE_PDELAB_ORDERING_LEAFGRIDVIEWORDERING_HH 
    7#include <dune/pdelab/ordering/directleaflocalordering.hh> 
    8#include <dune/pdelab/ordering/leaforderingbase.hh> 
   17    template<
typename LocalOrdering>
 
   22      typedef typename LocalOrdering::Traits Traits;
 
   26      using ES = 
typename Traits::EntitySet;
 
   34        : 
BaseT(local_ordering, container_blocked, gfs_data)
 
   35        , _es(this->
template child<0>().entitySet())
 
   65      typename Traits::SizeType 
size(
typename Traits::ContainerIndex suffix)
 const 
   71        using size_type = 
typename Traits::SizeType;
 
   72        if (suffix.size() == Traits::ContainerIndex::max_depth)
 
   74        if (suffix.size() == 0) 
 
   78        typename Traits::DOFIndex::EntityIndex entity_index;
 
   81        auto back_index = suffix.back();
 
   84        auto& _gt_entity_offsets = this->localOrdering()._gt_entity_offsets;
 
   85        auto& _entity_dof_offsets = this->localOrdering()._entity_dof_offsets;
 
   86        bool _fixed_size = this->localOrdering()._fixed_size;
 
   88        if (_container_blocked) {
 
   90          auto gt_begin = _fixed_size ? _gt_dof_offsets.begin() : _gt_entity_offsets.begin();
 
   91          auto gt_end = _fixed_size ? _gt_dof_offsets.end() : _gt_entity_offsets.end();
 
   92          auto gt_it = std::prev(std::upper_bound(gt_begin, gt_end, back_index));
 
   93          size_type 
gt = std::distance(gt_begin, gt_it);
 
   94          assert(back_index >= *gt_it);
 
   95          size_type ei = back_index - *gt_it;
 
   96          Traits::DOFIndexAccessor::GeometryIndex::store(entity_index,
gt,ei);
 
   98          auto dof_begin = _fixed_size ? _gt_dof_offsets.begin() : _entity_dof_offsets.begin();
 
   99          auto dof_end = _fixed_size ? _gt_dof_offsets.end() : _entity_dof_offsets.end();
 
  100          auto dof_it = std::prev(std::upper_bound(dof_begin, dof_end, back_index));
 
  101          size_type dof_dist = std::distance(dof_begin, dof_it);
 
  104            Traits::DOFIndexAccessor::GeometryIndex::store(entity_index,dof_dist,~size_type{0});
 
  106            auto gt_begin = _gt_entity_offsets.begin();
 
  107            auto gt_end = _gt_entity_offsets.end();
 
  108            auto gt_it = std::prev(std::upper_bound(gt_begin, gt_end, dof_dist));
 
  109            size_type 
gt = std::distance(gt_begin, gt_it);
 
  110            assert(dof_dist >= *gt_it);
 
  111            size_type ei = dof_dist - *gt_it;
 
  112            Traits::DOFIndexAccessor::GeometryIndex::store(entity_index,
gt,ei);
 
  116        return this->localOrdering().size(suffix, entity_index);
 
  122        LocalOrdering& lo = this->localOrdering();
 
  123        lo.update_a_priori_fixed_size();
 
  125        const std::size_t dim = ES::dimension;
 
  127        typename ES::CodimMask codims;
 
  129        lo.collect_used_codims(codims);
 
  131        for (
typename ES::dim_type codim = 0; codim <= ES::dimension; ++codim)
 
  132          if (codims.test(codim))
 
  137        typedef typename Traits::SizeType size_type;
 
  138        auto geom_types = _es.indexSet().types();
 
  142            lo.update_fixed_size(geom_types.begin(),geom_types.end());
 
  146            lo.pre_collect_used_geometry_types_from_cell();
 
  148            for (
const auto& element : 
elements(_es))
 
  150                lo.collect_used_geometry_types_from_cell(element);
 
  153            lo.allocate_entity_offset_vector(geom_types.begin(),geom_types.end());
 
  155            for (
const auto& element : 
elements(_es))
 
  157                lo.extract_per_entity_sizes_from_cell(element);
 
  161            lo.finalize_non_fixed_size_update();
 
  171            for (
auto gt : geom_types)
 
  174                size_type gt_size = lo.size(gt_index,0);
 
  175                size_type entity_count = _es.indexSet().size(
gt);
 
  176                _size += gt_size * entity_count;
 
  177                if (_container_blocked)
 
  178                  gt_size = gt_size > 0;
 
  179                _gt_dof_offsets[gt_index + 1] = gt_size * entity_count;
 
  181            std::partial_sum(_gt_dof_offsets.begin(),_gt_dof_offsets.end(),_gt_dof_offsets.begin());
 
  182            _block_count = _gt_dof_offsets.back();
 
  183            _codim_fixed_size.set();
 
  187            _block_count = _size = lo._entity_dof_offsets.back();
 
  188            _codim_fixed_size.reset();
 
  191        _fixed_size = lo._fixed_size;
 
  192        _max_local_size = lo.maxLocalSize();
 
  194        _codim_used = lo._codim_used;
 
  195        _codim_fixed_size = lo._codim_fixed_size;
 
  199      using BaseT::fixedSize;
 
  203      using BaseT::_max_local_size;
 
  205      using BaseT::_block_count;
 
  206      using BaseT::_container_blocked;
 
  207      using BaseT::_fixed_size;
 
  208      using BaseT::_codim_used;
 
  209      using BaseT::_codim_fixed_size;
 
  210      using BaseT::_gt_dof_offsets;
 
  212      typename Traits::EntitySet _es;
 
  216    template<
typename GFS, 
typename Transformation>
 
  217    struct direct_leaf_gfs_to_gridview_ordering_descriptor
 
  220      static const bool recursive = 
false;
 
  222      typedef DirectLeafLocalOrdering<
typename GFS::Traits::OrderingTag,
 
  223                                      typename GFS::Traits::FiniteElementMap,
 
  224                                      typename GFS::Traits::EntitySet,
 
  225                                      typename Transformation::DOFIndex,
 
  226                                      typename Transformation::ContainerIndex
 
  229      typedef LeafGridViewOrdering<LocalOrdering> GridViewOrdering;
 
  231      typedef GridViewOrdering transformed_type;
 
  232      typedef std::shared_ptr<transformed_type> transformed_storage_type;
 
  234      static transformed_type transform(
const GFS& gfs, 
const Transformation& t)
 
  236        return transformed_type(make_tuple(std::make_shared<LocalOrdering>(gfs.finiteElementMapStorage(),gfs.entitySet())),gfs.backend().blocked(gfs),
const_cast<GFS*
>(&gfs));
 
  239      static transformed_storage_type transform_storage(std::shared_ptr<const GFS> gfs, 
const Transformation& t)
 
  241        return std::make_shared<transformed_type>(make_tuple(std::make_shared<LocalOrdering>(gfs->finiteElementMapStorage(),gfs->entitySet())),gfs->backend().blocked(*gfs),
const_cast<GFS*
>(gfs.get()));
 
  247    template<
typename GFS, 
typename Transformation, 
typename Params>
 
  248    direct_leaf_gfs_to_gridview_ordering_descriptor<GFS,Transformation>
 
  249    register_leaf_gfs_to_ordering_descriptor(GFS*,Transformation*,LeafOrderingTag<Params>*);
 
static constexpr std::size_t index(const GeometryType >)
Compute the index for the given geometry type over all dimensions.
Definition: typeindex.hh:138
 
static constexpr std::size_t size(std::size_t maxdim)
Compute total number of geometry types up to and including the given dimension.
Definition: typeindex.hh:125
 
Gridview ordering for leaf spaces.
Definition: leafgridviewordering.hh:20
 
virtual void update() override
Definition: leafgridviewordering.hh:120
 
Traits::SizeType size(typename Traits::ContainerIndex suffix) const
Gives the size for a given suffix.
Definition: leafgridviewordering.hh:65
 
Generic infrastructure for orderings for leaf spaces.
Definition: leaforderingbase.hh:27
 
std::tuple< std::shared_ptr< Children >... > NodeStorage
The type used for storing the children.
Definition: compositenode.hh:36
 
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:158
 
auto elements(const SubDomainGridView< HostGridView > &subDomainGridView)
ADL findable access to element range for a SubDomainGridView.
Definition: subdomain.hh:487
 
Dune namespace.
Definition: alignedallocator.hh:13