dune-grid  2.4.1
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 #include <dune/common/deprecated.hh>
10 
13 
14 namespace 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  {
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 >
42  struct DUNE_DEPRECATED_MSG("Capabilities::isParallel will be removed after dune-grid-2.4.") isParallel< GeometryGrid< HostGrid, CoordFunction, Allocator > >
43  {
44  static const bool DUNE_DEPRECATED_MSG("Capabilities::isParallel will be removed after dune-grid-2.4.") v = isParallel< HostGrid >::v;
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;
52  };
53 
54 
55  template< class HostGrid, class CoordFunction, class Allocator >
56  struct hasBackupRestoreFacilities< GeometryGrid< HostGrid, CoordFunction, Allocator > >
57  {
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 >
113  {
114  static const int dimension = Grid::dimension;
115 
116  template< int codim >
117  struct BuildCache;
118 
119  bool hasHostEntity_[ Grid::dimension + 1 ];
120 
121  CodimCache ()
122  {
123  Dune::ForLoop< BuildCache, 0, dimension >::apply( hasHostEntity_ );
124  }
125 
126  static CodimCache &instance ()
127  {
128  static CodimCache singleton;
129  return singleton;
130  }
131 
132  public:
133  static bool hasHostEntity ( int codim )
134  {
135  assert( (codim >= 0) && (codim <= dimension) );
136  return instance().hasHostEntity_[ codim ];
137  }
138  };
139 
140  template< class Grid >
141  template< int codim >
142  struct CodimCache< Grid >::BuildCache
143  {
144  static void apply ( bool (&hasHostEntity)[ dimension + 1 ] )
145  {
146  hasHostEntity[ codim ] = Capabilities::hasHostEntity< Grid, codim >::v;
147  }
148  };
149 
150  } // namespace Capabilities
151 
152 } // namespace Dune
153 
154 #endif // #ifndef DUNE_GEOGRID_CAPABILITIES_HH
Specialize with 'true' if the grid implementation is thread safe, while it is not modified...
Definition: common/capabilities.hh:162
Specialize with 'true' if implementation supports parallelism. (default=false)
Definition: common/capabilities.hh:68
Specialize with 'true' if implementation guarantees conforming level grids. (default=false) ...
Definition: common/capabilities.hh:98
Definition: geometrygrid/capabilities.hh:112
Specialize with 'true' for if the codimension 0 entity of the grid has only one possible geometry typ...
Definition: common/capabilities.hh:26
Specialize with 'true' if implementation provides backup and restore facilities. (default=false) ...
Definition: common/capabilities.hh:116
static const bool v
Definition: common/capabilities.hh:28
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false) ...
Definition: common/capabilities.hh:107
grid wrapper replacing the geometriesGeometryGrid wraps another DUNE grid and replaces its geometry b...
Definition: geometrygrid/declaration.hh:10
Specialize with 'true' for all codims that a grid implements entities for. (default=false) ...
Definition: common/capabilities.hh:57
static bool hasHostEntity(int codim)
Definition: geometrygrid/capabilities.hh:133
static const bool v
Definition: common/capabilities.hh:59
Grid abstract base classThis class is the base class for all grid implementations. Although no virtual functions are used we call it abstract since its methods do not contain an implementation but forward to the methods of the derived class via the Barton-Nackman trick.
Definition: common/grid.hh:388
Definition: geometrygrid/capabilities.hh:92
static const unsigned int topologyId
Definition: common/capabilities.hh:31
The dimension of the grid.
Definition: common/grid.hh:402
Include standard header files.
Definition: agrid.hh:59
Specialize with 'true' if the grid implementation is thread safe. (default=false) ...
Definition: common/capabilities.hh:135
specialize with 'true' for all codims that a grid can communicate data on (default=false) ...
Definition: common/capabilities.hh:89
A set of traits classes to store static information about grid implementation.