15#ifndef dealii_tensor_h
16#define dealii_tensor_h
27#ifdef DEAL_II_WITH_ADOLC
28# include <adolc/adouble.h>
33#include <boost/version.hpp>
34#if BOOST_VERSION >= 106400
35# include <boost/serialization/array_wrapper.hpp>
37# include <boost/serialization/array.hpp>
50template <
typename ElementType,
typename MemorySpace>
53template <
int dim,
typename Number>
57template <
int rank_,
int dim, typename Number =
double>
59template <typename Number>
61template <typename number>
102template <
int dim,
typename Number>
106 static_assert(dim >= 0,
107 "Tensors must have a dimension greater than or equal to one.");
122 static constexpr unsigned int rank = 0;
167 template <
typename OtherNumber>
176 template <
typename OtherNumber>
180#ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
272 template <
typename OtherNumber>
276#if defined(__INTEL_COMPILER) || defined(DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG)
289#ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
303 template <
typename OtherNumber>
312 template <
typename OtherNumber>
319 template <
typename OtherNumber>
326 template <
typename OtherNumber>
335 template <
typename OtherNumber>
344 template <
typename OtherNumber>
353 template <
typename OtherNumber>
362 template <
typename OtherNumber>
413 template <
class Iterator>
415 unroll(
const Iterator begin,
const Iterator end)
const;
422 template <
class Archive>
439 template <
int,
int,
typename>
518template <
int rank_,
int dim,
typename Number>
522 static_assert(rank_ >= 1,
523 "Tensors must have a rank greater than or equal to one.");
524 static_assert(dim >= 0,
525 "Tensors must have a dimension greater than or equal to zero.");
539 static constexpr unsigned int rank = rank_;
554 std::conditional_t<rank_ == 1, Number,
Tensor<rank_ - 1, dim, Number>>;
569 Number[(dim != 0) ? dim : 1],
599 template <
typename ElementType,
typename MemorySpace>
610 template <
typename OtherNumber>
617 template <
typename OtherNumber>
624 template <
typename OtherNumber>
628#ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
659 constexpr const Number &
699 template <
typename OtherNumber>
720#ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
737 template <
typename OtherNumber>
744 template <
typename OtherNumber>
753 template <
typename OtherNumber>
762 template <
typename OtherNumber>
772 template <
typename OtherNumber>
781 template <
typename OtherNumber>
839 template <
typename OtherNumber>
853 template <
class Iterator>
855 unroll(
const Iterator begin,
const Iterator end)
const;
876 static constexpr std::size_t
884 template <
class Archive>
900 std::conditional_t<rank_ == 1,
901 std::array<Number, dim>,
902 std::array<
Tensor<rank_ - 1, dim, Number>, dim>>
911 template <
typename ArrayLike, std::size_t... Indices>
913 Tensor(
const ArrayLike &initializer, std::index_sequence<Indices...>);
916 template <
int,
int,
typename>
921 friend class Point<dim, Number>;
932 template <
int rank,
int dim,
typename T,
typename U>
933 struct ProductTypeImpl<
Tensor<rank, dim, T>,
std::complex<U>>
939 template <
int rank,
int dim,
typename T,
typename U>
940 struct ProductTypeImpl<
Tensor<rank, dim,
std::complex<T>>, std::complex<U>>
946 template <
typename T,
int rank,
int dim,
typename U>
947 struct ProductTypeImpl<
std::complex<T>,
Tensor<rank, dim, U>>
953 template <
int rank,
int dim,
typename T,
typename U>
954 struct ProductTypeImpl<
std::complex<T>,
Tensor<rank, dim, std::complex<U>>>
965 template <
int rank,
int dim,
typename T>
966 struct NumberType<
Tensor<rank, dim, T>>
989template <
int dim,
typename Number>
999template <
int dim,
typename Number>
1000template <
typename OtherNumber>
1008template <
int dim,
typename Number>
1009template <
typename OtherNumber>
1016# ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
1017template <
int dim,
typename Number>
1025template <
int dim,
typename Number>
1028 :
value{std::move(other.value)}
1033template <
int dim,
typename Number>
1037 return std::addressof(value);
1042template <
int dim,
typename Number>
1043inline const Number *
1046 return std::addressof(value);
1051template <
int dim,
typename Number>
1055 return begin_raw() + n_independent_components;
1060template <
int dim,
typename Number>
1064 return begin_raw() + n_independent_components;
1069template <
int dim,
typename Number>
1074 ExcMessage(
"Cannot access an object of type Tensor<0,0,Number>"));
1079template <
int dim,
typename Number>
1084 ExcMessage(
"Cannot access an object of type Tensor<0,0,Number>"));
1090template <
int dim,
typename Number>
1091template <
typename OtherNumber>
1100# if defined(__INTEL_COMPILER) || defined(DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG)
1101template <
int dim,
typename Number>
1110# ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
1111template <
int dim,
typename Number>
1115 value = std::move(other.value);
1122template <
int dim,
typename Number>
1123template <
typename OtherNumber>
1132template <
int dim,
typename Number>
1133template <
typename OtherNumber>
1134constexpr inline bool
1137# ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING
1138 Assert(!(std::is_same_v<Number, adouble> ||
1139 std::is_same_v<OtherNumber, adouble>),
1141 "The Tensor equality operator for ADOL-C taped numbers has not yet "
1142 "been extended to support advanced branching."));
1149template <
int dim,
typename Number>
1150template <
typename OtherNumber>
1154 return !((*this) ==
p);
1158template <
int dim,
typename Number>
1159template <
typename OtherNumber>
1168template <
int dim,
typename Number>
1169template <
typename OtherNumber>
1181 namespace ComplexWorkaround
1183 template <
typename Number,
typename OtherNumber>
1185 multiply_assign_scalar(Number &val,
const OtherNumber &s)
1190 template <
typename Number,
typename OtherNumber>
1192 multiply_assign_scalar(std::complex<Number> &val,
const OtherNumber &s)
1194# if KOKKOS_VERSION >= 30600
1195 KOKKOS_IF_ON_HOST((val *= s;))
1196 KOKKOS_IF_ON_DEVICE(({
1200 "This function is not implemented for std::complex<Number>!\n");
1203# ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
1209 "This function is not implemented for std::complex<Number>!\n");
1217template <
int dim,
typename Number>
1218template <
typename OtherNumber>
1222 internal::ComplexWorkaround::multiply_assign_scalar(value, s);
1228template <
int dim,
typename Number>
1229template <
typename OtherNumber>
1238template <
int dim,
typename Number>
1246template <
int dim,
typename Number>
1251 ExcMessage(
"Cannot access an object of type Tensor<0,0,Number>"));
1256template <
int dim,
typename Number>
1262 ExcMessage(
"Cannot access an object of type Tensor<0,0,Number>"));
1268template <
int dim,
typename Number>
1269constexpr inline void
1279template <
int dim,
typename Number>
1280template <
class Iterator>
1287 ExcMessage(
"Cannot unroll an object of type Tensor<0,0,Number>"));
1288 Assert(std::distance(begin, end) >= 1,
1289 ExcMessage(
"The provided iterator range must contain at least one "
1296template <
int dim,
typename Number>
1297template <
class Archive>
1305template <
int dim,
typename Number>
1311template <
int rank_,
int dim,
typename Number>
1312template <
typename ArrayLike, std::size_t... indices>
1315 std::index_sequence<indices...>)
1332 if constexpr (rank_ == 1)
1338 static_assert(
sizeof...(indices) == dim,
1339 "dim should match the number of indices");
1343# ifdef DEAL_II_HAVE_CXX20
1345template <
int rank_,
int dim,
typename Number>
1380 []<
std::size_t... I>(
1381 const
std::index_sequence<I...> &) constexpr -> decltype(
values) {
1382 if constexpr (rank_ == 1)
1384 auto get_zero_and_ignore_argument = [](
int) {
1387 return {{(get_zero_and_ignore_argument(I))...}};
1391 auto get_zero_and_ignore_argument = [](
int) {
1392 return Tensor<rank_ - 1, dim, Number>();
1394 return {{(get_zero_and_ignore_argument(I))...}};
1396 }(std::make_index_sequence<dim>()))
1412 namespace TensorInitialization
1414 template <
int rank,
int dim,
typename Number, std::size_t... I>
1415 constexpr std::array<typename Tensor<rank, dim, Number>::value_type, dim>
1416 make_zero_array(
const std::index_sequence<I...> &)
1418 static_assert(
sizeof...(I) == dim,
"This is bad.");
1424 if constexpr (dim == 0)
1428 else if constexpr (rank == 1)
1430 auto get_zero_and_ignore_argument = [](
int) {
1433 return {{(get_zero_and_ignore_argument(I))...}};
1437 auto get_zero_and_ignore_argument = [](
int) {
1438 return Tensor<rank - 1, dim, Number>();
1440 return {{(get_zero_and_ignore_argument(I))...}};
1447template <
int rank_,
int dim,
typename Number>
1450 :
values(
internal::TensorInitialization::make_zero_array<rank_, dim, Number>(
1451 std::make_index_sequence<dim>()))
1458template <
int rank_,
int dim,
typename Number>
1461 :
Tensor(initializer,
std::make_index_sequence<dim>{})
1466template <
int rank_,
int dim,
typename Number>
1467template <
typename ElementType,
typename MemorySpace>
1473 const int my_n_independent_components = n_independent_components;
1476 for (
unsigned int i = 0; i < my_n_independent_components; ++i)
1477 (*
this)[unrolled_to_component_indices(i)] = initializer[i];
1482template <
int rank_,
int dim,
typename Number>
1483template <
typename OtherNumber>
1487 :
Tensor(initializer,
std::make_index_sequence<dim>{})
1492template <
int rank_,
int dim,
typename Number>
1493template <
typename OtherNumber>
1497 :
Tensor(initializer,
std::make_index_sequence<dim>{})
1502template <
int rank_,
int dim,
typename Number>
1503template <
typename OtherNumber>
1505operator
Tensor<1, dim,
Tensor<rank_ - 1, dim, OtherNumber>>()
const
1508 std::copy(
values.begin(),
values.end(), x.values.begin());
1513# ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
1514template <
int rank_,
int dim,
typename Number>
1522template <
int rank_,
int dim,
typename Number>
1525 :
values(std::move(other.values))
1531template <
int rank_,
int dim,
typename Number>
1537 ExcMessage(
"Cannot access an object of type Tensor<rank_,0,Number>"));
1545template <
int rank_,
int dim,
typename Number>
1551 ExcMessage(
"Cannot access an object of type Tensor<rank_,0,Number>"));
1559template <
int rank_,
int dim,
typename Number>
1564 ExcMessage(
"Cannot access an object of type Tensor<rank_,0,Number>"));
1566 return TensorAccessors::extract<rank_>(*
this, indices);
1571template <
int rank_,
int dim,
typename Number>
1576 ExcMessage(
"Cannot access an object of type Tensor<rank_,0,Number>"));
1578 return TensorAccessors::extract<rank_>(*
this, indices);
1583template <
int rank_,
int dim,
typename Number>
1587 return std::addressof(
1588 this->
operator[](this->unrolled_to_component_indices(0)));
1593template <
int rank_,
int dim,
typename Number>
1594inline const Number *
1597 return std::addressof(
1598 this->
operator[](this->unrolled_to_component_indices(0)));
1603template <
int rank_,
int dim,
typename Number>
1607 return begin_raw() + n_independent_components;
1612template <
int rank_,
int dim,
typename Number>
1613inline const Number *
1616 return begin_raw() + n_independent_components;
1621template <
int rank_,
int dim,
typename Number>
1622template <
typename OtherNumber>
1628 for (
unsigned int i = 0; i < dim; ++i)
1635template <
int rank_,
int dim,
typename Number>
1643 for (
unsigned int i = 0; i < dim; ++i)
1649# ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
1650template <
int rank_,
int dim,
typename Number>
1654 for (
unsigned int i = 0; i < dim; ++i)
1655 values[i] = other.
values[i];
1661template <
int rank_,
int dim,
typename Number>
1666 for (
unsigned int i = 0; i < dim; ++i)
1667 values[i] = other.
values[i];
1673template <
int rank_,
int dim,
typename Number>
1674template <
typename OtherNumber>
1675constexpr inline bool
1679# ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING
1680 Assert(!(std::is_same_v<Number, adouble> ||
1681 std::is_same_v<OtherNumber, adouble>),
1683 "The Tensor equality operator for ADOL-C taped numbers has not yet "
1684 "been extended to support advanced branching."));
1687 for (
unsigned int i = 0; i < dim; ++i)
1701constexpr inline bool
1708template <
int rank_,
int dim,
typename Number>
1709template <
typename OtherNumber>
1714 return !((*this) ==
p);
1718template <
int rank_,
int dim,
typename Number>
1719template <
typename OtherNumber>
1725 for (
unsigned int i = 0; i < dim; ++i)
1731template <
int rank_,
int dim,
typename Number>
1732template <
typename OtherNumber>
1738 for (
unsigned int i = 0; i < dim; ++i)
1744template <
int rank_,
int dim,
typename Number>
1745template <
typename OtherNumber>
1750 for (
unsigned int i = 0; i < dim; ++i)
1757template <
int rank_,
int dim,
typename Number>
1758template <
typename OtherNumber>
1763 if constexpr (std::is_integral<
1765 std::is_same_v<Number, Differentiation::SD::Expression>)
1768 for (
unsigned int d = 0;
d < dim; ++
d)
1775 const Number inverse_factor = Number(1.) / s;
1776 for (
unsigned int d = 0;
d < dim; ++
d)
1777 values[d] *= inverse_factor;
1784template <
int rank_,
int dim,
typename Number>
1791 for (
unsigned int i = 0; i < dim; ++i)
1792 tmp.
values[i] = -values[i];
1798template <
int rank_,
int dim,
typename Number>
1804 if constexpr ((rank_ == 1) && (dim == 1) && std::is_arithmetic_v<Number>)
1808 else if constexpr ((rank_ == 2) && (dim == 1) && std::is_arithmetic_v<Number>)
1821 return sqrt(norm_square());
1826template <
int rank_,
int dim,
typename Number>
1831 if constexpr (dim == 0)
1834 else if constexpr (rank_ == 1)
1840 for (
unsigned int i = 1; i < dim; ++i)
1851 for (
unsigned int i = 1; i < dim; ++i)
1852 s += values[i].norm_square();
1860template <
int rank_,
int dim,
typename Number>
1861template <
typename OtherNumber>
1865 unroll(result.
begin(), result.
end());
1870template <
int rank_,
int dim,
typename Number>
1871template <
class Iterator>
1874 const Iterator end)
const
1876 if constexpr (rank_ > 1)
1879 Iterator next =
begin;
1880 for (
unsigned int i = 0; i < dim; ++i)
1882 values[i].unroll(next, end);
1893 Assert(std::distance(begin, end) >= dim,
1895 "The provided iterator range must contain at least 'dim' "
1897 std::copy(std::begin(values), std::end(values), begin);
1903template <
int rank_,
int dim,
typename Number>
1904constexpr inline unsigned int
1908 unsigned int index = 0;
1909 for (
int r = 0; r < rank_; ++r)
1910 index = index * dim + indices[r];
1917template <
int rank_,
int dim,
typename Number>
1922 unsigned int dummy = n_independent_components;
1926 if constexpr (dim == 0)
1930 "A tensor with dimension 0 does not store any elements. "
1931 "There is no indexing that can address its elements."));
1938 unsigned int remainder = i;
1939 for (
int r = rank_ - 1; r >= 0; --r)
1941 indices[r] = remainder % dim;
1942 remainder = remainder / dim;
1951template <
int rank_,
int dim,
typename Number>
1952constexpr inline void
1955 for (
unsigned int i = 0; i < dim; ++i)
1960template <
int rank_,
int dim,
typename Number>
1961constexpr std::size_t
1968template <
int rank_,
int dim,
typename Number>
1969template <
class Archive>
1973 if constexpr (rank_ > 1)
1976 ar &boost::serialization::make_array(&values[0], dim);
1980template <
int rank_,
int dim,
typename Number>
1999template <
int rank_,
int dim,
typename Number>
2000inline std::ostream &
2003 for (
unsigned int i = 0; i < dim; ++i)
2007 for (
unsigned int j = 0; j < rank_; ++j)
2021template <
int dim,
typename Number>
2022inline std::ostream &
2025 out << static_cast<const Number &>(p);
2048template <
int dim,
typename Number,
typename Other>
2053 return object *
static_cast<const Number &
>(t);
2068template <
int dim,
typename Number,
typename Other>
2073 return static_cast<const Number &
>(t) *
object;
2088template <
int dim,
typename Number,
typename OtherNumber>
2094 return static_cast<const Number &
>(src1) *
2095 static_cast<const OtherNumber &
>(src2);
2106template <
int dim,
typename Number,
typename OtherNumber>
2114 return static_cast<const Number &
>(t) / factor;
2125template <
int dim,
typename Number,
typename OtherNumber>
2131 return static_cast<const Number &
>(p) +
static_cast<const OtherNumber &
>(q);
2142template <
int dim,
typename Number,
typename OtherNumber>
2148 return static_cast<const Number &
>(p) -
static_cast<const OtherNumber &
>(q);
2164template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2174 for (
unsigned int d = 0; d < dim; ++d)
2175 tt[d] = t[d] * factor;
2192template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2215template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2224 if constexpr (std::is_integral<
2228 for (
unsigned int d = 0; d < dim; ++d)
2229 tt[d] = t[d] / factor;
2233 const Number inverse_factor = Number(1.) / factor;
2235 for (
unsigned int d = 0; d < dim; ++d)
2236 tt[d] = t[d] * inverse_factor;
2251template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2259 for (
unsigned int i = 0; i < dim; ++i)
2275template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2283 for (
unsigned int i = 0; i < dim; ++i)
2295template <
int dim,
typename Number,
typename OtherNumber>
2324template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2332 for (
unsigned int i = 0; i < dim; ++i)
2383template <
int rank_1,
2387 typename OtherNumber,
2388 typename = std::enable_if_t<rank_1 >= 1 && rank_2 >= 1>>
2390 typename Tensor<rank_1 + rank_2 - 2,
2396 typename Tensor<rank_1 + rank_2 - 2,
2401 TensorAccessors::internal::
2402 ReorderedIndexView<0, rank_2, const Tensor<rank_2, dim, OtherNumber>>
2403 reordered = TensorAccessors::reordered_index_view<0, rank_2>(src2);
2404 TensorAccessors::contract<1, rank_1, rank_2, dim>(result, src1, reordered);
2438template <
int index_1,
2444 typename OtherNumber>
2446 typename Tensor<rank_1 + rank_2 - 2,
2452 Assert(0 <= index_1 && index_1 < rank_1,
2454 "The specified index_1 must lie within the range [0,rank_1)"));
2455 Assert(0 <= index_2 && index_2 < rank_2,
2457 "The specified index_2 must lie within the range [0,rank_2)"));
2464 reord_01 = reordered_index_view<index_1, rank_1>(src1);
2470 reord_02 = reordered_index_view<index_2, rank_2>(src2);
2472 typename Tensor<rank_1 + rank_2 - 2,
2476 TensorAccessors::contract<1, rank_1, rank_2, dim>(result, reord_01, reord_02);
2511template <
int index_1,
2519 typename OtherNumber>
2521 typename Tensor<rank_1 + rank_2 - 4,
2527 Assert(0 <= index_1 && index_1 < rank_1,
2529 "The specified index_1 must lie within the range [0,rank_1)"));
2530 Assert(0 <= index_3 && index_3 < rank_1,
2532 "The specified index_3 must lie within the range [0,rank_1)"));
2533 Assert(index_1 != index_3,
2534 ExcMessage(
"index_1 and index_3 must not be the same"));
2535 Assert(0 <= index_2 && index_2 < rank_2,
2537 "The specified index_2 must lie within the range [0,rank_2)"));
2538 Assert(0 <= index_4 && index_4 < rank_2,
2540 "The specified index_4 must lie within the range [0,rank_2)"));
2541 Assert(index_2 != index_4,
2542 ExcMessage(
"index_2 and index_4 must not be the same"));
2549 reord_1 = TensorAccessors::reordered_index_view<index_1, rank_1>(src1);
2553 reord_2 = TensorAccessors::reordered_index_view<index_2, rank_2>(src2);
2559 (index_3 < index_1 ? index_3 : index_3 - 1),
2571 (index_4 < index_2 ? index_4 : index_4 - 1),
2579 typename Tensor<rank_1 + rank_2 - 4,
2583 TensorAccessors::contract<2, rank_1, rank_2, dim>(result, reord_3, reord_4);
2600template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2607 TensorAccessors::contract<rank, rank, rank, dim>(result, left, right);
2629template <
template <
int,
int,
typename>
class TensorT1,
2630 template <
int,
int,
typename>
2632 template <
int,
int,
typename>
2642 contract3(
const TensorT1<rank_1, dim, T1> &left,
2643 const TensorT2<rank_1 + rank_2, dim, T2> &middle,
2644 const TensorT3<rank_2, dim, T3> &right)
2648 return TensorAccessors::contract3<rank_1, rank_2, dim, return_type>(left,
2664template <
int rank_1,
2668 typename OtherNumber>
2674 typename Tensor<rank_1 + rank_2,
2678 TensorAccessors::contract<0, rank_1, rank_2, dim>(result, src1, src2);
2701template <
int dim,
typename Number>
2710 result[1] = -src[0];
2725template <
int dim,
typename Number1,
typename Number2>
2736 constexpr int s0 = 0 % dim;
2737 constexpr int s1 = 1 % dim;
2738 constexpr int s2 = 2 % dim;
2740 result[s0] = src1[s1] * src2[s2] - src1[s2] * src2[s1];
2741 result[s1] = src1[s2] * src2[s0] - src1[s0] * src2[s2];
2742 result[s2] = src1[s0] * src2[s1] - src1[s1] * src2[s0];
2761template <
int dim,
typename Number>
2769 for (
unsigned int k = 0; k < dim; ++k)
2771 Tensor<2, dim - 1, Number> minor;
2772 for (
unsigned int i = 0; i < dim - 1; ++i)
2773 for (
unsigned int j = 0; j < dim - 1; ++j)
2774 minor[i][j] = t[i][j < k ? j : j + 1];
2776 const Number cofactor = ((k % 2 == 0) ? -1. : 1.) *
determinant(minor);
2778 det += t[dim - 1][k] * cofactor;
2781 return ((dim % 2 == 0) ? 1. : -1.) * det;
2789template <
typename Number>
2801template <
typename Number>
2806 return t[0][0] * t[1][1] - t[1][0] * t[0][1];
2814template <
typename Number>
2825 return t[0][0] * C0 + t[0][1] * C1 + t[0][2] * C2;
2835template <
int dim,
typename Number>
2840 for (
unsigned int i = 1; i < dim; ++i)
2854template <
int dim,
typename Number>
2858 Number return_tensor[dim][dim];
2871template <
typename Number>
2879 return return_tensor;
2883template <
typename Number>
2890 1.0 / (t[0][0] * t[1][1] - t[1][0] * t[0][1]));
2891 return_tensor[0][0] = t[1][1];
2892 return_tensor[0][1] = -t[0][1];
2893 return_tensor[1][0] = -t[1][0];
2894 return_tensor[1][1] = t[0][0];
2895 return_tensor *= inv_det_t;
2897 return return_tensor;
2901template <
typename Number>
2926 1.0 / (t[0][0] * return_tensor[0][0] + t[0][1] * return_tensor[1][0] +
2927 t[0][2] * return_tensor[2][0]));
2928 return_tensor *= inv_det_t;
2930 return return_tensor;
2941template <
int dim,
typename Number>
2946 for (
unsigned int i = 0; i < dim; ++i)
2949 for (
unsigned int j = i + 1; j < dim; ++j)
2972template <
int dim,
typename Number>
2993template <
int dim,
typename Number>
3064template <
int dim,
typename Number>
3076template <
int dim,
typename Number>
3081 for (
unsigned int j = 0; j < dim; ++j)
3084 for (
unsigned int i = 0; i < dim; ++i)
3102template <
int dim,
typename Number>
3107 for (
unsigned int i = 0; i < dim; ++i)
3110 for (
unsigned int j = 0; j < dim; ++j)
3128# ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING
3137 for (
unsigned int j = 0; j < dim; ++j)
3140 for (
unsigned int i = 0; i < dim; ++i)
3141 sum += fabs(t[i][j]);
3143 condassign(max, (sum > max), sum, max);
3155 for (
unsigned int i = 0; i < dim; ++i)
3158 for (
unsigned int j = 0; j < dim; ++j)
3159 sum +=
fabs(t[i][j]);
3161 condassign(max, (sum > max), sum, max);
constexpr Tensor & operator*=(const OtherNumber &factor)
constexpr Tensor & operator=(const OtherNumber &d) &&=delete
void serialize(Archive &ar, const unsigned int version)
constexpr Tensor & operator/=(const OtherNumber &factor)
const Number * end_raw() const
constexpr Tensor & operator-=(const Tensor< 0, dim, OtherNumber > &rhs)
constexpr Tensor(const Tensor< 0, dim, OtherNumber > &initializer)
constexpr Tensor(const OtherNumber &initializer)
constexpr real_type norm_square() const
constexpr bool operator!=(const Tensor< 0, dim, OtherNumber > &rhs) const
constexpr Tensor & operator=(const Tensor< 0, dim, OtherNumber > &rhs)
const Number * begin_raw() const
constexpr Tensor & operator+=(const Tensor< 0, dim, OtherNumber > &rhs)
void unroll(const Iterator begin, const Iterator end) const
constexpr bool operator==(const Tensor< 0, dim, OtherNumber > &rhs) const
typename numbers::NumberTraits< Number >::real_type real_type
constexpr Tensor & operator=(const OtherNumber &d) &
constexpr Tensor operator-() const
constexpr Tensor & operator/=(const OtherNumber &factor)
constexpr Tensor(const ArrayView< ElementType, MemorySpace > &initializer)
constexpr bool operator==(const Tensor< rank_, dim, OtherNumber > &) const
constexpr Tensor< rank, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator/(const Tensor< rank, dim, Number > &t, const OtherNumber &factor)
constexpr Tensor(const Tensor< 1, dim, Tensor< rank_ - 1, dim, OtherNumber > > &initializer)
constexpr const Number & operator[](const TableIndices< rank_ > &indices) const
constexpr Tensor< 0, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator/(const Tensor< 0, dim, Number > &t, const OtherNumber &factor)
static constexpr unsigned int rank
constexpr Tensor(const Tensor< rank_, dim, OtherNumber > &initializer)
std::conditional_t< rank_==1, Number, Tensor< rank_ - 1, dim, Number > > value_type
numbers::NumberTraits< Number >::real_type norm() const
constexpr Tensor & operator-=(const Tensor< rank_, dim, OtherNumber > &)
void unroll(const Iterator begin, const Iterator end) const
void unroll(Vector< OtherNumber > &result) const
static constexpr unsigned int component_to_unrolled_index(const TableIndices< rank_ > &indices)
constexpr ProductType< Number, OtherNumber >::type operator*(const Tensor< 0, dim, Number > &src1, const Tensor< 0, dim, OtherNumber > &src2)
const Number * begin_raw() const
std::conditional_t< rank_==1, Number[(dim !=0) ? dim :1], typename Tensor< rank_ - 1, dim, Number >::array_type[(dim !=0) ? dim :1]> array_type
constexpr bool operator!=(const Tensor< rank_, dim, OtherNumber > &) const
constexpr Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > schur_product(const Tensor< 0, dim, Number > &src1, const Tensor< 0, dim, OtherNumber > &src2)
constexpr value_type & operator[](const unsigned int i)
constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > operator-(const Tensor< 0, dim, Number > &p, const Tensor< 0, dim, OtherNumber > &q)
constexpr Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator+(const Tensor< rank, dim, Number > &p, const Tensor< rank, dim, OtherNumber > &q)
Number linfty_norm(const Tensor< 2, dim, Number > &t)
constexpr ProductType< Other, Number >::type operator*(const Other &object, const Tensor< 0, dim, Number > &t)
constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE Tensor()
Number l1_norm(const Tensor< 2, dim, Number > &t)
static constexpr unsigned int dimension
static constexpr TableIndices< rank_ > unrolled_to_component_indices(const unsigned int i)
constexpr Tensor & operator=(const Number &d) &&=delete
constexpr Tensor< rank, dim, typename ProductType< typename EnableIfScalar< Number >::type, OtherNumber >::type > operator*(const Number &factor, const Tensor< rank, dim, OtherNumber > &t)
static constexpr std::size_t memory_consumption()
constexpr Tensor & operator=(const Number &d) &
std::conditional_t< rank_==1, std::array< Number, dim >, std::array< Tensor< rank_ - 1, dim, Number >, dim > > values
constexpr Tensor & operator+=(const Tensor< rank_, dim, OtherNumber > &)
constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > operator+(const Tensor< 0, dim, Number > &p, const Tensor< 0, dim, OtherNumber > &q)
const Number * end_raw() const
constexpr Number & operator[](const TableIndices< rank_ > &indices)
constexpr Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > schur_product(const Tensor< rank, dim, Number > &src1, const Tensor< rank, dim, OtherNumber > &src2)
constexpr numbers::NumberTraits< Number >::real_type norm_square() const
constexpr Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator-(const Tensor< rank, dim, Number > &p, const Tensor< rank, dim, OtherNumber > &q)
constexpr ProductType< Number, Other >::type operator*(const Tensor< 0, dim, Number > &t, const Other &object)
constexpr Tensor(const ArrayLike &initializer, std::index_sequence< Indices... >)
constexpr Tensor< rank, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator*(const Tensor< rank, dim, Number > &t, const OtherNumber &factor)
void serialize(Archive &ar, const unsigned int version)
constexpr Tensor & operator*=(const OtherNumber &factor)
constexpr const value_type & operator[](const unsigned int i) const
constexpr Tensor(const array_type &initializer)
static constexpr unsigned int n_independent_components
constexpr Tensor operator-() const
constexpr Tensor & operator=(const Tensor< rank_, dim, OtherNumber > &rhs)
#define DEAL_II_ALWAYS_INLINE
#define DEAL_II_DEPRECATED
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_CXX20_REQUIRES(condition)
#define DEAL_II_CXX23_ASSUME(expr)
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
static ::ExceptionBase & ExcScalarAssignmentOnlyForZeroValue()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
Expression fabs(const Expression &x)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
constexpr internal::ReorderedIndexView< index, rank, T > reordered_index_view(T &t)
constexpr void contract(T1 &result, const T2 &left, const T3 &right)
constexpr T1 contract3(const T2 &left, const T3 &middle, const T4 &right)
T sum(const T &t, const MPI_Comm mpi_communicator)
constexpr bool values_are_not_equal(const Number1 &value_1, const Number2 &value_2)
constexpr bool value_is_zero(const Number &value)
constexpr bool values_are_equal(const Number1 &value_1, const Number2 &value_2)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)
#define DEAL_II_HOST_DEVICE
#define DEAL_II_HOST_DEVICE_ALWAYS_INLINE
typename internal::ProductTypeImpl< std::decay_t< T >, std::decay_t< U > >::type type
static constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE const T & value(const T &t)
decltype(std::declval< T >() *std::declval< U >()) type
static real_type abs(const number &x)
static constexpr real_type abs_square(const number &x)
DEAL_II_HOST constexpr Number determinant(const SymmetricTensor< 2, dim, Number > &)
DEAL_II_HOST constexpr SymmetricTensor< 2, dim, Number > invert(const SymmetricTensor< 2, dim, Number > &)
DEAL_II_HOST constexpr SymmetricTensor< 4, dim, Number > outer_product(const SymmetricTensor< 2, dim, Number > &t1, const SymmetricTensor< 2, dim, Number > &t2)
DEAL_II_HOST constexpr Number trace(const SymmetricTensor< 2, dim2, Number > &)
Tensor< 2, dim, Number > project_onto_orthogonal_tensors(const Tensor< 2, dim, Number > &A)
std::ostream & operator<<(std::ostream &out, const Tensor< rank_, dim, Number > &p)
constexpr Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > schur_product(const Tensor< 0, dim, Number > &src1, const Tensor< 0, dim, OtherNumber > &src2)
Number linfty_norm(const Tensor< 2, dim, Number > &t)
constexpr ProductType< Other, Number >::type operator*(const Other &object, const Tensor< 0, dim, Number > &t)
Number l1_norm(const Tensor< 2, dim, Number > &t)