Dune Core Modules (2.4.2)

rangegenerators.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_GRID_COMMON_RANGEGENERATORS_HH
4#define DUNE_GRID_COMMON_RANGEGENERATORS_HH
5
6#include <dune/common/iteratorrange.hh>
7#include <dune/geometry/dimension.hh>
8#include <dune/grid/common/gridenums.hh>
9#include <dune/grid/common/partitionset.hh>
10
11namespace Dune
12{
13
14#ifdef DOXYGEN
15
190 // *****************************************************************************************
191 // Doxygen documentation
192 // *****************************************************************************************
193 //
194 // In the following, the range generating functions are documented for Doxygen; the actual
195 // implementations are further down in this file and hidden from Doxygen.
196 // The main reason for this split are the return types of those functions, which either contain
197 // long type listings to obtain the iterator type or (in the case of the forwarded functions
198 // use the new-style function syntax and calculate the return type using decltype. In both cases,
199 // Doxygen generates function signatures that are very confusing to the average user.
200 //
201 // *****************************************************************************************
202
203
204
208
209
211
241 template<typename GV>
242 inline IteratorRange<...> elements(const GV& gv);
243
244
246
276 template<typename GV>
277 inline IteratorRange<...> facets(const GV& gv);
278
279
281
311 template<typename GV>
312 inline IteratorRange<...> edges(const GV& gv);
313
314
316
346 template<typename GV>
347 inline IteratorRange<...> vertices(const GV& gv);
348
349
351
352
353
357
359
383 template<typename GV, typename Entity>
384 inline IteratorRange<...> intersections(const GV& gv, const Entity& e);
385
386
388
389
390
394
395
397
424 template<typename Entity>
425 inline IteratorRange<...> descendantElements(const Entity& e, int maxLevel);
426 // Entity<int dim, class GridImp, template<int,int,class> class EntityImp>
427
429
430
431
435
436
438
477 template<typename GV, int codim>
478 inline IteratorRange<...> entities(const GV& gv, Codim<codim> cd);
479
480
482
523 template<typename GV, int dim>
524 inline IteratorRange<...> entities(const GV& gv, Dim<dim> d);
525
527
528
529
533
534
536
563 template<typename GV, unsigned int partitions>
564 inline IteratorRange<...> elements(const GV& gv, PartitionSet<partitions> ps);
565
566
568
598 template<typename GV, unsigned int partitions>
599 inline IteratorRange<...> facets(const GV& gv, PartitionSet<partitions> ps);
600
601
603
630 template<typename GV, unsigned int partitions>
631 inline IteratorRange<...> edges(const GV& gv, PartitionSet<partitions> ps);
632
633
635
662 template<typename GV, unsigned int partitions>
663 inline IteratorRange<...> vertices(const GV& gv, PartitionSet<partitions> ps);
664
666
667
668
672
673
675
712 template<typename GV, int codim, unsigned int partitions>
713 inline IteratorRange<...> entities(const GV& gv gv, Codim<codim> cd, PartitionSet<partitions> ps);
714
715
717
754 template<typename GV, int dim, unsigned int partitions>
755 inline IteratorRange<...> entities(const GV& gv, Dim<dim> d, PartitionSet<partitions> ps);
756
757
759
760
761#else // DOXYGEN
762
763// only make the implementations available on new compilers - there is a really nasty bug in GCC 4.4...
764#if HAVE_RANGE_BASED_FOR
765
766 // ******************************************************************************************
767 // Implementations
768 // ******************************************************************************************
769
770
780 template<typename GV, int codim, unsigned int partitions>
781 inline IteratorRange<
782 typename GV::template Codim<codim>::template Partition<
783 derive_partition_iterator_type<partitions>::value
784 >::Iterator
785 >
786 entities(const GV& gv, Codim<codim>, PartitionSet<partitions>)
787 {
788 static_assert(0 <= codim && codim <= GV::dimension, "invalid codimension for given GridView");
789 const PartitionIteratorType pit = derive_partition_iterator_type<partitions>::value;
790 typedef IteratorRange<
791 typename GV::template Codim<codim>::template Partition<pit>::Iterator
792 > return_type;
793 return return_type(gv.template begin<codim,pit>(),gv.template end<codim,pit>());
794 }
795
803 template<typename GV, int codim>
804 inline IteratorRange<
805 typename GV::template Codim<codim>::Iterator
806 >
807 entities(const GV& gv, Codim<codim>)
808 {
809 static_assert(0 <= codim && codim <= GV::dimension, "invalid codimension for given GridView");
810 typedef IteratorRange<
811 typename GV::template Codim<codim>::Iterator
812 > return_type;
813 return return_type(gv.template begin<codim>(),gv.template end<codim>());
814 }
815
819 template<typename Entity>
820 inline IteratorRange<typename Entity::HierarchicIterator> descendantElements(const Entity& e, int maxLevel)
821 {
822 typedef IteratorRange<typename Entity::HierarchicIterator> return_type;
823 return return_type(e.hbegin(maxLevel),e.hend(maxLevel));
824 }
825
829 template<typename GV, typename Entity>
830 inline IteratorRange<typename GV::IntersectionIterator> intersections(const GV& gv, const Entity& e)
831 {
832 return IteratorRange<typename GV::IntersectionIterator>(gv.ibegin(e),gv.iend(e));
833 }
834
835
841 template<typename GV, int dim, unsigned int partitions>
842 inline auto entities(const GV& gv, Dim<dim>, PartitionSet<partitions>)
843 -> decltype(entities(gv,Codim<GV::dimension - dim>(),PartitionSet<partitions>()))
844 {
845 static_assert(0 <= dim && dim <= GV::dimension, "invalid dimension for given GridView");
846 return entities(gv,Codim<GV::dimension - dim>(),PartitionSet<partitions>());
847 }
848
849 template<typename GV, int dim>
850 inline auto entities(const GV& gv, Dim<dim>)
851 -> decltype(entities(gv,Codim<GV::dimension - dim>()))
852 {
853 static_assert(0 <= dim && dim <= GV::dimension, "invalid dimension for given GridView");
854 return entities(gv,Codim<GV::dimension - dim>());
855 }
856
857 template<typename GV, unsigned int partitions>
858 inline auto elements(const GV& gv, PartitionSet<partitions>)
859 -> decltype(entities(gv,Codim<0>(),PartitionSet<partitions>()))
860 {
861 return entities(gv,Codim<0>(),PartitionSet<partitions>());
862 }
863
864 template<typename GV>
865 inline auto elements(const GV& gv)
866 -> decltype(entities(gv,Codim<0>()))
867 {
868 return entities(gv,Codim<0>());
869 }
870
871 template<typename GV, unsigned int partitions>
872 inline auto facets(const GV& gv, PartitionSet<partitions>)
873 -> decltype(entities(gv,Codim<1>(),PartitionSet<partitions>()))
874 {
875 return entities(gv,Codim<1>(),PartitionSet<partitions>());
876 }
877
878 template<typename GV>
879 inline auto facets(const GV& gv)
880 -> decltype(entities(gv,Codim<1>()))
881 {
882 return entities(gv,Codim<1>());
883 }
884
885 template<typename GV, unsigned int partitions>
886 inline auto edges(const GV& gv, PartitionSet<partitions>)
887 -> decltype(entities(gv,Dim<1>(),PartitionSet<partitions>()))
888 {
889 return entities(gv,Dim<1>(),PartitionSet<partitions>());
890 }
891
892 template<typename GV>
893 inline auto edges(const GV& gv)
894 -> decltype(entities(gv,Dim<1>()))
895 {
896 return entities(gv,Dim<1>());
897 }
898
899 template<typename GV, unsigned int partitions>
900 inline auto vertices(const GV& gv, PartitionSet<partitions>)
901 -> decltype(entities(gv,Dim<0>(),PartitionSet<partitions>()))
902 {
903 return entities(gv,Dim<0>(),PartitionSet<partitions>());
904 }
905
906 template<typename GV>
907 inline auto vertices(const GV& gv)
908 -> decltype(entities(gv,Dim<0>()))
909 {
910 return entities(gv,Dim<0>());
911 }
912
913#endif // HAVE_RANGE_BASED_FOR
914
915#endif // DOXYGEN
916
921} // namespace Dune
922
923#endif // DUNE_GRID_COMMON_RANGEGENERATORS_HH
Wrapper class for entities.
Definition: entity.hh:62
Simple range between a begin and an end iterator.
Definition: iteratorrange.hh:19
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<... > 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<... > 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 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<... > 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.
PartitionIteratorType
Parameter to be used for the parallel level- and leaf iterators.
Definition: gridenums.hh:134
Dune namespace.
Definition: alignment.hh:10
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:95
A set of PartitionType values.
Definition: partitionset.hh:97
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 20, 23:31, 2024)