dune-grid 2.9.0
geometrygrid/capabilities.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 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
17namespace 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 >
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
Include standard header files.
Definition: agrid.hh:60
Specialize with 'true' for if the codimension 0 entity of the grid has only one possible geometry typ...
Definition: common/capabilities.hh:27
static const bool v
Definition: common/capabilities.hh:28
static const unsigned int topologyId
Definition: common/capabilities.hh:31
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition: common/capabilities.hh:58
static const bool v
Definition: common/capabilities.hh:59
specialize with 'true' for all codims that a grid provides an iterator for (default=hasEntity<codim>:...
Definition: common/capabilities.hh:74
static const bool v
Definition: common/capabilities.hh:75
specialize with 'true' for all codims that a grid can communicate data on (default=false)
Definition: common/capabilities.hh:97
static const bool v
Definition: common/capabilities.hh:98
Specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition: common/capabilities.hh:106
static const bool v
Definition: common/capabilities.hh:107
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition: common/capabilities.hh:115
static const bool v
Definition: common/capabilities.hh:116
Specialize with 'true' if implementation provides backup and restore facilities. (default=false)
Definition: common/capabilities.hh:124
static const bool v
Definition: common/capabilities.hh:125
Specialize with 'true' if the grid implementation is thread safe. (default=false)
Definition: common/capabilities.hh:142
static const bool v
Definition: common/capabilities.hh:143
Specialize with 'true' if the grid implementation is thread safe, while it is not modified....
Definition: common/capabilities.hh:169
static const bool v
Definition: common/capabilities.hh:170
Grid abstract base class.
Definition: common/grid.hh:375
static constexpr int dimension
The dimension of the grid.
Definition: common/grid.hh:387
Definition: geometrygrid/capabilities.hh:95
Definition: geometrygrid/capabilities.hh:116
static bool hasHostEntity(int codim)
Definition: geometrygrid/capabilities.hh:134
grid wrapper replacing the geometries
Definition: geometrygrid/grid.hh:86
A set of traits classes to store static information about grid implementation.