dune-grid  2.4
rangegenerators.hh
Go to the documentation of this file.
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>
10 
11 namespace Dune
12 {
13 
14 #ifdef DOXYGEN
15 
184  // *****************************************************************************************
185  // Doxygen documentation
186  // *****************************************************************************************
187  //
188  // In the following, the range generating functions are documented for Doxygen; the actual
189  // implementations are further down in this file and hidden from Doxygen.
190  // The main reason for this split are the return types of those functions, which either contain
191  // long type listings to obtain the iterator type or (in the case of the forwarded functions
192  // use the new-style function syntax and calculate the return type using decltype. In both cases,
193  // Doxygen generates function signatures that are very confusing to the average user.
194  //
195  // *****************************************************************************************
196 
197 
198 
202 
203 
205 
235  template<typename GV>
236  inline IteratorRange<...> elements(const GV& gv);
237 
238 
240 
270  template<typename GV>
271  inline IteratorRange<...> facets(const GV& gv);
272 
273 
275 
305  template<typename GV>
306  inline IteratorRange<...> edges(const GV& gv);
307 
308 
310 
340  template<typename GV>
341  inline IteratorRange<...> vertices(const GV& gv);
342 
343 
345 
346 
347 
351 
353 
377  template<typename GV, typename Entity>
378  inline IteratorRange<...> intersections(const GV& gv, const Entity& e);
379 
380 
382 
383 
384 
388 
389 
391 
418  template<typename Entity>
419  inline IteratorRange<...> descendantElements(const Entity& e, int maxLevel);
420  // Entity<int dim, class GridImp, template<int,int,class> class EntityImp>
421 
423 
424 
425 
429 
430 
432 
471  template<typename GV, int codim>
472  inline IteratorRange<...> entities(const GV& gv, Codim<codim> cd);
473 
474 
476 
517  template<typename GV, int dim>
518  inline IteratorRange<...> entities(const GV& gv, Dim<dim> d);
519 
521 
522 
523 
527 
528 
530 
557  template<typename GV, unsigned int partitions>
558  inline IteratorRange<...> elements(const GV& gv, PartitionSet<partitions> ps);
559 
560 
562 
592  template<typename GV, unsigned int partitions>
593  inline IteratorRange<...> facets(const GV& gv, PartitionSet<partitions> ps);
594 
595 
597 
624  template<typename GV, unsigned int partitions>
625  inline IteratorRange<...> edges(const GV& gv, PartitionSet<partitions> ps);
626 
627 
629 
656  template<typename GV, unsigned int partitions>
657  inline IteratorRange<...> vertices(const GV& gv, PartitionSet<partitions> ps);
658 
660 
661 
662 
666 
667 
669 
706  template<typename GV, int codim, unsigned int partitions>
707  inline IteratorRange<...> entities(const GV& gv gv, Codim<codim> cd, PartitionSet<partitions> ps);
708 
709 
711 
748  template<typename GV, int dim, unsigned int partitions>
749  inline IteratorRange<...> entities(const GV& gv, Dim<dim> d, PartitionSet<partitions> ps);
750 
751 
753 
754 
755 #else // DOXYGEN
756 
757 // only make the implementations available on new compilers - there is a really nasty bug in GCC 4.4...
758 #if HAVE_RANGE_BASED_FOR
759 
760  // ******************************************************************************************
761  // Implementations
762  // ******************************************************************************************
763 
764 
774  template<typename GV, int codim, unsigned int partitions>
775  inline IteratorRange<
776  typename GV::template Codim<codim>::template Partition<
777  derive_partition_iterator_type<partitions>::value
778  >::Iterator
779  >
780  entities(const GV& gv, Codim<codim>, PartitionSet<partitions>)
781  {
782  static_assert(0 <= codim && codim <= GV::dimension, "invalid codimension for given GridView");
783  const PartitionIteratorType pit = derive_partition_iterator_type<partitions>::value;
784  typedef IteratorRange<
785  typename GV::template Codim<codim>::template Partition<pit>::Iterator
786  > return_type;
787  return return_type(gv.template begin<codim,pit>(),gv.template end<codim,pit>());
788  }
789 
797  template<typename GV, int codim>
798  inline IteratorRange<
799  typename GV::template Codim<codim>::Iterator
800  >
801  entities(const GV& gv, Codim<codim>)
802  {
803  static_assert(0 <= codim && codim <= GV::dimension, "invalid codimension for given GridView");
804  typedef IteratorRange<
805  typename GV::template Codim<codim>::Iterator
806  > return_type;
807  return return_type(gv.template begin<codim>(),gv.template end<codim>());
808  }
809 
813  template<typename Entity>
814  inline IteratorRange<typename Entity::HierarchicIterator> descendantElements(const Entity& e, int maxLevel)
815  {
816  typedef IteratorRange<typename Entity::HierarchicIterator> return_type;
817  return return_type(e.hbegin(maxLevel),e.hend(maxLevel));
818  }
819 
823  template<typename GV, typename Entity>
824  inline IteratorRange<typename GV::IntersectionIterator> intersections(const GV& gv, const Entity& e)
825  {
826  return IteratorRange<typename GV::IntersectionIterator>(gv.ibegin(e),gv.iend(e));
827  }
828 
829 
835  template<typename GV, int dim, unsigned int partitions>
836  inline auto entities(const GV& gv, Dim<dim>, PartitionSet<partitions>)
837  -> decltype(entities(gv,Codim<GV::dimension - dim>(),PartitionSet<partitions>()))
838  {
839  static_assert(0 <= dim && dim <= GV::dimension, "invalid dimension for given GridView");
840  return entities(gv,Codim<GV::dimension - dim>(),PartitionSet<partitions>());
841  }
842 
843  template<typename GV, int dim>
844  inline auto entities(const GV& gv, Dim<dim>)
845  -> decltype(entities(gv,Codim<GV::dimension - dim>()))
846  {
847  static_assert(0 <= dim && dim <= GV::dimension, "invalid dimension for given GridView");
848  return entities(gv,Codim<GV::dimension - dim>());
849  }
850 
851  template<typename GV, unsigned int partitions>
852  inline auto elements(const GV& gv, PartitionSet<partitions>)
853  -> decltype(entities(gv,Codim<0>(),PartitionSet<partitions>()))
854  {
855  return entities(gv,Codim<0>(),PartitionSet<partitions>());
856  }
857 
858  template<typename GV>
859  inline auto elements(const GV& gv)
860  -> decltype(entities(gv,Codim<0>()))
861  {
862  return entities(gv,Codim<0>());
863  }
864 
865  template<typename GV, unsigned int partitions>
866  inline auto facets(const GV& gv, PartitionSet<partitions>)
867  -> decltype(entities(gv,Codim<1>(),PartitionSet<partitions>()))
868  {
869  return entities(gv,Codim<1>(),PartitionSet<partitions>());
870  }
871 
872  template<typename GV>
873  inline auto facets(const GV& gv)
874  -> decltype(entities(gv,Codim<1>()))
875  {
876  return entities(gv,Codim<1>());
877  }
878 
879  template<typename GV, unsigned int partitions>
880  inline auto edges(const GV& gv, PartitionSet<partitions>)
881  -> decltype(entities(gv,Dim<1>(),PartitionSet<partitions>()))
882  {
883  return entities(gv,Dim<1>(),PartitionSet<partitions>());
884  }
885 
886  template<typename GV>
887  inline auto edges(const GV& gv)
888  -> decltype(entities(gv,Dim<1>()))
889  {
890  return entities(gv,Dim<1>());
891  }
892 
893  template<typename GV, unsigned int partitions>
894  inline auto vertices(const GV& gv, PartitionSet<partitions>)
895  -> decltype(entities(gv,Dim<0>(),PartitionSet<partitions>()))
896  {
897  return entities(gv,Dim<0>(),PartitionSet<partitions>());
898  }
899 
900  template<typename GV>
901  inline auto vertices(const GV& gv)
902  -> decltype(entities(gv,Dim<0>()))
903  {
904  return entities(gv,Dim<0>());
905  }
906 
907 #endif // HAVE_RANGE_BASED_FOR
908 
909 #endif // DOXYGEN
910 
915 } // namespace Dune
916 
917 #endif // DUNE_GRID_COMMON_RANGEGENERATORS_HH
Include standard header files.
Definition: agrid.hh:59
PartitionIteratorType
Parameter to be used for the parallel level- and leaf iterators.
Definition: gridenums.hh:134