DUNE-FEM (unstable)

intersectioniterator.hh
1#ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_INTERSECTIONITERATOR_HH
2#define DUNE_FEM_GRIDPART_GEOGRIDPART_INTERSECTIONITERATOR_HH
3
4#include <type_traits>
5#include <utility>
6#include <optional>
7
8#include <dune/grid/common/intersectioniterator.hh>
9
10#include <dune/fem/gridpart/geogridpart/intersection.hh>
11
12namespace Dune
13{
14
15 namespace Fem
16 {
17
18 // GeoIntersectionIterator
19 // -----------------------
20
21 template< class GridFamily >
22 class GeoIntersectionIterator
23 {
24 typedef GeoIntersectionIterator< GridFamily > ThisType;
25
26 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
27
28 typedef typename Traits::CoordFunctionType CoordFunctionType;
29 typedef typename Traits::template Codim< 0 >::Geometry ElementGeometryType;
30 typedef typename Traits::HostGridPartType::IntersectionIteratorType HostIntersectionIteratorType;
31
32 typedef GeoIntersection< const GridFamily > IntersectionImplType;
33
34 public:
36
37 template< class Entity >
38 GeoIntersectionIterator ( const Entity &inside,
39 HostIntersectionIteratorType hostIterator )
40 : coordFunction_( &inside.impl().coordFunction() ),
41 insideGeo_( inside.geometry() ),
42 hostIterator_( std::move( hostIterator ) )
43 {}
44
45 GeoIntersectionIterator ( const GeoIntersectionIterator& other )
46 : coordFunction_( &other.coordFunction() ),
47 insideGeo_( other.insideGeo_ ),
48 hostIterator_( other.hostIterator_ )
49 {}
50
51 GeoIntersectionIterator ( )
52 : coordFunction_( nullptr ),
53 hostIterator_()
54 {}
55
56 GeoIntersectionIterator& operator= ( const GeoIntersectionIterator& other )
57 {
58 coordFunction_ = other.coordFunction_;
59 insideGeo_.reset();
60 insideGeo_.emplace( *other.insideGeo_ );
61 hostIterator_ = other.hostIterator_ ;
62 return *this;
63 }
64
65 bool equals ( const ThisType &other ) const
66 {
67 return hostIterator_ == other.hostIterator_;
68 }
69
70 void increment ()
71 {
72 ++hostIterator_;
73 }
74
75 Intersection dereference () const
76 {
77 assert( insideGeo_ );
78 return IntersectionImplType( coordFunction(), *insideGeo_, *hostIterator_ );
79 }
80
81 const CoordFunctionType &coordFunction () const
82 {
83 assert( coordFunction_ );
84 return *coordFunction_;
85 }
86
87 private:
88 const CoordFunctionType *coordFunction_ = nullptr;
89 std::optional< ElementGeometryType > insideGeo_;
90 HostIntersectionIteratorType hostIterator_;
91 };
92
93 } // namespace Fem
94
95} // namespace Dune
96
97#endif // #ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_INTERSECTIONITERATOR_HH
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: intersection.hh:164
constexpr auto equals(T1 &&t1, T2 &&t2)
Equality comparison.
Definition: hybridutilities.hh:587
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)