Dune Core Modules (2.9.1)

entityseed.hh
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
9
11#include <dune/grid/geometrygrid/capabilities.hh>
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) >
23 class EntitySeed;
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
50 EntitySeed ( )
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
94 EntitySeed ( )
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
Interface class EntitySeed.
Dune namespace.
Definition: alignedallocator.hh:13
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)