dune-grid  2.6-git
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/hybridutilities.hh>
9 #include <dune/common/std/utility.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, 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  {
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  {
65  };
66 
67  template< class HostGrid, class CoordFunction, class Allocator >
68  struct isLeafwiseConforming< GeometryGrid< HostGrid, CoordFunction, Allocator > >
69  {
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  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
Dune::Capabilities::hasBackupRestoreFacilities
Specialize with 'true' if implementation provides backup and restore facilities. (default=false)
Definition: common/capabilities.hh:121
Dune::Capabilities::viewThreadSafe::v
static const bool v
Definition: common/capabilities.hh:168
Dune::Capabilities::hasEntity::v
static const bool v
Definition: common/capabilities.hh:57
Dune::Capabilities::hasHostEntity
Definition: geometrygrid/capabilities.hh:92
Dune::Capabilities::canCommunicate::v
static const bool v
Definition: common/capabilities.hh:96
Dune::Capabilities::isLeafwiseConforming
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition: common/capabilities.hh:112
declaration.hh
Dune::Capabilities::isLevelwiseConforming
Specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition: common/capabilities.hh:103
Dune::Capabilities::threadSafe::v
static const bool v
Definition: common/capabilities.hh:141
Dune::Grid
Grid abstract base class.
Definition: common/grid.hh:373
Dune::Capabilities::canCommunicate
specialize with 'true' for all codims that a grid can communicate data on (default=false)
Definition: common/capabilities.hh:94
Dune::Capabilities::hasEntityIterator
specialize with 'true' for all codims that a grid provides an iterator for (default=false)
Definition: common/capabilities.hh:71
Dune::Capabilities::hasSingleGeometryType
Specialize with 'true' for if the codimension 0 entity of the grid has only one possible geometry typ...
Definition: common/capabilities.hh:24
capabilities.hh
A set of traits classes to store static information about grid implementation.
Dune::Capabilities::hasEntity
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition: common/capabilities.hh:55
Dune::Capabilities::threadSafe
Specialize with 'true' if the grid implementation is thread safe. (default=false)
Definition: common/capabilities.hh:140
Dune::Capabilities::hasBackupRestoreFacilities::v
static const bool v
Definition: common/capabilities.hh:123
Dune::Capabilities::CodimCache::hasHostEntity
static bool hasHostEntity(int codim)
Definition: geometrygrid/capabilities.hh:131
Dune::Capabilities::hasSingleGeometryType::topologyId
static const unsigned int topologyId
Definition: common/capabilities.hh:29
Dune::Capabilities::hasEntityIterator::v
static const bool v
Definition: common/capabilities.hh:73
Dune::Capabilities::hasSingleGeometryType::v
static const bool v
Definition: common/capabilities.hh:26
Dune::GeometryGrid
grid wrapper replacing the geometries
Definition: declaration.hh:10
Dune::Capabilities::CodimCache
Definition: geometrygrid/capabilities.hh:112
Dune::Capabilities::isLeafwiseConforming::v
static const bool v
Definition: common/capabilities.hh:114
Dune
Include standard header files.
Definition: agrid.hh:58
Dune::Grid::dimension
@ dimension
The dimension of the grid.
Definition: common/grid.hh:387
Dune::Capabilities::isLevelwiseConforming::v
static const bool v
Definition: common/capabilities.hh:105
Dune::Capabilities::viewThreadSafe
Specialize with 'true' if the grid implementation is thread safe, while it is not modified....
Definition: common/capabilities.hh:167