dune-grid 2.9.0
geometrygrid/entityseed.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_ENTITYSEED_HH
6#define DUNE_GEOGRID_ENTITYSEED_HH
7
8#include <dune/common/typetraits.hh>
9
12
13namespace Dune
14{
15
16 namespace GeoGrid
17 {
18
19 // Internal Forward Declarations
20 // -----------------------------
21
22 template< int codim, class Grid, bool fake = !(Capabilities::hasHostEntity< Grid, codim >::v) >
24
25
26
27 // EntitySeed (real)
28 // -----------------
29
30 template< int codim, class Grd >
31 class EntitySeed< codim, Grd, false >
32 {
33 typedef typename std::remove_const< Grd >::type::Traits Traits;
34
35 public:
36 static const int codimension = codim;
37 static const int dimension = Traits::dimension;
38 static const int mydimension = dimension - codimension;
39 static const int dimensionworld = Traits::dimensionworld;
40
41 static const bool fake = false;
42
43 typedef typename Traits::Grid Grid;
44 typedef typename Traits::template Codim< codim >::Entity Entity;
45
46 typedef typename Traits::HostGrid HostGrid;
47 typedef typename HostGrid::template Codim< codim >::EntitySeed HostEntitySeed;
48
51 {}
52
53 explicit EntitySeed ( const HostEntitySeed &hostEntitySeed )
54 : hostEntitySeed_( hostEntitySeed )
55 {}
56
58 bool isValid() const
59 {
60 return hostEntitySeed_.isValid();
61 }
62
63 const HostEntitySeed &hostEntitySeed () const { return hostEntitySeed_; }
64
65 private:
66 HostEntitySeed hostEntitySeed_;
67 };
68
69
70
71 // EntitySeed (fake)
72 // -----------------
73
74 template< int codim, class Grd >
75 class EntitySeed< codim, Grd, true >
76 {
77 typedef typename std::remove_const< Grd >::type::Traits Traits;
78
79 public:
80 static const int codimension = codim;
81 static const int dimension = Traits::dimension;
82 static const int mydimension = dimension - codimension;
83 static const int dimensionworld = Traits::dimensionworld;
84
85 static const bool fake = true;
86
87 typedef typename Traits::Grid Grid;
88 typedef typename Traits::template Codim< codim >::Entity Entity;
89
90 typedef typename Traits::HostGrid HostGrid;
91 typedef typename HostGrid::template Codim< 0 >::EntitySeed HostElementSeed;
92
95 {}
96
97 explicit EntitySeed ( const HostElementSeed &hostElementSeed, unsigned int subEntity )
98 : hostElementSeed_( hostElementSeed ),
99 subEntity_( subEntity )
100 {}
101
103 bool isValid() const
104 {
105 return hostElementSeed_.isValid();
106 }
107
108 const HostElementSeed &hostElementSeed () const { return hostElementSeed_; }
109 unsigned int subEntity () const { return subEntity_; }
110
111 private:
112 HostElementSeed hostElementSeed_;
113 unsigned int subEntity_;
114 };
115
116 } // namespace GeoGrid
117
118} // namespace Dune
119
120#endif // #ifndef DUNE_GEOGRID_ENTITYSEED_HH
Include standard header files.
Definition: agrid.hh:60
Definition: geometrygrid/entityseed.hh:23
Traits::template Codim< codim >::Entity Entity
Definition: geometrygrid/entityseed.hh:44
EntitySeed(const HostEntitySeed &hostEntitySeed)
Definition: geometrygrid/entityseed.hh:53
Traits::Grid Grid
Definition: geometrygrid/entityseed.hh:43
HostGrid::template Codim< codim >::EntitySeed HostEntitySeed
Definition: geometrygrid/entityseed.hh:47
EntitySeed()
default construct an invalid entity seed
Definition: geometrygrid/entityseed.hh:50
Traits::HostGrid HostGrid
Definition: geometrygrid/entityseed.hh:46
bool isValid() const
check whether the EntitySeed refers to a valid Entity
Definition: geometrygrid/entityseed.hh:58
const HostEntitySeed & hostEntitySeed() const
Definition: geometrygrid/entityseed.hh:63
HostGrid::template Codim< 0 >::EntitySeed HostElementSeed
Definition: geometrygrid/entityseed.hh:91
EntitySeed()
default construct an invalid entity seed
Definition: geometrygrid/entityseed.hh:94
const HostElementSeed & hostElementSeed() const
Definition: geometrygrid/entityseed.hh:108
Traits::template Codim< codim >::Entity Entity
Definition: geometrygrid/entityseed.hh:88
unsigned int subEntity() const
Definition: geometrygrid/entityseed.hh:109
Traits::HostGrid HostGrid
Definition: geometrygrid/entityseed.hh:90
bool isValid() const
check whether the EntitySeed refers to a valid Entity
Definition: geometrygrid/entityseed.hh:103
EntitySeed(const HostElementSeed &hostElementSeed, unsigned int subEntity)
Definition: geometrygrid/entityseed.hh:97
Traits::Grid Grid
Definition: geometrygrid/entityseed.hh:87
Interface class EntitySeed.