DUNE-FEM (unstable)

iterator.hh
1#ifndef DUNE_FEM_GRIDPART_FILTEREDGRIDPART_ITERATOR_HH
2#define DUNE_FEM_GRIDPART_FILTEREDGRIDPART_ITERATOR_HH
3
4//- system includes
5#include <cassert>
6
7//- dune-grid includes
8#include <dune/grid/common/gridenums.hh>
9
10namespace Dune
11{
12
13 namespace Fem
14 {
15
16 // FilteredGridPartIterator
17 // ------------------------
18
19 template< int codim, PartitionIteratorType pitype, class GridPartImp >
20 class FilteredGridPartIterator
21 {
22 typedef FilteredGridPartIterator< codim, pitype, GridPartImp > ThisType;
23
24 typedef GridPartImp GridPartType;
25 typedef typename GridPartType::HostGridPartType HostGridPartType;
26 typedef typename HostGridPartType::template Codim< codim >::template Partition< pitype >::IteratorType HostIteratorType;
27
28 public:
29 // type of entity
30 typedef typename HostIteratorType::Entity Entity;
31
32 static const int codimension = codim;
33
35 FilteredGridPartIterator ( const GridPartType &gridPart, const HostIteratorType &hostIterator )
36 : gridPart_( gridPart ),
37 hostIterator_( hostIterator ),
38 hostEnd_( gridPart.hostGridPart().template end< codim, pitype >() )
39 {
40 if( done() )
41 return;
42
43 if( !gridPart.contains( *hostIterator_ ) )
44 increment();
45 }
46
48 FilteredGridPartIterator ( const ThisType &other )
49 : gridPart_( other.gridPart_ ),
50 hostIterator_( other.hostIterator_ ),
51 hostEnd_( other.hostEnd_ )
52 {}
53
55 ThisType &operator= ( const ThisType &other )
56 {
57 assert( &gridPart_ == &other.gridPart_ );
58 hostIterator_ = other.hostIterator_;
59 hostEnd_ = other.hostEnd_;
60 return *this;
61 }
62
64 void increment ()
65 {
66 assert( !done() );
67 do { ++hostIterator_; } while ( !done() && !contains() );
68 }
69
71 int level () const { return hostIterator_.level(); }
72
74 Entity dereference () const { return *hostIterator_; }
75
77 bool equals ( const ThisType &other ) const
78 {
79 return hostIterator_ == other.hostIterator_;
80 }
81
82 private:
83 bool done () const
84 {
85 return (hostIterator_ == hostEnd_);
86 }
87
88 bool contains () const
89 {
90 assert( !done() );
91 return gridPart().contains( *hostIterator_ );
92 }
93
94 // reference to grid part
95 const GridPartType &gridPart () const { return gridPart_; }
96
97 const GridPartType &gridPart_;
98 HostIteratorType hostIterator_;
99 HostIteratorType hostEnd_;
100 };
101
102 } // namespace Fem
103
104} // namespace Dune
105
106#endif // #ifndef DUNE_FEM_GRIDPART_FILTEREDGRIDPART_ITERATOR_HH
constexpr auto equals
Function object for performing equality comparison.
Definition: hybridutilities.hh:572
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::bool_constant<((II==value)||...)> contains(std::integer_sequence< T, II... >, std::integral_constant< T, value >)
Checks whether or not a given sequence contains a value.
Definition: integersequence.hh:137
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)