Dune Core Modules (2.9.0)

rangegenerators.hh
1// SPDX-FileCopyrightText: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_GRID_COMMON_RANGEGENERATORS_HH
6#define DUNE_GRID_COMMON_RANGEGENERATORS_HH
7
8#include <dune/common/iteratorrange.hh>
10#include <dune/geometry/dimension.hh>
11#include <dune/grid/common/gridenums.hh>
12#include <dune/grid/common/partitionset.hh>
13
14namespace Dune
15{
16
17#ifdef DOXYGEN
18
206 // *****************************************************************************************
207 // Doxygen documentation
208 // *****************************************************************************************
209 //
210 // In the following, the range generating functions are documented for Doxygen; the actual
211 // implementations are further down in this file and hidden from Doxygen.
212 // The main reason for this split are the return types of those functions, which either contain
213 // long type listings to obtain the iterator type or (in the case of the forwarded functions
214 // use the new-style function syntax and calculate the return type using decltype. In both cases,
215 // Doxygen generates function signatures that are very confusing to the average user.
216 //
217 // *****************************************************************************************
218
219
220
224
225
227
256 template<typename GV>
257 inline IteratorRange<...> elements(const GV& gv);
258
259
261
290 template<typename GV>
291 inline IteratorRange<...> facets(const GV& gv);
292
293
295
324 template<typename GV>
325 inline IteratorRange<...> edges(const GV& gv);
326
327
329
358 template<typename GV>
359 inline IteratorRange<...> vertices(const GV& gv);
360
361
363
364
365
369
371
394 template<typename GV, typename Entity>
395 inline IteratorRange<...> intersections(const GV& gv, const Entity& e);
396
397
399
400
401
405
406
408
434 template<typename Entity>
435 inline IteratorRange<...> descendantElements(const Entity& e, int maxLevel);
436 // Entity<int dim, class GridImp, template<int,int,class> class EntityImp>
437
439
440
441
445
446
448
486 template<typename GV, int codim>
487 inline IteratorRange<...> entities(const GV& gv, Codim<codim> cd);
488
489
491
531 template<typename GV, int dim>
532 inline IteratorRange<...> entities(const GV& gv, Dim<dim> d);
533
535
536
537
541
542
544
570 template<typename GV, unsigned int partitions>
571 inline IteratorRange<...> elements(const GV& gv, PartitionSet<partitions> ps);
572
573
575
604 template<typename GV, unsigned int partitions>
605 inline IteratorRange<...> facets(const GV& gv, PartitionSet<partitions> ps);
606
607
609
635 template<typename GV, unsigned int partitions>
636 inline IteratorRange<...> edges(const GV& gv, PartitionSet<partitions> ps);
637
638
640
666 template<typename GV, unsigned int partitions>
667 inline IteratorRange<...> vertices(const GV& gv, PartitionSet<partitions> ps);
668
670
671
672
676
677
679
715 template<typename GV, int codim, unsigned int partitions>
717
718
720
756 template<typename GV, int dim, unsigned int partitions>
757 inline IteratorRange<...> entities(const GV& gv, Dim<dim> d, PartitionSet<partitions> ps);
758
759
761
782 template<typename E, int codim>
783 inline IteratorRange<...> subEntities(const E& e, Codim<codim> c);
784
785
787
788
789#else // DOXYGEN
790
791 // ******************************************************************************************
792 // Implementations
793 // ******************************************************************************************
794
795
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>())>
808 {
809 static_assert(0 <= codim && codim <= GV::dimension, "invalid codimension for given GridView");
810 const PartitionIteratorType pit = derive_partition_iterator_type<partitions>::value;
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>());
813 }
814
822 template<typename GV, int codim>
823 inline auto entities(const GV& gv, Codim<codim>)
824 -> IteratorRange<decltype(gv.template begin<codim>())>
825 {
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>());
829 }
830
834 template<typename Entity>
835 inline IteratorRange<typename Entity::HierarchicIterator> descendantElements(const Entity& e, int maxLevel)
836 {
837 typedef IteratorRange<typename Entity::HierarchicIterator> return_type;
838 return return_type(e.hbegin(maxLevel),e.hend(maxLevel));
839 }
840
844 template<typename GV, typename Entity>
845 inline auto intersections(const GV& gv, const Entity& e)
846 -> IteratorRange<decltype(gv.ibegin(e))>
847 {
848 return IteratorRange<decltype(gv.ibegin(e))>(gv.ibegin(e),gv.iend(e));
849 }
850
851
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>()))
860 {
861 static_assert(0 <= dim && dim <= GV::dimension, "invalid dimension for given GridView");
862 return entities(gv,Codim<GV::dimension - dim>(),PartitionSet<partitions>());
863 }
864
865 template<typename GV, int dim>
866 inline auto entities(const GV& gv, Dim<dim>)
867 -> decltype(entities(gv,Codim<GV::dimension - dim>()))
868 {
869 static_assert(0 <= dim && dim <= GV::dimension, "invalid dimension for given GridView");
870 return entities(gv,Codim<GV::dimension - dim>());
871 }
872
873 template<typename GV, unsigned int partitions>
874 inline auto elements(const GV& gv, PartitionSet<partitions>)
875 -> decltype(entities(gv,Codim<0>(),PartitionSet<partitions>()))
876 {
877 return entities(gv,Codim<0>(),PartitionSet<partitions>());
878 }
879
880 template<typename GV>
881 inline auto elements(const GV& gv)
882 -> decltype(entities(gv,Codim<0>()))
883 {
884 return entities(gv,Codim<0>());
885 }
886
887 template<typename GV, unsigned int partitions>
888 inline auto facets(const GV& gv, PartitionSet<partitions>)
889 -> decltype(entities(gv,Codim<1>(),PartitionSet<partitions>()))
890 {
891 return entities(gv,Codim<1>(),PartitionSet<partitions>());
892 }
893
894 template<typename GV>
895 inline auto facets(const GV& gv)
896 -> decltype(entities(gv,Codim<1>()))
897 {
898 return entities(gv,Codim<1>());
899 }
900
901 template<typename GV, unsigned int partitions>
902 inline auto edges(const GV& gv, PartitionSet<partitions>)
903 -> decltype(entities(gv,Dim<1>(),PartitionSet<partitions>()))
904 {
905 return entities(gv,Dim<1>(),PartitionSet<partitions>());
906 }
907
908 template<typename GV>
909 inline auto edges(const GV& gv)
910 -> decltype(entities(gv,Dim<1>()))
911 {
912 return entities(gv,Dim<1>());
913 }
914
915 template<typename GV, unsigned int partitions>
916 inline auto vertices(const GV& gv, PartitionSet<partitions>)
917 -> decltype(entities(gv,Dim<0>(),PartitionSet<partitions>()))
918 {
919 return entities(gv,Dim<0>(),PartitionSet<partitions>());
920 }
921
922 template<typename GV>
923 inline auto vertices(const GV& gv)
924 -> decltype(entities(gv,Dim<0>()))
925 {
926 return entities(gv,Dim<0>());
927 }
928
929 template<typename E, int codim>
930 inline auto subEntities(const E& e, Codim<codim> c)
931 {
932 static_assert(E::codimension <= codim,
933 "Can only iterate over sub-entities with equal or larger codimension");
935 range(static_cast<int>(e.subEntities(c))),
936 [&](const int i){ return e.template subEntity<codim>(i); }
937 );
938 }
939
940#endif // DOXYGEN
941
946} // namespace Dune
947
948#endif // DUNE_GRID_COMMON_RANGEGENERATORS_HH
Wrapper class for entities.
Definition: entity.hh:66
Simple range between a begin and an end iterator.
Definition: iteratorrange.hh:22
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:136
auto transformedRangeView(R &&range, const F &f)
Create a TransformedRangeView.
Definition: rangeutilities.hh:769
Dune namespace.
Definition: alignedallocator.hh:13
Utilities for reduction like operations on ranges.
Static tag representing a codimension.
Definition: dimension.hh:24
Static tag representing a dimension.
Definition: dimension.hh:16
A struct that collects all associated types of one implementation from the Traits class.
Definition: gridview.hh:118
A set of PartitionType values.
Definition: partitionset.hh:138
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)