10 #include <type_traits>
20 template <
typename T,
typename =
void>
21 struct scalar_value_type
28 struct scalar_value_type<T, std::void_t<typename T::value_type>>
30 typedef typename T::value_type value_type;
34 using scalar_value_type_t =
typename scalar_value_type<T>::value_type;
43 contravariantPiola = 3,
44 doubleCovariantPiola = 4,
45 doubleContravariantPiola = 5,
49 template <
typename O,
typename P,
typename Q,
typename R>
50 void l2_piola(O&& r,
const P& U,
const Q& ,
double detJ,
const R& )
52 assert(U.extent(0) == r.extent(0));
53 assert(U.extent(1) == r.extent(1));
54 for (std::size_t i = 0; i < U.extent(0); ++i)
55 for (std::size_t j = 0; j < U.extent(1); ++j)
56 r(i, j) = U(i, j) / detJ;
60 template <
typename O,
typename P,
typename Q,
typename R>
64 using T =
typename std::decay_t<O>::value_type;
65 using Z =
typename impl::scalar_value_type_t<T>;
66 for (std::size_t p = 0; p < U.extent(0); ++p)
69 for (std::size_t i = 0; i < r.extent(1); ++i)
72 for (std::size_t k = 0; k < K.extent(0); ++k)
73 acc +=
static_cast<Z
>(K(k, i)) * U(p, k);
80 template <
typename O,
typename P,
typename Q,
typename R>
84 using T =
typename std::decay_t<O>::value_type;
85 using Z =
typename impl::scalar_value_type_t<T>;
86 for (std::size_t p = 0; p < U.extent(0); ++p)
88 for (std::size_t i = 0; i < r.extent(1); ++i)
91 for (std::size_t k = 0; k < J.extent(1); ++k)
92 acc +=
static_cast<Z
>(J(i, k)) * U(p, k);
97 std::transform(r.data_handle(), r.data_handle() + r.size(), r.data_handle(),
98 [detJ](
auto ri) { return ri / static_cast<Z>(detJ); });
102 template <
typename O,
typename P,
typename Q,
typename R>
107 = MDSPAN_IMPL_STANDARD_NAMESPACE::MDSPAN_IMPL_PROPOSED_NAMESPACE;
108 using T =
typename std::decay_t<O>::value_type;
109 using Z =
typename impl::scalar_value_type_t<T>;
110 for (std::size_t p = 0; p < U.extent(0); ++p)
112 MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan<
113 const T, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents<std::size_t, 2>>
114 _U(U.data_handle() + p * U.extent(1), J.extent(1), J.extent(1));
115 MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan<
116 T, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents<std::size_t, 2>>
117 _r(r.data_handle() + p * r.extent(1), K.extent(1), K.extent(1));
119 for (std::size_t i = 0; i < _r.extent(0); ++i)
121 for (std::size_t j = 0; j < _r.extent(1); ++j)
124 for (std::size_t k = 0; k < K.extent(0); ++k)
125 for (std::size_t l = 0; l < _U.extent(1); ++l)
126 acc +=
static_cast<Z
>(K(k, i)) * _U(k, l) *
static_cast<Z
>(K(l, j));
134 template <
typename O,
typename P,
typename Q,
typename R>
139 = MDSPAN_IMPL_STANDARD_NAMESPACE::MDSPAN_IMPL_PROPOSED_NAMESPACE;
140 using T =
typename std::decay_t<O>::value_type;
141 using Z =
typename impl::scalar_value_type_t<T>;
142 for (std::size_t p = 0; p < U.extent(0); ++p)
144 MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan<
145 const T, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents<std::size_t, 2>>
146 _U(U.data_handle() + p * U.extent(1), J.extent(1), J.extent(1));
147 MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan<
148 T, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents<std::size_t, 2>>
149 _r(r.data_handle() + p * r.extent(1), J.extent(0), J.extent(0));
152 for (std::size_t i = 0; i < _r.extent(0); ++i)
154 for (std::size_t j = 0; j < _r.extent(1); ++j)
157 for (std::size_t k = 0; k < J.extent(1); ++k)
158 for (std::size_t l = 0; l < _U.extent(1); ++l)
159 acc +=
static_cast<Z
>(J(i, k)) * _U(k, l) *
static_cast<Z
>(J(j, l));
165 std::transform(r.data_handle(), r.data_handle() + r.size(), r.data_handle(),
166 [detJ](
auto ri) { return ri / static_cast<Z>(detJ * detJ); });
Information about finite element maps.
Definition: maps.h:14
void l2_piola(O &&r, const P &U, const Q &, double detJ, const R &)
L2 Piola map.
Definition: maps.h:50
void covariant_piola(O &&r, const P &U, const Q &, double, const R &K)
Covariant Piola map.
Definition: maps.h:61
void contravariant_piola(O &&r, const P &U, const Q &J, double detJ, const R &)
Contravariant Piola map.
Definition: maps.h:81
void double_contravariant_piola(O &&r, const P &U, const Q &J, double detJ, const R &)
Double contravariant Piola map.
Definition: maps.h:135
void double_covariant_piola(O &&r, const P &U, const Q &J, double, const R &K)
Double covariant Piola map.
Definition: maps.h:103
type
Map type.
Definition: maps.h:39