My Project
entitypointer.hh
1// -*- mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=2 sw=2 sts=2:
3#ifndef DUNE_POLYHEDRALGRID_ENTITYPOINTER_HH
4#define DUNE_POLYHEDRALGRID_ENTITYPOINTER_HH
5
6//- dune-grid includes
7#include <dune/grid/common/grid.hh>
8
9//- dune-metagrid includes
10#include <opm/grid/polyhedralgrid/declaration.hh>
11
12namespace Dune
13{
14 // PolyhedralGridEntityPointer
15 // -------------------
16
17 template< int codim, class Grid >
19 {
21
22 protected:
23 typedef typename Grid::Traits Traits;
24
25 public:
27 static const int dimension = Grid::dimension;
29 static const int codimension = codim;
30
32 typedef typename Traits::template Codim< codimension >::Entity Entity;
33
34 protected:
35 typedef typename Traits::ExtraData ExtraData;
36
37 typedef typename Traits::template Codim< codimension > :: EntityImpl EntityImpl;
38
39 public:
40 PolyhedralGridEntityPointer ( ExtraData data )
41 : entity_( EntityImpl( data ) )
42 {}
43
44 explicit PolyhedralGridEntityPointer ( const EntityImpl &entity )
45 : entity_( EntityImpl( entity ) )
46 {}
47
48 PolyhedralGridEntityPointer ( const This &other )
49 : entity_( EntityImpl( other.entityImpl() ) )
50 {}
51
52 const This &operator= ( const This &other )
53 {
54 entityImpl() = other.entityImpl();
55 return *this;
56 }
57
59 bool equals ( const This &other ) const
60 {
61 return entityImpl().equals( other.entityImpl() );
62 }
63
66 {
67 return entity_;
68 }
69
70 operator const Entity& () const { return entity_; }
71 operator Entity& () { return entity_; }
72
74 int level () const { return entity_.level(); }
75
76 protected:
77 EntityImpl &entityImpl () const
78 {
79#if DUNE_VERSION_NEWER(DUNE_GRID, 2, 7)
80 return entity_.impl();
81#else
82 return Grid::getRealImplementation( entity_ );
83#endif
84 }
85
86 ExtraData data () const { return entityImpl().data(); }
87
88 protected:
89 mutable Entity entity_;
90 };
91
92} // namespace Dune
93
94#endif // #ifndef DUNE_POLYHEDRALGRID_ENTITYPOINTER_HH
Definition: entitypointer.hh:19
bool equals(const This &other) const
check for equality
Definition: entitypointer.hh:59
int level() const
obtain level
Definition: entitypointer.hh:74
static const int codimension
world dimension
Definition: entitypointer.hh:29
Entity & dereference() const
dereference entity
Definition: entitypointer.hh:65
Traits::template Codim< codimension >::Entity Entity
type of entity
Definition: entitypointer.hh:32
static const int dimension
grid dimension
Definition: entitypointer.hh:27
Copyright 2019 Equinor AS.
Definition: CartesianIndexMapper.hpp:10