Dune Core Modules (2.3.1)

capabilities.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_GEOGRID_CAPABILITIES_HH
4#define DUNE_GEOGRID_CAPABILITIES_HH
5
6#include <cassert>
7
9
11#include <dune/grid/geometrygrid/declaration.hh>
12
13namespace Dune
14{
15
16 // Capabilities
17 // ------------
18
19 namespace Capabilities
20 {
21
22 // Capabilities from dune-grid
23 // ---------------------------
24
25 template< class HostGrid, class CoordFunction, class Allocator >
26 struct hasSingleGeometryType< GeometryGrid< HostGrid, CoordFunction, Allocator > >
27 {
28 static const bool v = hasSingleGeometryType< HostGrid > :: v;
29 static const unsigned int topologyId = hasSingleGeometryType< HostGrid > :: topologyId;
30 };
31
32
33 template< class HostGrid, class CoordFunction, class Allocator, int codim >
34 struct hasEntity< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
35 {
36 static const bool v = true;
37 };
38
39
40 template< class HostGrid, class CoordFunction, class Allocator >
41 struct isParallel< GeometryGrid< HostGrid, CoordFunction, Allocator > >
42 {
43 static const bool v = isParallel< HostGrid >::v;
44 };
45
46
47 template< class HostGrid, class CoordFunction, class Allocator, int codim >
48 struct canCommunicate< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
49 {
50 static const bool v = canCommunicate< HostGrid, codim >::v;
51 };
52
53
54 template< class HostGrid, class CoordFunction, class Allocator >
55 struct hasBackupRestoreFacilities< GeometryGrid< HostGrid, CoordFunction, Allocator > >
56 {
57 static const bool v = hasBackupRestoreFacilities< HostGrid >::v;
58 };
59
60 template< class HostGrid, class CoordFunction, class Allocator >
61 struct isLevelwiseConforming< GeometryGrid< HostGrid, CoordFunction, Allocator > >
62 {
63 static const bool v = isLevelwiseConforming< HostGrid >::v;
64 };
65
66 template< class HostGrid, class CoordFunction, class Allocator >
67 struct isLeafwiseConforming< GeometryGrid< HostGrid, CoordFunction, Allocator > >
68 {
69 static const bool v = isLeafwiseConforming< HostGrid >::v;
70 };
71
72 template< class HostGrid, class CoordFunction, class Allocator >
73 struct threadSafe< GeometryGrid< HostGrid, CoordFunction, Allocator > >
74 {
75 static const bool v = false;
76 };
77
78 template< class HostGrid, class CoordFunction, class Allocator >
79 struct viewThreadSafe< GeometryGrid< HostGrid, CoordFunction, Allocator > >
80 {
81 static const bool v = false;
82 };
83
84
85
86
87 // hasHostEntity
88 // -------------
89
90 template< class Grid, int codim >
91 struct hasHostEntity;
92
93 template< class Grid, int codim >
94 struct hasHostEntity< const Grid, codim >
95 {
96 static const bool v = hasHostEntity< Grid, codim >::v;
97 };
98
99 template< class HostGrid, class CoordFunction, class Allocator, int codim >
100 struct hasHostEntity< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
101 {
102 static const bool v = hasEntity< HostGrid, codim >::v;
103 };
104
105
106
107 // CodimCache
108 // ----------
109
110 template< class Grid >
111 class CodimCache
112 {
113 static const int dimension = Grid::dimension;
114
115 template< int codim >
116 struct BuildCache;
117
118 bool hasHostEntity_[ Grid::dimension + 1 ];
119
120 CodimCache ()
121 {
123 }
124
125 static CodimCache &instance ()
126 {
127 static CodimCache singleton;
128 return singleton;
129 }
130
131 public:
132 static bool hasHostEntity ( int codim )
133 {
134 assert( (codim >= 0) && (codim <= dimension) );
135 return instance().hasHostEntity_[ codim ];
136 }
137 };
138
139 template< class Grid >
140 template< int codim >
141 struct CodimCache< Grid >::BuildCache
142 {
143 static void apply ( bool (&hasHostEntity)[ dimension + 1 ] )
144 {
145 hasHostEntity[ codim ] = Capabilities::hasHostEntity< Grid, codim >::v;
146 }
147 };
148
149 } // namespace Capabilities
150
151} // namespace Dune
152
153#endif // #ifndef DUNE_GEOGRID_CAPABILITIES_HH
A static loop using TMP.
Definition: forloop.hh:223
@ dimension
The dimension of the grid.
Definition: grid.hh:400
A set of traits classes to store static information about grid implementation.
A static for loop for template meta-programming.
Dune namespace.
Definition: alignment.hh:14
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)