Dune Core Modules (2.5.0)

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, int codim >
41 struct canCommunicate< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
42 {
43 static const bool v = canCommunicate< HostGrid, codim >::v && hasEntity< HostGrid, codim >::v;
44 };
45
46
47 template< class HostGrid, class CoordFunction, class Allocator >
48 struct hasBackupRestoreFacilities< GeometryGrid< HostGrid, CoordFunction, Allocator > >
49 {
50 static const bool v = hasBackupRestoreFacilities< HostGrid >::v;
51 };
52
53 template< class HostGrid, class CoordFunction, class Allocator >
54 struct isLevelwiseConforming< GeometryGrid< HostGrid, CoordFunction, Allocator > >
55 {
56 static const bool v = isLevelwiseConforming< HostGrid >::v;
57 };
58
59 template< class HostGrid, class CoordFunction, class Allocator >
60 struct isLeafwiseConforming< GeometryGrid< HostGrid, CoordFunction, Allocator > >
61 {
62 static const bool v = isLeafwiseConforming< HostGrid >::v;
63 };
64
65 template< class HostGrid, class CoordFunction, class Allocator >
66 struct threadSafe< GeometryGrid< HostGrid, CoordFunction, Allocator > >
67 {
68 static const bool v = false;
69 };
70
71 template< class HostGrid, class CoordFunction, class Allocator >
72 struct viewThreadSafe< GeometryGrid< HostGrid, CoordFunction, Allocator > >
73 {
74 static const bool v = false;
75 };
76
77
78
79
80 // hasHostEntity
81 // -------------
82
83 template< class Grid, int codim >
84 struct hasHostEntity;
85
86 template< class Grid, int codim >
87 struct hasHostEntity< const Grid, codim >
88 {
89 static const bool v = hasHostEntity< Grid, codim >::v;
90 };
91
92 template< class HostGrid, class CoordFunction, class Allocator, int codim >
93 struct hasHostEntity< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
94 {
95 static const bool v = hasEntity< HostGrid, codim >::v;
96 };
97
98
99
100 // CodimCache
101 // ----------
102
103 template< class Grid >
104 class CodimCache
105 {
106 static const int dimension = Grid::dimension;
107
108 template< int codim >
109 struct BuildCache;
110
111 bool hasHostEntity_[ Grid::dimension + 1 ];
112
113 CodimCache ()
114 {
116 }
117
118 static CodimCache &instance ()
119 {
120 static CodimCache singleton;
121 return singleton;
122 }
123
124 public:
125 static bool hasHostEntity ( int codim )
126 {
127 assert( (codim >= 0) && (codim <= dimension) );
128 return instance().hasHostEntity_[ codim ];
129 }
130 };
131
132 template< class Grid >
133 template< int codim >
134 struct CodimCache< Grid >::BuildCache
135 {
136 static void apply ( bool (&hasHostEntity)[ dimension + 1 ] )
137 {
138 hasHostEntity[ codim ] = Capabilities::hasHostEntity< Grid, codim >::v;
139 }
140 };
141
142 } // namespace Capabilities
143
144} // namespace Dune
145
146#endif // #ifndef DUNE_GEOGRID_CAPABILITIES_HH
@ dimension
The dimension of the grid.
Definition: grid.hh:387
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:11
A static loop using TMP.
Definition: forloop.hh:67
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)