Dune Core Modules (2.8.0)

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>
8#include <dune/geometry/dimension.hh>
9#include <dune/grid/common/gridenums.hh>
10#include <dune/grid/common/partitionset.hh>
11
12namespace Dune
13{
14
15#ifdef DOXYGEN
16
204 // *****************************************************************************************
205 // Doxygen documentation
206 // *****************************************************************************************
207 //
208 // In the following, the range generating functions are documented for Doxygen; the actual
209 // implementations are further down in this file and hidden from Doxygen.
210 // The main reason for this split are the return types of those functions, which either contain
211 // long type listings to obtain the iterator type or (in the case of the forwarded functions
212 // use the new-style function syntax and calculate the return type using decltype. In both cases,
213 // Doxygen generates function signatures that are very confusing to the average user.
214 //
215 // *****************************************************************************************
216
217
218
222
223
225
254 template<typename GV>
255 inline IteratorRange<...> elements(const GV& gv);
256
257
259
288 template<typename GV>
289 inline IteratorRange<...> facets(const GV& gv);
290
291
293
322 template<typename GV>
323 inline IteratorRange<...> edges(const GV& gv);
324
325
327
356 template<typename GV>
357 inline IteratorRange<...> vertices(const GV& gv);
358
359
361
362
363
367
369
392 template<typename GV, typename Entity>
393 inline IteratorRange<...> intersections(const GV& gv, const Entity& e);
394
395
397
398
399
403
404
406
432 template<typename Entity>
433 inline IteratorRange<...> descendantElements(const Entity& e, int maxLevel);
434 // Entity<int dim, class GridImp, template<int,int,class> class EntityImp>
435
437
438
439
443
444
446
484 template<typename GV, int codim>
485 inline IteratorRange<...> entities(const GV& gv, Codim<codim> cd);
486
487
489
529 template<typename GV, int dim>
530 inline IteratorRange<...> entities(const GV& gv, Dim<dim> d);
531
533
534
535
539
540
542
568 template<typename GV, unsigned int partitions>
569 inline IteratorRange<...> elements(const GV& gv, PartitionSet<partitions> ps);
570
571
573
602 template<typename GV, unsigned int partitions>
603 inline IteratorRange<...> facets(const GV& gv, PartitionSet<partitions> ps);
604
605
607
633 template<typename GV, unsigned int partitions>
634 inline IteratorRange<...> edges(const GV& gv, PartitionSet<partitions> ps);
635
636
638
664 template<typename GV, unsigned int partitions>
665 inline IteratorRange<...> vertices(const GV& gv, PartitionSet<partitions> ps);
666
668
669
670
674
675
677
713 template<typename GV, int codim, unsigned int partitions>
715
716
718
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
780 template<typename E, int codim>
781 inline IteratorRange<...> subEntities(const E& e, Codim<codim> c);
782
783
785
786
787#else // DOXYGEN
788
789 // ******************************************************************************************
790 // Implementations
791 // ******************************************************************************************
792
793
803 template<typename GV, int codim, unsigned int partitions>
804 inline auto entities(const GV& gv, Codim<codim>, PartitionSet<partitions>)
805 -> IteratorRange<decltype(gv.template begin<codim,derive_partition_iterator_type<partitions>::value>())>
806 {
807 static_assert(0 <= codim && codim <= GV::dimension, "invalid codimension for given GridView");
808 const PartitionIteratorType pit = derive_partition_iterator_type<partitions>::value;
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>());
811 }
812
820 template<typename GV, int codim>
821 inline auto entities(const GV& gv, Codim<codim>)
822 -> IteratorRange<decltype(gv.template begin<codim>())>
823 {
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>());
827 }
828
832 template<typename Entity>
833 inline IteratorRange<typename Entity::HierarchicIterator> descendantElements(const Entity& e, int maxLevel)
834 {
835 typedef IteratorRange<typename Entity::HierarchicIterator> return_type;
836 return return_type(e.hbegin(maxLevel),e.hend(maxLevel));
837 }
838
842 template<typename GV, typename Entity>
843 inline auto intersections(const GV& gv, const Entity& e)
844 -> IteratorRange<decltype(gv.ibegin(e))>
845 {
846 return IteratorRange<decltype(gv.ibegin(e))>(gv.ibegin(e),gv.iend(e));
847 }
848
849
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>()))
858 {
859 static_assert(0 <= dim && dim <= GV::dimension, "invalid dimension for given GridView");
860 return entities(gv,Codim<GV::dimension - dim>(),PartitionSet<partitions>());
861 }
862
863 template<typename GV, int dim>
864 inline auto entities(const GV& gv, Dim<dim>)
865 -> decltype(entities(gv,Codim<GV::dimension - dim>()))
866 {
867 static_assert(0 <= dim && dim <= GV::dimension, "invalid dimension for given GridView");
868 return entities(gv,Codim<GV::dimension - dim>());
869 }
870
871 template<typename GV, unsigned int partitions>
872 inline auto elements(const GV& gv, PartitionSet<partitions>)
873 -> decltype(entities(gv,Codim<0>(),PartitionSet<partitions>()))
874 {
875 return entities(gv,Codim<0>(),PartitionSet<partitions>());
876 }
877
878 template<typename GV>
879 inline auto elements(const GV& gv)
880 -> decltype(entities(gv,Codim<0>()))
881 {
882 return entities(gv,Codim<0>());
883 }
884
885 template<typename GV, unsigned int partitions>
886 inline auto facets(const GV& gv, PartitionSet<partitions>)
887 -> decltype(entities(gv,Codim<1>(),PartitionSet<partitions>()))
888 {
889 return entities(gv,Codim<1>(),PartitionSet<partitions>());
890 }
891
892 template<typename GV>
893 inline auto facets(const GV& gv)
894 -> decltype(entities(gv,Codim<1>()))
895 {
896 return entities(gv,Codim<1>());
897 }
898
899 template<typename GV, unsigned int partitions>
900 inline auto edges(const GV& gv, PartitionSet<partitions>)
901 -> decltype(entities(gv,Dim<1>(),PartitionSet<partitions>()))
902 {
903 return entities(gv,Dim<1>(),PartitionSet<partitions>());
904 }
905
906 template<typename GV>
907 inline auto edges(const GV& gv)
908 -> decltype(entities(gv,Dim<1>()))
909 {
910 return entities(gv,Dim<1>());
911 }
912
913 template<typename GV, unsigned int partitions>
914 inline auto vertices(const GV& gv, PartitionSet<partitions>)
915 -> decltype(entities(gv,Dim<0>(),PartitionSet<partitions>()))
916 {
917 return entities(gv,Dim<0>(),PartitionSet<partitions>());
918 }
919
920 template<typename GV>
921 inline auto vertices(const GV& gv)
922 -> decltype(entities(gv,Dim<0>()))
923 {
924 return entities(gv,Dim<0>());
925 }
926
927 template<typename E, int codim>
928 inline auto subEntities(const E& e, Codim<codim> c)
929 {
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); }
935 );
936 }
937
938#endif // DOXYGEN
939
944} // namespace Dune
945
946#endif // DUNE_GRID_COMMON_RANGEGENERATORS_HH
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.
PartitionIteratorType
Parameter to be used for the parallel level- and leaf iterators.
Definition: gridenums.hh:134
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
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)