dune-grid  2.3beta2
geometrygrid/capabilities.hh
Go to the documentation of this file.
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/forloop.hh>
9 
12 
13 namespace 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  {
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  {
51  };
52 
53 
54  template< class HostGrid, class CoordFunction, class Allocator >
55  struct hasBackupRestoreFacilities< GeometryGrid< HostGrid, CoordFunction, Allocator > >
56  {
58  };
59 
60  template< class HostGrid, class CoordFunction, class Allocator >
61  struct isLevelwiseConforming< GeometryGrid< HostGrid, CoordFunction, Allocator > >
62  {
64  };
65 
66  template< class HostGrid, class CoordFunction, class Allocator >
67  struct isLeafwiseConforming< GeometryGrid< HostGrid, CoordFunction, Allocator > >
68  {
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 >
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  {
122  Dune::ForLoop< BuildCache, 0, dimension >::apply( hasHostEntity_ );
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 >
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