idset.hh 1.54 KB
Newer Older
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
1
2
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
Praetorius, Simon's avatar
Praetorius, Simon committed
3
4
#ifndef DUNE_CURVED_SURFACE_GRID_IDSET_HH
#define DUNE_CURVED_SURFACE_GRID_IDSET_HH
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
5
6
7
8
9

#include <dune/grid/common/indexidset.hh>

namespace Dune
{
Praetorius, Simon's avatar
Praetorius, Simon committed
10
  namespace CGeo
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
11
12
13
14
15
16
17
  {

    // IdSet
    // -----

    template< class Grid, class HostIdSet >
    class IdSet
Praetorius, Simon's avatar
Praetorius, Simon committed
18
        : public Dune::IdSet<Grid, IdSet<Grid, HostIdSet>, typename HostIdSet::IdType>
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
19
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
20
21
      using Self = IdSet;
      using Super = Dune::IdSet<Grid, Self, typename HostIdSet::IdType>;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
22

Praetorius, Simon's avatar
Praetorius, Simon committed
23
      using Traits = typename std::remove_const<Grid>::type::Traits;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
24
25

    public:
26
      using IdType = typename HostIdSet::IdType;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
27

Praetorius, Simon's avatar
Praetorius, Simon committed
28
29
    public:
      IdSet () = default;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
30

Praetorius, Simon's avatar
Praetorius, Simon committed
31
32
      explicit IdSet (const HostIdSet& hostIdSet)
        : hostIdSet_(&hostIdSet)
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
33
34
35
      {}

      template< int codim >
Praetorius, Simon's avatar
Praetorius, Simon committed
36
      IdType id (const typename Traits::template Codim<codim>::Entity& entity) const
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
37
      {
Praetorius, Simon's avatar
Praetorius, Simon committed
38
        return entity.impl().id(hostIdSet());
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
39
40
      }

Praetorius, Simon's avatar
Praetorius, Simon committed
41
      using Super::id;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
42

Praetorius, Simon's avatar
Praetorius, Simon committed
43
      IdType subId (const typename Traits::template Codim<0>::Entity& entity, int i, unsigned int codim) const
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
44
      {
Praetorius, Simon's avatar
Praetorius, Simon committed
45
        return hostIdSet().subId(Grid::template getHostEntity<0>(entity), i, codim);
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
46
47
      }

Praetorius, Simon's avatar
Praetorius, Simon committed
48
49
50
      using Super::subId;

      explicit operator bool () const { return bool(hostIdSet_); }
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
51
52

    private:
Praetorius, Simon's avatar
Praetorius, Simon committed
53
      const HostIdSet& hostIdSet () const
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
54
55
56
57
58
      {
        assert( *this );
        return *hostIdSet_;
      }

Praetorius, Simon's avatar
Praetorius, Simon committed
59
      const HostIdSet* hostIdSet_ = nullptr;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
60
61
    };

Praetorius, Simon's avatar
Praetorius, Simon committed
62
  } // namespace CGeo
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
63
64
} // namespace Dune

Praetorius, Simon's avatar
Praetorius, Simon committed
65
#endif // DUNE_CURVED_SURFACE_GRID_IDSET_HH