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