DUNE PDELab (git)

capabilities.hh
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
15#include <dune/grid/geometrygrid/declaration.hh>
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 {
32 static const bool v = hasSingleGeometryType< HostGrid > :: v;
33 static const unsigned int topologyId = hasSingleGeometryType< HostGrid > :: topologyId;
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 {
47 static const bool v = hasEntityIterator<HostGrid, codim>::v;
48 };
49
50
51 template< class HostGrid, class CoordFunction, class Allocator, int codim >
52 struct canCommunicate< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim >
53 {
54 static const bool v = canCommunicate< HostGrid, codim >::v && hasEntity< HostGrid, codim >::v;
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 {
67 static const bool v = isLevelwiseConforming< HostGrid >::v;
68 };
69
70 template< class HostGrid, class CoordFunction, class Allocator >
71 struct isLeafwiseConforming< GeometryGrid< HostGrid, CoordFunction, Allocator > >
72 {
73 static const bool v = isLeafwiseConforming< HostGrid >::v;
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 >
115 class CodimCache
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 constexpr int dimension
The dimension of the grid.
Definition: grid.hh:387
A set of traits classes to store static information about grid implementation.
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition: hybridutilities.hh:256
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)