DUNE PDELab (2.8)

indexsets.hh
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_GEOGRID_INDEXSETS_HH
4#define DUNE_GEOGRID_INDEXSETS_HH
5
6#include <vector>
7
9
10#include <dune/grid/common/gridenums.hh>
12
13#include <dune/grid/geometrygrid/declaration.hh>
14
15namespace Dune
16{
17
18 namespace GeoGrid
19 {
20
21 // IndexSet
22 // --------
23
24 template< class Grid, class HostIndexSet >
25 class IndexSet
26 : public Dune::IndexSet< Grid, IndexSet< Grid, HostIndexSet >, typename HostIndexSet::IndexType, typename HostIndexSet::Types >
27 {
28 typedef IndexSet< Grid, HostIndexSet > This;
30
31 typedef typename std::remove_const< Grid >::type::Traits Traits;
32
33 typedef typename Traits::HostGrid HostGrid;
34
35 public:
36 static const int dimension = Traits::dimension;
37
38 typedef typename Base::IndexType IndexType;
39
40 typedef typename Base::Types Types;
41
42 IndexSet () = default;
43
44 explicit IndexSet ( const HostIndexSet &hostIndexSet )
45 : hostIndexSet_( &hostIndexSet )
46 {}
47
48 // The index set contains a pointer to the host index set, so copying or assigning this can be dangerous.
49 IndexSet ( const This & ) = delete;
50 IndexSet ( This && ) = delete;
51
52 IndexSet &operator= ( const This & ) = delete;
53 IndexSet &operator= ( This && ) = delete;
54
55 using Base::index;
56 using Base::subIndex;
57
58 template< int cc >
59 IndexType index ( const typename Traits::template Codim< cc >::Entity &entity ) const
60 {
61 return entity.impl().index( hostIndexSet() );
62 }
63
64 template< int cc >
65 IndexType subIndex ( const typename Traits::template Codim< cc >::Entity &entity, int i, unsigned int codim ) const
66 {
67 return entity.impl().subIndex( hostIndexSet(), i, codim );
68 }
69
70 std::size_t size ( GeometryType type ) const
71 {
72 return hostIndexSet().size( type );
73 }
74
75 std::size_t size ( int codim ) const
76 {
77 return hostIndexSet().size( codim );
78 }
79
80 template< class Entity >
81 bool contains ( const Entity &entity ) const
82 {
83 return entity.impl().isContained( hostIndexSet() );
84 }
85
86 Types types ( int codim ) const { return hostIndexSet().types( codim ); }
87
88 const std::vector< GeometryType > &geomTypes ( int codim ) const
89 {
90 return hostIndexSet().geomTypes( codim );
91 }
92
93 explicit operator bool () const { return bool( hostIndexSet_ ); }
94
95 void reset () { hostIndexSet_ = nullptr; }
96 void reset ( const HostIndexSet &hostIndexSet ) { hostIndexSet_ = &hostIndexSet; }
97
98 private:
99 const HostIndexSet &hostIndexSet () const
100 {
101 assert( *this );
102 return *hostIndexSet_;
103 }
104
105 const HostIndexSet *hostIndexSet_ = nullptr;
106 };
107
108 } // namespace GeoGrid
109
110} // namespace Dune
111
112#endif // #ifndef DUNE_GEOGRID_INDEXSETS_HH
Index Set Interface base class.
Definition: indexidset.hh:76
IndexType subIndex(const typename Traits::template Codim< cc >::Entity &e, int i, unsigned int codim) const
Map a subentity to an index.
Definition: indexidset.hh:151
TypesImp Types
iterator range for geometry types in domain
Definition: indexidset.hh:93
IndexType index(const typename Traits::template Codim< cc >::Entity &e) const
Map entity to index. The result of calling this method with an entity that is not in the index set is...
Definition: indexidset.hh:111
IndexTypeImp IndexType
The type used for the indices.
Definition: indexidset.hh:90
bool contains(const Entity &e) const
Return true if the given entity is contained in .
Definition: indexidset.hh:246
Traits for type conversions and type information.
Provides base classes for index and id sets.
Dune namespace.
Definition: alignedallocator.hh:11
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 22, 23:30, 2024)