dune-grid  2.9.0
idset.hh
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 // vi: set et ts=4 sw=2 sts=2:
5 #ifndef DUNE_GEOGRID_IDSET_HH
6 #define DUNE_GEOGRID_IDSET_HH
7 
9 
10 namespace Dune
11 {
12 
13  namespace GeoGrid
14  {
15 
16  // IdSet
17  // -----
18 
19  template< class Grid, class HostIdSet >
20  class IdSet
21  : public Dune::IdSet< Grid, IdSet< Grid, HostIdSet >, typename HostIdSet::IdType >
22  {
25 
26  typedef typename std::remove_const< Grid >::type::Traits Traits;
27 
28  public:
29  typedef typename HostIdSet::IdType IdType;
30 
31  using Base::subId;
32 
33  IdSet ()
34  : hostIdSet_( 0 )
35  {}
36 
37  explicit IdSet ( const HostIdSet &hostIdSet )
38  : hostIdSet_( &hostIdSet )
39  {}
40 
41  IdSet ( const This &other )
42  : hostIdSet_( other.hostIdSet_ )
43  {}
44 
45  const This &operator= ( const This &other )
46  {
47  hostIdSet_ = other.hostIdSet_;
48  return *this;
49  }
50 
51  template< int codim >
52  IdType id ( const typename Traits::template Codim< codim >::Entity &entity ) const
53  {
54  return entity.impl().id( hostIdSet() );
55  }
56 
57  template< class Entity >
58  IdType id ( const Entity &entity ) const
59  {
60  return id< Entity::codimension >( entity );
61  }
62 
63  IdType subId ( const typename Traits::template Codim< 0 >::Entity &entity, int i, unsigned int codim ) const
64  {
65  return hostIdSet().subId( Grid::template getHostEntity< 0 >( entity ), i, codim );
66  }
67 
68  explicit operator bool () const { return bool( hostIdSet_ ); }
69 
70  private:
71  const HostIdSet &hostIdSet () const
72  {
73  assert( *this );
74  return *hostIdSet_;
75  }
76 
77  const HostIdSet *hostIdSet_;
78  };
79 
80  } // namespace GeoGrid
81 
82 } // namespace Dune
83 
84 #endif // #ifndef DUNE_GEOGRID_IDSET_HH
Provides base classes for index and id sets.
Include standard header files.
Definition: agrid.hh:60
Id Set Interface.
Definition: indexidset.hh:452
IdType subId(const typename Codim< 0 >::Entity &e, int i, unsigned int codim) const
Get id of subentity i of co-dimension codim of a co-dimension 0 entity.
Definition: indexidset.hh:486
DUNE-conform implementation of the entity.
Definition: geometrygrid/entity.hh:34
Definition: idset.hh:22
IdSet()
Definition: idset.hh:33
IdSet(const HostIdSet &hostIdSet)
Definition: idset.hh:37
IdType id(const Entity &entity) const
Definition: idset.hh:58
IdType subId(const typename Traits::template Codim< 0 >::Entity &entity, int i, unsigned int codim) const
Definition: idset.hh:63
IdType id(const typename Traits::template Codim< codim >::Entity &entity) const
Definition: idset.hh:52
IdSet(const This &other)
Definition: idset.hh:41
const This & operator=(const This &other)
Definition: idset.hh:45
HostIdSet::IdType IdType
Definition: idset.hh:29