5 #ifndef DUNE_GRID_COMMON_RANGEGENERATORS_HH 6 #define DUNE_GRID_COMMON_RANGEGENERATORS_HH 8 #include <dune/common/iteratorrange.hh> 9 #include <dune/common/rangeutilities.hh> 10 #include <dune/geometry/dimension.hh> 256 template<
typename GV>
257 inline IteratorRange<...> elements(
const GV& gv);
290 template<
typename GV>
291 inline IteratorRange<...> facets(
const GV& gv);
324 template<
typename GV>
325 inline IteratorRange<...> edges(
const GV& gv);
358 template<
typename GV>
359 inline IteratorRange<...> vertices(
const GV& gv);
394 template<
typename GV,
typename Entity>
395 inline IteratorRange<...> intersections(
const GV& gv,
const Entity& e);
434 template<
typename Entity>
435 inline IteratorRange<...> descendantElements(
const Entity& e,
int maxLevel);
486 template<
typename GV,
int codim>
487 inline IteratorRange<...> entities(
const GV& gv, Codim<codim> cd);
531 template<
typename GV,
int dim>
532 inline IteratorRange<...> entities(
const GV& gv, Dim<dim> d);
570 template<
typename GV,
unsigned int partitions>
571 inline IteratorRange<...> elements(
const GV& gv, PartitionSet<partitions> ps);
604 template<
typename GV,
unsigned int partitions>
605 inline IteratorRange<...> facets(
const GV& gv, PartitionSet<partitions> ps);
635 template<
typename GV,
unsigned int partitions>
636 inline IteratorRange<...> edges(
const GV& gv, PartitionSet<partitions> ps);
666 template<
typename GV,
unsigned int partitions>
667 inline IteratorRange<...> vertices(
const GV& gv, PartitionSet<partitions> ps);
715 template<
typename GV,
int codim,
unsigned int partitions>
716 inline IteratorRange<...> entities(
const GV& gv, Codim<codim> cd, PartitionSet<partitions> ps);
756 template<
typename GV,
int dim,
unsigned int partitions>
757 inline IteratorRange<...> entities(
const GV& gv, Dim<dim> d, PartitionSet<partitions> ps);
782 template<
typename E,
int codim>
783 inline IteratorRange<...> subEntities(
const E& e, Codim<codim> c);
805 template<
typename GV,
int codim,
unsigned int partitions>
806 inline auto entities(
const GV& gv, Codim<codim>, PartitionSet<partitions>)
807 -> IteratorRange<decltype(gv.template begin<codim,derive_partition_iterator_type<partitions>::value>())>
809 static_assert(0 <= codim && codim <= GV::dimension,
"invalid codimension for given GridView");
811 typedef IteratorRange<decltype(gv.template begin<codim,pit>())> return_type;
812 return return_type(gv.template begin<codim,pit>(),gv.template end<codim,pit>());
822 template<
typename GV,
int codim>
823 inline auto entities(
const GV& gv, Codim<codim>)
824 -> IteratorRange<decltype(gv.template begin<codim>())>
826 static_assert(0 <= codim && codim <= GV::dimension,
"invalid codimension for given GridView");
827 typedef IteratorRange<decltype(gv.template begin<codim>())> return_type;
828 return return_type(gv.template begin<codim>(),gv.template end<codim>());
834 template<
typename Entity>
835 inline IteratorRange<typename Entity::HierarchicIterator> descendantElements(
const Entity& e,
int maxLevel)
837 typedef IteratorRange<typename Entity::HierarchicIterator> return_type;
838 return return_type(e.hbegin(maxLevel),e.hend(maxLevel));
844 template<
typename GV,
typename Entity>
845 inline auto intersections(
const GV& gv,
const Entity& e)
846 -> IteratorRange<decltype(gv.ibegin(e))>
848 return IteratorRange<decltype(gv.ibegin(e))>(gv.ibegin(e),gv.iend(e));
857 template<
typename GV,
int dim,
unsigned int partitions>
858 inline auto entities(
const GV& gv, Dim<dim>, PartitionSet<partitions>)
859 -> decltype(entities(gv,Codim<GV::dimension - dim>(),PartitionSet<partitions>()))
861 static_assert(0 <= dim && dim <= GV::dimension,
"invalid dimension for given GridView");
862 return entities(gv,Codim<GV::dimension - dim>(),PartitionSet<partitions>());
865 template<
typename GV,
int dim>
866 inline auto entities(
const GV& gv, Dim<dim>)
867 -> decltype(entities(gv,Codim<GV::dimension - dim>()))
869 static_assert(0 <= dim && dim <= GV::dimension,
"invalid dimension for given GridView");
870 return entities(gv,Codim<GV::dimension - dim>());
873 template<
typename GV,
unsigned int partitions>
874 inline auto elements(
const GV& gv, PartitionSet<partitions>)
875 -> decltype(entities(gv,Codim<0>(),PartitionSet<partitions>()))
877 return entities(gv,Codim<0>(),PartitionSet<partitions>());
880 template<
typename GV>
881 inline auto elements(
const GV& gv)
882 -> decltype(entities(gv,Codim<0>()))
884 return entities(gv,Codim<0>());
887 template<
typename GV,
unsigned int partitions>
888 inline auto facets(
const GV& gv, PartitionSet<partitions>)
889 -> decltype(entities(gv,Codim<1>(),PartitionSet<partitions>()))
891 return entities(gv,Codim<1>(),PartitionSet<partitions>());
894 template<
typename GV>
895 inline auto facets(
const GV& gv)
896 -> decltype(entities(gv,Codim<1>()))
898 return entities(gv,Codim<1>());
901 template<
typename GV,
unsigned int partitions>
902 inline auto edges(
const GV& gv, PartitionSet<partitions>)
903 -> decltype(entities(gv,Dim<1>(),PartitionSet<partitions>()))
905 return entities(gv,Dim<1>(),PartitionSet<partitions>());
908 template<
typename GV>
909 inline auto edges(
const GV& gv)
910 -> decltype(entities(gv,Dim<1>()))
912 return entities(gv,Dim<1>());
915 template<
typename GV,
unsigned int partitions>
916 inline auto vertices(
const GV& gv, PartitionSet<partitions>)
917 -> decltype(entities(gv,Dim<0>(),PartitionSet<partitions>()))
919 return entities(gv,Dim<0>(),PartitionSet<partitions>());
922 template<
typename GV>
923 inline auto vertices(
const GV& gv)
924 -> decltype(entities(gv,Dim<0>()))
926 return entities(gv,Dim<0>());
929 template<
typename E,
int codim>
930 inline auto subEntities(
const E& e, Codim<codim> c)
932 static_assert(E::codimension <= codim,
933 "Can only iterate over sub-entities with equal or larger codimension");
934 return transformedRangeView(
935 range(static_cast<int>(e.subEntities(c))),
936 [&](
const int i){
return e.template subEntity<codim>(i); }
948 #endif // DUNE_GRID_COMMON_RANGEGENERATORS_HH concept Entity
Model of a grid entity.
Definition: concepts/entity.hh:119
Include standard header files.
Definition: agrid.hh:59
PartitionIteratorType
Parameter to be used for the parallel level- and leaf iterators.
Definition: gridenums.hh:136