dune-grid 2.8.0
Loading...
Searching...
No Matches
geometrygrid/indexsets.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_GEOGRID_INDEXSETS_HH
4#define DUNE_GEOGRID_INDEXSETS_HH
5
6#include <vector>
7
8#include <dune/common/typetraits.hh>
9
12
14
15namespace Dune
16{
17
18 namespace GeoGrid
19 {
20
21 // IndexSet
22 // --------
23
24 template< class Grid, class HostIndexSet >
26 : public Dune::IndexSet< Grid, IndexSet< Grid, HostIndexSet >, typename HostIndexSet::IndexType, typename HostIndexSet::Types >
27 {
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
Provides base classes for index and id sets.
Include standard header files.
Definition: agrid.hh:58
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
DUNE-conform implementation of the entity.
Definition: geometrygrid/entity.hh:692
Definition: geometrygrid/indexsets.hh:27
std::size_t size(GeometryType type) const
Definition: geometrygrid/indexsets.hh:70
IndexSet & operator=(const This &)=delete
Types types(int codim) const
Definition: geometrygrid/indexsets.hh:86
IndexSet(const This &)=delete
void reset(const HostIndexSet &hostIndexSet)
Definition: geometrygrid/indexsets.hh:96
void reset()
Definition: geometrygrid/indexsets.hh:95
static const int dimension
Definition: geometrygrid/indexsets.hh:36
const std::vector< GeometryType > & geomTypes(int codim) const
Definition: geometrygrid/indexsets.hh:88
IndexType subIndex(const typename Traits::template Codim< cc >::Entity &entity, int i, unsigned int codim) const
Definition: geometrygrid/indexsets.hh:65
IndexSet(This &&)=delete
bool contains(const Entity &entity) const
Definition: geometrygrid/indexsets.hh:81
IndexSet(const HostIndexSet &hostIndexSet)
Definition: geometrygrid/indexsets.hh:44
Base::Types Types
Definition: geometrygrid/indexsets.hh:40
std::size_t size(int codim) const
Definition: geometrygrid/indexsets.hh:75
Base::IndexType IndexType
Definition: geometrygrid/indexsets.hh:38
IndexType index(const typename Traits::template Codim< cc >::Entity &entity) const
Definition: geometrygrid/indexsets.hh:59