3#ifndef DUNE_GRID_COMMON_RANGEGENERATORS_HH
4#define DUNE_GRID_COMMON_RANGEGENERATORS_HH
6#include <dune/common/iteratorrange.hh>
8#include <dune/geometry/dimension.hh>
9#include <dune/grid/common/gridenums.hh>
10#include <dune/grid/common/partitionset.hh>
254 template<
typename GV>
288 template<
typename GV>
322 template<
typename GV>
356 template<
typename GV>
392 template<
typename GV,
typename Entity>
432 template<
typename Entity>
484 template<
typename GV,
int codim>
529 template<
typename GV,
int dim>
568 template<
typename GV,
unsigned int partitions>
602 template<
typename GV,
unsigned int partitions>
633 template<
typename GV,
unsigned int partitions>
664 template<
typename GV,
unsigned int partitions>
713 template<
typename GV,
int codim,
unsigned int partitions>
754 template<
typename GV,
int dim,
unsigned int partitions>
780 template<
typename E,
int codim>
803 template<
typename GV,
int codim,
unsigned int partitions>
805 ->
IteratorRange<
decltype(gv.template begin<codim,derive_partition_iterator_type<partitions>::value>())>
807 static_assert(0 <= codim && codim <= GV::dimension,
"invalid codimension for given GridView");
809 typedef IteratorRange<
decltype(gv.template begin<codim,pit>())> return_type;
810 return return_type(gv.template begin<codim,pit>(),gv.template end<codim,pit>());
820 template<
typename GV,
int codim>
824 static_assert(0 <= codim && codim <= GV::dimension,
"invalid codimension for given GridView");
825 typedef IteratorRange<
decltype(gv.template begin<codim>())> return_type;
826 return return_type(gv.template begin<codim>(),gv.template end<codim>());
832 template<
typename Entity>
833 inline IteratorRange<typename Entity::HierarchicIterator> descendantElements(
const Entity& e,
int maxLevel)
835 typedef IteratorRange<typename Entity::HierarchicIterator> return_type;
836 return return_type(e.hbegin(maxLevel),e.hend(maxLevel));
842 template<
typename GV,
typename Entity>
843 inline auto intersections(
const GV& gv,
const Entity& e)
844 -> IteratorRange<
decltype(gv.ibegin(e))>
846 return IteratorRange<
decltype(gv.ibegin(e))>(gv.ibegin(e),gv.iend(e));
855 template<
typename GV,
int dim,
unsigned int partitions>
856 inline auto entities(
const GV& gv, Dim<dim>, PartitionSet<partitions>)
857 ->
decltype(entities(gv,Codim<GV::dimension - dim>(),PartitionSet<partitions>()))
859 static_assert(0 <= dim && dim <= GV::dimension,
"invalid dimension for given GridView");
860 return entities(gv,Codim<GV::dimension - dim>(),PartitionSet<partitions>());
863 template<
typename GV,
int dim>
864 inline auto entities(
const GV& gv, Dim<dim>)
865 ->
decltype(entities(gv,Codim<GV::dimension - dim>()))
867 static_assert(0 <= dim && dim <= GV::dimension,
"invalid dimension for given GridView");
868 return entities(gv,Codim<GV::dimension - dim>());
871 template<
typename GV,
unsigned int partitions>
872 inline auto elements(
const GV& gv, PartitionSet<partitions>)
873 ->
decltype(entities(gv,Codim<0>(),PartitionSet<partitions>()))
875 return entities(gv,Codim<0>(),PartitionSet<partitions>());
878 template<
typename GV>
879 inline auto elements(
const GV& gv)
880 ->
decltype(entities(gv,Codim<0>()))
882 return entities(gv,Codim<0>());
885 template<
typename GV,
unsigned int partitions>
886 inline auto facets(
const GV& gv, PartitionSet<partitions>)
887 ->
decltype(entities(gv,Codim<1>(),PartitionSet<partitions>()))
889 return entities(gv,Codim<1>(),PartitionSet<partitions>());
892 template<
typename GV>
893 inline auto facets(
const GV& gv)
894 ->
decltype(entities(gv,Codim<1>()))
896 return entities(gv,Codim<1>());
899 template<
typename GV,
unsigned int partitions>
900 inline auto edges(
const GV& gv, PartitionSet<partitions>)
901 ->
decltype(entities(gv,Dim<1>(),PartitionSet<partitions>()))
903 return entities(gv,Dim<1>(),PartitionSet<partitions>());
906 template<
typename GV>
907 inline auto edges(
const GV& gv)
908 ->
decltype(entities(gv,Dim<1>()))
910 return entities(gv,Dim<1>());
913 template<
typename GV,
unsigned int partitions>
914 inline auto vertices(
const GV& gv, PartitionSet<partitions>)
915 ->
decltype(entities(gv,Dim<0>(),PartitionSet<partitions>()))
917 return entities(gv,Dim<0>(),PartitionSet<partitions>());
920 template<
typename GV>
921 inline auto vertices(
const GV& gv)
922 ->
decltype(entities(gv,Dim<0>()))
924 return entities(gv,Dim<0>());
927 template<
typename E,
int codim>
928 inline auto subEntities(
const E& e, Codim<codim> c)
930 static_assert(E::codimension <= codim,
931 "Can only iterate over sub-entities with equal or larger codimension");
933 range(
static_cast<int>(e.subEntities(c))),
934 [&](
const int i){ return e.template subEntity<codim>(i); }
Wrapper class for entities.
Definition: entity.hh:64
Simple range between a begin and an end iterator.
Definition: iteratorrange.hh:20
IteratorRange<... > intersections(const GV &gv, const Entity &e)
Iterates over all Intersections of an Entity with respect to the given GridView.
IteratorRange<... > vertices(const GV &gv)
Iterates over all vertices (entities with dimension 0) of a GridView.
IteratorRange<... > elements(const GV &gv, PartitionSet< partitions > ps)
Iterates over all elements / cells (entities with codimension 0) of a GridView that belong to the giv...
IteratorRange<... > entities(const GV &gv, Codim< codim > cd, PartitionSet< partitions > ps)
Iterates over all entities of a GridView with the given codimension that belong to the given Partitio...
IteratorRange<... > edges(const GV &gv, PartitionSet< partitions > ps)
Iterates over all edges (entities with dimension 1) of a GridView that belong to the given PartitionS...
IteratorRange<... > entities(const GV &gv, Dim< dim > d, PartitionSet< partitions > ps)
Iterates over all entities of a GridView with the given dimension that belong to the given PartitionS...
IteratorRange<... > entities(const GV &gv, Dim< dim > d)
Iterates over all entities of a GridView with the given dimension.
IteratorRange<... > subEntities(const E &e, Codim< codim > c)
Iterates over all sub-entities of an entity given the codimension of the sub-entities.
IteratorRange<... > vertices(const GV &gv, PartitionSet< partitions > ps)
Iterates over all vertices (entities with dimension 0) of a GridView that belong to the given Partiti...
IteratorRange<... > elements(const GV &gv)
Iterates over all elements / cells (entities with codimension 0) of a GridView.
IteratorRange<... > entities(const GV &gv, Codim< codim > cd)
Iterates over all entities of a GridView with the given codimension.
IteratorRange<... > facets(const GV &gv, PartitionSet< partitions > ps)
Iterates over all facets (entities with codimension 1) of a GridView that belong to the given Partiti...
IteratorRange<... > facets(const GV &gv)
Iterates over all facets (entities with codimension 1) of a GridView.
IteratorRange<... > edges(const GV &gv)
Iterates over all edges (entities with dimension 1) of a GridView.
IteratorRange<... > descendantElements(const Entity &e, int maxLevel)
Iterates over all descendant elements of the given element up to a maximum level.
auto transformedRangeView(R &&range, const F &f)
Create a TransformedRangeView.
Definition: rangeutilities.hh:767
Dune namespace.
Definition: alignedallocator.hh:11
Utilities for reduction like operations on ranges.
Static tag representing a codimension.
Definition: dimension.hh:22
Static tag representing a dimension.
Definition: dimension.hh:14
A struct that collects all associated types of one implementation from the Traits class.
Definition: gridview.hh:98
A set of PartitionType values.
Definition: partitionset.hh:136