dune-grid  2.7.0
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 #include <type_traits>
8 
9 #include <dune/common/hybridutilities.hh>
10 #include <dune/common/std/utility.hh>
11 
14 
15 namespace 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  {
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 = true;
46  };
47 
48 
49  template< class HostGrid, class CoordFunction, class Allocator, int codim >
50  struct canCommunicate< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
51  {
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  {
66  };
67 
68  template< class HostGrid, class CoordFunction, class Allocator >
69  struct isLeafwiseConforming< GeometryGrid< HostGrid, CoordFunction, Allocator > >
70  {
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 >
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
Dune::Capabilities::canCommunicate::v
static const bool v
Definition: common/capabilities.hh:96
Dune::Capabilities::isLevelwiseConforming::v
static const bool v
Definition: common/capabilities.hh:105
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::isLeafwiseConforming
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition: common/capabilities.hh:112
Dune::Capabilities::hasEntity::v
static const bool v
Definition: common/capabilities.hh:57
Dune::Capabilities::threadSafe::v
static const bool v
Definition: common/capabilities.hh:141
Dune::Capabilities::viewThreadSafe::v
static const bool v
Definition: common/capabilities.hh:168
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::hasEntity
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition: common/capabilities.hh:55
Dune::Capabilities::hasHostEntity
Definition: geometrygrid/capabilities.hh:93
Dune::Capabilities::hasBackupRestoreFacilities::v
static const bool v
Definition: common/capabilities.hh:123
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
Dune::Capabilities::isLeafwiseConforming::v
static const bool v
Definition: common/capabilities.hh:114
Dune::Capabilities::CodimCache
Definition: geometrygrid/capabilities.hh:113
Dune::Capabilities::threadSafe
Specialize with 'true' if the grid implementation is thread safe. (default=false)
Definition: common/capabilities.hh:140
Dune::Capabilities::hasEntityIterator::v
static const bool v
Definition: common/capabilities.hh:73
Dune::GeometryGrid
grid wrapper replacing the geometries
Definition: declaration.hh:10
capabilities.hh
A set of traits classes to store static information about grid implementation.
declaration.hh
Dune::Capabilities::isLevelwiseConforming
Specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition: common/capabilities.hh:103
Dune::Grid::dimension
@ dimension
The dimension of the grid.
Definition: common/grid.hh:387
Dune::Grid
Grid abstract base class.
Definition: common/grid.hh:373
Dune::Capabilities::viewThreadSafe
Specialize with 'true' if the grid implementation is thread safe, while it is not modified....
Definition: common/capabilities.hh:167
Dune::Capabilities::hasSingleGeometryType::v
static const bool v
Definition: common/capabilities.hh:26
Dune
Include standard header files.
Definition: agrid.hh:58
Dune::Capabilities::hasBackupRestoreFacilities
Specialize with 'true' if implementation provides backup and restore facilities. (default=false)
Definition: common/capabilities.hh:121
Dune::Capabilities::hasSingleGeometryType::topologyId
static const unsigned int topologyId
Definition: common/capabilities.hh:29
Dune::Capabilities::CodimCache::hasHostEntity
static bool hasHostEntity(int codim)
Definition: geometrygrid/capabilities.hh:132