dune-grid  2.2.0
geometrygrid/entityseed.hh
Go to the documentation of this file.
1 #ifndef DUNE_GEOGRID_ENTITYSEED_HH
2 #define DUNE_GEOGRID_ENTITYSEED_HH
3 
4 #include <dune/common/typetraits.hh>
5 
7 
8 namespace Dune
9 {
10 
11  namespace GeoGrid
12  {
13 
14  // Internal Forward Declarations
15  // -----------------------------
16 
17  template< int codim, class Grid, bool fake = !(Capabilities::hasHostEntity< Grid, codim >::v) >
18  class EntitySeed;
19 
20 
21 
22  // EntitySeed (real)
23  // -----------------
24 
25  template< int codim, class Grd >
26  class EntitySeed< codim, Grd, false >
27  {
28  typedef typename remove_const< Grd >::type::Traits Traits;
29 
30  public:
31  static const int codimension = codim;
32  static const int dimension = Traits::dimension;
33  static const int mydimension = dimension - codimension;
34  static const int dimensionworld = Traits::dimensionworld;
35 
36  static const bool fake = false;
37 
38  typedef typename Traits::Grid Grid;
39  typedef typename Traits::template Codim< codim >::Entity Entity;
40 
41  typedef typename Traits::HostGrid HostGrid;
42  typedef typename HostGrid::template Codim< codim >::EntitySeed HostEntitySeed;
43 
44  explicit EntitySeed ( const HostEntitySeed &hostEntitySeed )
45  : hostEntitySeed_( hostEntitySeed )
46  {}
47 
48  const HostEntitySeed &hostEntitySeed () const { return hostEntitySeed_; }
49 
50  private:
51  HostEntitySeed hostEntitySeed_;
52  };
53 
54 
55 
56  // EntitySeed (fake)
57  // -----------------
58 
59  template< int codim, class Grd >
60  class EntitySeed< codim, Grd, true >
61  {
62  typedef typename remove_const< Grd >::type::Traits Traits;
63 
64  public:
65  static const int codimension = codim;
66  static const int dimension = Traits::dimension;
67  static const int mydimension = dimension - codimension;
68  static const int dimensionworld = Traits::dimensionworld;
69 
70  static const bool fake = true;
71 
72  typedef typename Traits::Grid Grid;
73  typedef typename Traits::template Codim< codim >::Entity Entity;
74 
75  typedef typename Traits::HostGrid HostGrid;
76  typedef typename HostGrid::template Codim< 0 >::EntitySeed HostElementSeed;
77 
78  explicit EntitySeed ( const HostElementSeed &hostElementSeed, unsigned int subEntity )
79  : hostElementSeed_( hostElementSeed ),
80  subEntity_( subEntity )
81  {}
82 
83  const HostElementSeed &hostElementSeed () const { return hostElementSeed_; }
84  unsigned int subEntity () const { return subEntity_; }
85 
86  private:
87  HostElementSeed hostElementSeed_;
88  unsigned int subEntity_;
89  };
90 
91  } // namespace GeoGrid
92 
93 } // namespace Dune
94 
95 #endif // #ifndef DUNE_GEOGRID_ENTITYSEED_HH