dune-grid  2.2.1
geometrygrid/capabilities.hh
Go to the documentation of this file.
1 #ifndef DUNE_GEOGRID_CAPABILITIES_HH
2 #define DUNE_GEOGRID_CAPABILITIES_HH
3 
4 #include <cassert>
5 
6 #include <dune/common/forloop.hh>
7 
10 
11 namespace Dune
12 {
13 
14  // Capabilities
15  // ------------
16 
17  namespace Capabilities
18  {
19 
20  // Capabilities from dune-grid
21  // ---------------------------
22 
23  template< class HostGrid, class CoordFunction, class Allocator >
24  struct hasSingleGeometryType< GeometryGrid< HostGrid, CoordFunction, Allocator > >
25  {
28  };
29 
30 
31  template< class HostGrid, class CoordFunction, class Allocator, int codim >
32  struct hasEntity< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
33  {
34  static const bool v = true;
35  };
36 
37 
38  template< class HostGrid, class CoordFunction, class Allocator >
39  struct isParallel< GeometryGrid< HostGrid, CoordFunction, Allocator > >
40  {
41  static const bool v = isParallel< HostGrid >::v;
42  };
43 
44 
45  template< class HostGrid, class CoordFunction, class Allocator, int codim >
46  struct canCommunicate< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
47  {
49  };
50 
51 
52  template< class HostGrid, class CoordFunction, class Allocator >
53  struct hasBackupRestoreFacilities< GeometryGrid< HostGrid, CoordFunction, Allocator > >
54  {
56  };
57 
58  template< class HostGrid, class CoordFunction, class Allocator >
59  struct isLevelwiseConforming< GeometryGrid< HostGrid, CoordFunction, Allocator > >
60  {
62  };
63 
64  template< class HostGrid, class CoordFunction, class Allocator >
65  struct isLeafwiseConforming< GeometryGrid< HostGrid, CoordFunction, Allocator > >
66  {
68  };
69 
70  template< class HostGrid, class CoordFunction, class Allocator >
71  struct threadSafe< GeometryGrid< HostGrid, CoordFunction, Allocator > >
72  {
73  static const bool v = false;
74  };
75 
76  template< class HostGrid, class CoordFunction, class Allocator >
77  struct viewThreadSafe< GeometryGrid< HostGrid, CoordFunction, Allocator > >
78  {
79  static const bool v = false;
80  };
81 
82 
83 
84 
85  // hasHostEntity
86  // -------------
87 
88  template< class Grid, int codim >
89  struct hasHostEntity;
90 
91  template< class Grid, int codim >
92  struct hasHostEntity< const Grid, codim >
93  {
94  static const bool v = hasHostEntity< Grid, codim >::v;
95  };
96 
97  template< class HostGrid, class CoordFunction, class Allocator, int codim >
98  struct hasHostEntity< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
99  {
100  static const bool v = hasEntity< HostGrid, codim >::v;
101  };
102 
103 
104 
105  // CodimCache
106  // ----------
107 
108  template< class Grid >
110  {
111  static const int dimension = Grid::dimension;
112 
113  template< int codim >
114  struct BuildCache;
115 
116  bool hasHostEntity_[ Grid::dimension + 1 ];
117 
118  CodimCache ()
119  {
120  Dune::ForLoop< BuildCache, 0, dimension >::apply( hasHostEntity_ );
121  }
122 
123  static CodimCache &instance ()
124  {
125  static CodimCache singleton;
126  return singleton;
127  }
128 
129  public:
130  static bool hasHostEntity ( int codim )
131  {
132  assert( (codim >= 0) && (codim <= dimension) );
133  return instance().hasHostEntity_[ codim ];
134  }
135  };
136 
137  template< class Grid >
138  template< int codim >
140  {
141  static void apply ( bool (&hasHostEntity)[ dimension + 1 ] )
142  {
143  hasHostEntity[ codim ] = Capabilities::hasHostEntity< Grid, codim >::v;
144  }
145  };
146 
147  } // namespace Capabilities
148 
149 } // namespace Dune
150 
151 #endif // #ifndef DUNE_GEOGRID_CAPABILITIES_HH