dune-fem  2.4.1-rc
geogridpart/iterator.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_ITERATOR_HH
2 #define DUNE_FEM_GRIDPART_GEOGRIDPART_ITERATOR_HH
3 
4 #include <cassert>
5 
6 #include <type_traits>
7 #include <utility>
8 
9 #include <dune/grid/common/entitypointer.hh>
10 #include <dune/grid/common/gridenums.hh>
11 
12 namespace Dune
13 {
14 
15  namespace Fem
16  {
17 
18  // GeoIterator
19  // -----------
20 
21  template< int codim, PartitionIteratorType pitype, class GridFamily >
23  {
24  typedef typename std::remove_const< GridFamily >::type::Traits Traits;
25 
26  typedef typename Traits::HostGridPartType HostGridPartType;
27 
28  public:
29  typedef typename Traits::CoordFunctionType CoordFunctionType;
30  typedef typename HostGridPartType::template Codim< codim >::template Partition< pitype >::IteratorType HostIteratorType;
31 
32  static const int codimension = HostIteratorType::codimension;
33 
34  typedef typename Traits::template Codim< codimension >::Entity Entity;
35 
36  GeoIterator () = default;
37 
38  GeoIterator ( const CoordFunctionType &coordFunction, HostIteratorType hostIterator )
39  : coordFunction_( &coordFunction ),
40  hostIterator_( std::move( hostIterator ) )
41  {}
42 
43  void increment ()
44  {
45  ++hostIterator_;
46  }
47 
48  Entity dereference () const
49  {
50  return typename Entity::Implementation( coordFunction(), *hostIterator_ );
51  }
52 
53  bool equals ( const GeoIterator &rhs ) const
54  {
55  return hostIterator_ == rhs.hostIterator_;
56  }
57 
58  int level () const
59  {
60  return hostIterator_.level();
61  }
62 
63  operator Dune::DefaultEntityPointer< Entity > () const
64  {
65  return Dune::DefaultEntityPointer< Entity >( dereference() );
66  }
67 
68  bool equals ( const Dune::DefaultEntityPointer< Entity > &rhs ) const
69  {
70  return dereference() == rhs.dereference();
71  }
72 
73  private:
74  const CoordFunctionType &coordFunction () const
75  {
76  assert( coordFunction_ );
77  return *coordFunction_;
78  }
79 
80  const CoordFunctionType *coordFunction_ = nullptr;
81  HostIteratorType hostIterator_;
82  };
83 
84  } // namespace Fem
85 
86 } // namespace Dune
87 
88 #endif // #ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_ITERATOR_HH
static const int codimension
Definition: geogridpart/iterator.hh:32
GeoIterator(const CoordFunctionType &coordFunction, HostIteratorType hostIterator)
Definition: geogridpart/iterator.hh:38
Definition: geogridpart/iterator.hh:22
Definition: coordinate.hh:4
Traits::CoordFunctionType CoordFunctionType
Definition: geogridpart/iterator.hh:29
Traits::template Codim< codimension >::Entity Entity
Definition: geogridpart/iterator.hh:34
STL namespace.
bool equals(const GeoIterator &rhs) const
Definition: geogridpart/iterator.hh:53
void increment()
Definition: geogridpart/iterator.hh:43
bool equals(const Dune::DefaultEntityPointer< Entity > &rhs) const
Definition: geogridpart/iterator.hh:68
void move(ArrayInterface< T > &array, const unsigned int oldOffset, const unsigned int newOffset, const unsigned int length)
Definition: array_inline.hh:38
int level() const
Definition: geogridpart/iterator.hh:58
HostGridPartType::template Codim< codim >::template Partition< pitype >::IteratorType HostIteratorType
Definition: geogridpart/iterator.hh:30
Entity dereference() const
Definition: geogridpart/iterator.hh:48