dune-grid  2.11
geometrygrid/capabilities.hh
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 // vi: set et ts=4 sw=2 sts=2:
5 #ifndef DUNE_GEOGRID_CAPABILITIES_HH
6 #define DUNE_GEOGRID_CAPABILITIES_HH
7 
8 #include <cassert>
9 #include <type_traits>
10 #include <utility>
11 
12 #include <dune/common/hybridutilities.hh>
13 
16 
17 namespace Dune
18 {
19 
20  // Capabilities
21  // ------------
22 
23  namespace Capabilities
24  {
25 
26  // Capabilities from dune-grid
27  // ---------------------------
28 
29  template< class HostGrid, class CoordFunction, class Allocator >
30  struct hasSingleGeometryType< GeometryGrid< HostGrid, CoordFunction, Allocator > >
31  {
34  };
35 
36 
37  template< class HostGrid, class CoordFunction, class Allocator, int codim >
38  struct hasEntity< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
39  {
40  static const bool v = true;
41  };
42 
43 
44  template< class HostGrid, class CoordFunction, class Allocator, int codim >
45  struct hasEntityIterator< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
46  {
48  };
49 
50 
51  template< class HostGrid, class CoordFunction, class Allocator, int codim >
52  struct canCommunicate< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
53  {
55  };
56 
57 
58  template< class HostGrid, class CoordFunction, class Allocator >
59  struct hasBackupRestoreFacilities< GeometryGrid< HostGrid, CoordFunction, Allocator > >
60  {
61  static const bool v = hasBackupRestoreFacilities< HostGrid >::v && std::is_default_constructible< CoordFunction >::value;
62  };
63 
64  template< class HostGrid, class CoordFunction, class Allocator >
65  struct isLevelwiseConforming< GeometryGrid< HostGrid, CoordFunction, Allocator > >
66  {
68  };
69 
70  template< class HostGrid, class CoordFunction, class Allocator >
71  struct isLeafwiseConforming< GeometryGrid< HostGrid, CoordFunction, Allocator > >
72  {
74  };
75 
76  template< class HostGrid, class CoordFunction, class Allocator >
77  struct threadSafe< GeometryGrid< HostGrid, CoordFunction, Allocator > >
78  {
79  static const bool v = false;
80  };
81 
82  template< class HostGrid, class CoordFunction, class Allocator >
83  struct viewThreadSafe< GeometryGrid< HostGrid, CoordFunction, Allocator > >
84  {
85  static const bool v = false;
86  };
87 
88 
89 
90 
91  // hasHostEntity
92  // -------------
93 
94  template< class Grid, int codim >
95  struct hasHostEntity;
96 
97  template< class Grid, int codim >
98  struct hasHostEntity< const Grid, codim >
99  {
100  static const bool v = hasHostEntity< Grid, codim >::v;
101  };
102 
103  template< class HostGrid, class CoordFunction, class Allocator, int codim >
104  struct hasHostEntity< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
105  {
106  static const bool v = hasEntity< HostGrid, codim >::v;
107  };
108 
109 
110 
111  // CodimCache
112  // ----------
113 
114  template< class Grid >
116  {
117  static const int dimension = Grid::dimension;
118 
119  bool hasHostEntity_[ Grid::dimension + 1 ];
120 
121  CodimCache ()
122  {
123  Hybrid::forEach( std::make_index_sequence< dimension+1 >{},
124  [ & ]( auto i ){ hasHostEntity_[ i ] = Capabilities::hasHostEntity< Grid, i >::v; } );
125  }
126 
127  static CodimCache &instance ()
128  {
129  static CodimCache singleton;
130  return singleton;
131  }
132 
133  public:
134  static bool hasHostEntity ( int codim )
135  {
136  assert( (codim >= 0) && (codim <= dimension) );
137  return instance().hasHostEntity_[ codim ];
138  }
139  };
140 
141  } // namespace Capabilities
142 
143 } // namespace Dune
144 
145 #endif // #ifndef DUNE_GEOGRID_CAPABILITIES_HH
static bool hasHostEntity(int codim)
Definition: geometrygrid/capabilities.hh:134
static const bool v
Definition: common/capabilities.hh:98
Specialize with &#39;true&#39; for if the codimension 0 entity of the grid has only one possible geometry typ...
Definition: common/capabilities.hh:26
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:375
static const bool v
Definition: common/capabilities.hh:116
static const bool v
Definition: common/capabilities.hh:125
Specialize with &#39;true&#39; for all codims that a grid implements entities for. (default=false) ...
Definition: common/capabilities.hh:57
Specialize with &#39;true&#39; if implementation guarantees a conforming leaf grid. (default=false) ...
Definition: common/capabilities.hh:114
Include standard header files.
Definition: agrid.hh:59
static const bool v
Definition: common/capabilities.hh:75
Specialize with &#39;true&#39; if the grid implementation is thread safe. (default=false) ...
Definition: common/capabilities.hh:142
grid wrapper replacing the geometriesGeometryGrid wraps another DUNE grid and replaces its geometry b...
Definition: declaration.hh:12
Specialize with &#39;true&#39; if implementation guarantees conforming level grids. (default=false) ...
Definition: common/capabilities.hh:105
static const bool v
Definition: common/capabilities.hh:107
static const bool v
Definition: common/capabilities.hh:28
specialize with &#39;true&#39; for all codims that a grid provides an iterator for (default=hasEntity<codim>:...
Definition: common/capabilities.hh:73
static constexpr int dimension
The dimension of the grid.
Definition: common/grid.hh:387
static const bool v
Definition: common/capabilities.hh:59
static const unsigned int topologyId
Definition: common/capabilities.hh:31
static const bool v
Definition: common/capabilities.hh:170
Specialize with &#39;true&#39; if implementation provides backup and restore facilities. (default=false) ...
Definition: common/capabilities.hh:123
specialize with &#39;true&#39; for all codims that a grid can communicate data on (default=false) ...
Definition: common/capabilities.hh:96
A set of traits classes to store static information about grid implementation.
Definition: geometrygrid/capabilities.hh:115
Specialize with &#39;true&#39; if the grid implementation is thread safe, while it is not modified...
Definition: common/capabilities.hh:169
Definition: geometrygrid/capabilities.hh:95
static const bool v
Definition: common/capabilities.hh:143