Dune Core Modules (2.6.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
8#include <dune/common/hybridutilities.hh>
9#include <dune/common/std/utility.hh>
10
12#include <dune/grid/geometrygrid/declaration.hh>
13
14namespace Dune
15{
16
17 // Capabilities
18 // ------------
19
20 namespace Capabilities
21 {
22
23 // Capabilities from dune-grid
24 // ---------------------------
25
26 template< class HostGrid, class CoordFunction, class Allocator >
27 struct hasSingleGeometryType< GeometryGrid< HostGrid, CoordFunction, Allocator > >
28 {
29 static const bool v = hasSingleGeometryType< HostGrid > :: v;
30 static const unsigned int topologyId = hasSingleGeometryType< HostGrid > :: topologyId;
31 };
32
33
34 template< class HostGrid, class CoordFunction, class Allocator, int codim >
35 struct hasEntity< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
36 {
37 static const bool v = true;
38 };
39
40
41 template< class HostGrid, class CoordFunction, class Allocator, int codim >
42 struct hasEntityIterator< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
43 {
44 static const bool v = true;
45 };
46
47
48 template< class HostGrid, class CoordFunction, class Allocator, int codim >
49 struct canCommunicate< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
50 {
51 static const bool v = canCommunicate< HostGrid, codim >::v && hasEntity< HostGrid, codim >::v;
52 };
53
54
55 template< class HostGrid, class CoordFunction, class Allocator >
56 struct hasBackupRestoreFacilities< GeometryGrid< HostGrid, CoordFunction, Allocator > >
57 {
58 static const bool v = hasBackupRestoreFacilities< HostGrid >::v;
59 };
60
61 template< class HostGrid, class CoordFunction, class Allocator >
62 struct isLevelwiseConforming< GeometryGrid< HostGrid, CoordFunction, Allocator > >
63 {
64 static const bool v = isLevelwiseConforming< HostGrid >::v;
65 };
66
67 template< class HostGrid, class CoordFunction, class Allocator >
68 struct isLeafwiseConforming< GeometryGrid< HostGrid, CoordFunction, Allocator > >
69 {
70 static const bool v = isLeafwiseConforming< HostGrid >::v;
71 };
72
73 template< class HostGrid, class CoordFunction, class Allocator >
74 struct threadSafe< GeometryGrid< HostGrid, CoordFunction, Allocator > >
75 {
76 static const bool v = false;
77 };
78
79 template< class HostGrid, class CoordFunction, class Allocator >
80 struct viewThreadSafe< GeometryGrid< HostGrid, CoordFunction, Allocator > >
81 {
82 static const bool v = false;
83 };
84
85
86
87
88 // hasHostEntity
89 // -------------
90
91 template< class Grid, int codim >
92 struct hasHostEntity;
93
94 template< class Grid, int codim >
95 struct hasHostEntity< const Grid, codim >
96 {
97 static const bool v = hasHostEntity< Grid, codim >::v;
98 };
99
100 template< class HostGrid, class CoordFunction, class Allocator, int codim >
101 struct hasHostEntity< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
102 {
103 static const bool v = hasEntity< HostGrid, codim >::v;
104 };
105
106
107
108 // CodimCache
109 // ----------
110
111 template< class Grid >
112 class CodimCache
113 {
114 static const int dimension = Grid::dimension;
115
116 bool hasHostEntity_[ Grid::dimension + 1 ];
117
118 CodimCache ()
119 {
120 Hybrid::forEach( Std::make_index_sequence< dimension+1 >{},
121 [ & ]( auto i ){ hasHostEntity_[ i ] = Capabilities::hasHostEntity< Grid, i >::v; } );
122 }
123
124 static CodimCache &instance ()
125 {
126 static CodimCache singleton;
127 return singleton;
128 }
129
130 public:
131 static bool hasHostEntity ( int codim )
132 {
133 assert( (codim >= 0) && (codim <= dimension) );
134 return instance().hasHostEntity_[ codim ];
135 }
136 };
137
138 } // namespace Capabilities
139
140} // namespace Dune
141
142#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.
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition: hybridutilities.hh:308
Dune namespace.
Definition: alignedallocator.hh:10
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 27, 23:30, 2024)