dune-pdelab 2.8
Loading...
Searching...
No Matches
finiteelementmap/utility.hh
Go to the documentation of this file.
1#ifndef DUNE_PDELAB_FINITEELEMENTMAP_UTILITY_HH
2#define DUNE_PDELAB_FINITEELEMENTMAP_UTILITY_HH
3
4#include <cstddef>
5
8
10
11namespace Dune {
12 namespace PDELab {
13
15
18 template<typename FEM>
19 using StaticFEMSize = decltype(FEM::size(GeometryTypes::vertex));
20
21#ifndef DOXYGEN
22
23 namespace Impl {
24
25 // This function iterates over all geometry types up to the dimension of the finite element map
26 // and returns the value of FEM::size(gt) iff that number is constant for all geometry types for
27 // which the returned size is > 0. Otherwise it returns 0. As this only works if FEM::size() is
28 // static, we use the additional argument to provide a separate overload if it is not.
29 // Note that as there is no way to easily construct the set of "valid" geometry types for a
30 // given dimension, we manually iterate over all possible topology ids. This creates weird
31 // geometry types, but we just assume that FEM::size() will return 0 for invalid ones.
32 template<typename FEM>
33 constexpr std::size_t _femBlockSize(std::true_type)
34 {
35 constexpr int dim = FEM::dimension;
36 std::size_t size = 0;
37 for (int d = 0 ; d <= dim ; ++d)
38 {
39 std::size_t gt_size = FEM::size(GeometryTypes::none(d));
40 if (gt_size > 0)
41 {
42 if (size > 0 and size != gt_size)
43 return 0;
44 else
45 size = gt_size;
46 }
47 for (unsigned int topology_id = 0 ; topology_id < (1 << dim) ; ++topology_id)
48 {
49 std::size_t gt_size = FEM::size(GeometryType(topology_id,d));
50 if (gt_size > 0)
51 {
52 if (size > 0 and size != gt_size)
53 return 0;
54 else
55 size = gt_size;
56 }
57 }
58 }
59 return size;
60 }
61
62 // fallback version if `FEM::size()` is an instance method.
63 template<typename FEM>
64 constexpr std::size_t _femBlockSize(std::false_type)
65 {
66 return 0;
67 }
68
69 } // namespace Impl
70
71#endif // DOXYGEN
72
74
82 template<typename FEM>
84 {
85 return Impl::_femBlockSize<FEM>(Std::is_detected<StaticFEMSize,FEM>());
86 }
87
89 template<typename FEM>
91
92 } // namespace PDELab
93} //namespace Dune
94
95#endif // DUNE_PDELAB_FINITEELEMENTMAP_UTILITY_HH
int size() const
typename detected_or< nonesuch, Op, Args... >::value_t is_detected
static const int dim
Definition adaptivity.hh:84
decltype(FEM::size(GeometryTypes::vertex)) StaticFEMSize
Metafunction that returns the type of FEM::size() iff that function is static.
Definition finiteelementmap/utility.hh:19
constexpr std::size_t finiteElementMapBlockSize()
Returns the block size for FEM if available, 0 otherwise.
Definition finiteelementmap/utility.hh:83
For backward compatibility – Do not use this!