21 contravariantPiola = 3,
22 doubleCovariantPiola = 4,
23 doubleContravariantPiola = 5,
27 template <
typename O,
typename P,
typename Q,
typename R>
28 void l2_piola(O&& r,
const P& U,
const Q& ,
double detJ,
const R& )
30 assert(U.extent(0) == r.extent(0));
31 assert(U.extent(1) == r.extent(1));
32 for (std::size_t i = 0; i < U.extent(0); ++i)
33 for (std::size_t j = 0; j < U.extent(1); ++j)
34 r(i, j) = U(i, j) / detJ;
38 template <
typename O,
typename P,
typename Q,
typename R>
42 using T =
typename std::decay_t<O>::value_type;
43 for (std::size_t p = 0; p < U.extent(0); ++p)
46 for (std::size_t i = 0; i < r.extent(1); ++i)
49 for (std::size_t k = 0; k < K.extent(0); ++k)
50 acc += K(k, i) * U(p, k);
57 template <
typename O,
typename P,
typename Q,
typename R>
61 using T =
typename std::decay_t<O>::value_type;
62 for (std::size_t p = 0; p < U.extent(0); ++p)
64 for (std::size_t i = 0; i < r.extent(1); ++i)
67 for (std::size_t k = 0; k < J.extent(1); ++k)
68 acc += J(i, k) * U(p, k);
73 std::transform(r.data_handle(), r.data_handle() + r.size(), r.data_handle(),
74 [detJ](
auto ri) { return ri / detJ; });
78 template <
typename O,
typename P,
typename Q,
typename R>
82 namespace stdex = std::experimental;
83 using T =
typename std::decay_t<O>::value_type;
84 for (std::size_t p = 0; p < U.extent(0); ++p)
86 stdex::mdspan<const T, stdex::dextents<std::size_t, 2>> _U(
87 U.data_handle() + p * U.extent(1), J.extent(1), J.extent(1));
88 stdex::mdspan<T, stdex::dextents<std::size_t, 2>> _r(
89 r.data_handle() + p * r.extent(1), K.extent(1), K.extent(1));
91 for (std::size_t i = 0; i < _r.extent(0); ++i)
93 for (std::size_t j = 0; j < _r.extent(1); ++j)
96 for (std::size_t k = 0; k < K.extent(0); ++k)
97 for (std::size_t l = 0; l < _U.extent(1); ++l)
98 acc += K(k, i) * _U(k, l) * K(l, j);
106 template <
typename O,
typename P,
typename Q,
typename R>
110 namespace stdex = std::experimental;
111 using T =
typename std::decay_t<O>::value_type;
113 for (std::size_t p = 0; p < U.extent(0); ++p)
115 stdex::mdspan<const T, stdex::dextents<std::size_t, 2>> _U(
116 U.data_handle() + p * U.extent(1), J.extent(1), J.extent(1));
117 stdex::mdspan<T, stdex::dextents<std::size_t, 2>> _r(
118 r.data_handle() + p * r.extent(1), J.extent(0), J.extent(0));
121 for (std::size_t i = 0; i < _r.extent(0); ++i)
123 for (std::size_t j = 0; j < _r.extent(1); ++j)
126 for (std::size_t k = 0; k < J.extent(1); ++k)
127 for (std::size_t l = 0; l < _U.extent(1); ++l)
128 acc += J(i, k) * _U(k, l) * J(j, l);
134 std::transform(r.data_handle(), r.data_handle() + r.size(), r.data_handle(),
135 [detJ](
auto ri) { return ri / (detJ * detJ); });