OGS
LocalDOF.h
Go to the documentation of this file.
1
12#pragma once
13
14#include <boost/mp11.hpp>
15
17
18namespace NumLib
19{
20template <typename ShapeFunction, int Dim>
22{
23};
24
25namespace detail
26{
27template <typename ShapeFunction>
28struct NumberOfDofs : std::integral_constant<unsigned, ShapeFunction::NPOINTS>
29{
30};
31
32template <typename ShapeFunction, int Dim>
33struct NumberOfDofs<Vectorial<ShapeFunction, Dim>>
34 : std::integral_constant<unsigned, ShapeFunction::NPOINTS * Dim>
35{
36};
37
38template <typename... Ns_t,
39 typename ElementDOFVector,
40 int... Offsets,
41 int... Sizes>
42auto localDOFImpl(ElementDOFVector const& x,
43 boost::mp11::mp_list_c<int, Offsets...>,
44 boost::mp11::mp_list_c<int, Sizes...>)
45{
46 static_assert(((Sizes > 0) && ...));
47 static_assert(((Offsets >= 0) && ...));
48
49 return std::tuple<Eigen::Map<typename MatrixPolicyType::VectorType<
50 NumberOfDofs<Ns_t>::value> const>...>{{x.data() + Offsets, Sizes}...};
51}
52} // namespace detail
53
63template <typename... Ns_t, typename ElementDOFVector>
64auto localDOF(ElementDOFVector const& x)
65{
66 using namespace boost::mp11;
67
68 static_assert(sizeof...(Ns_t) > 0);
69
70 using Sizes = mp_list_c<int, detail::NumberOfDofs<Ns_t>::value...>;
71 using Offsets =
72 mp_push_front<mp_pop_back<mp_partial_sum<Sizes, mp_int<0>, mp_plus>>,
73 mp_int<0>>;
74
75 assert((mp_back<Offsets>::value + mp_back<Sizes>::value == x.size()) &&
76 "The passed shape matrices require a different number of "
77 "d.o.f.s than present in the passed element d.o.f. vector.");
78
79 return detail::localDOFImpl<Ns_t...>(x, Offsets{}, Sizes{});
80}
81
82} // namespace NumLib
auto localDOFImpl(ElementDOFVector const &x, boost::mp11::mp_list_c< int, Offsets... >, boost::mp11::mp_list_c< int, Sizes... >)
Definition LocalDOF.h:42
auto localDOF(ElementDOFVector const &x)
Definition LocalDOF.h:64
typename ::detail::EigenMatrixType< N, 1 >::type VectorType