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