13#ifndef dealii_tensor_h
14#define dealii_tensor_h
25#include <Kokkos_Array.hpp>
27#ifdef DEAL_II_WITH_ADOLC
28# include <adolc/adouble.h>
40template <
typename ElementType,
typename MemorySpace>
43template <
int dim,
typename Number>
47template <
int rank_,
int dim, typename Number =
double>
49template <typename Number>
51template <typename number>
92template <
int dim,
typename Number>
96 static_assert(dim >= 0,
97 "Tensors must have a dimension greater than or equal to one.");
112 static constexpr unsigned int rank = 0;
157 template <
typename OtherNumber>
166 template <
typename OtherNumber>
170#ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
205 operator const Number &()
const;
214 template <
typename OtherNumber>
218#if defined(__INTEL_COMPILER) || defined(DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG)
231#ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
245 template <
typename OtherNumber>
254 template <
typename OtherNumber>
261 template <
typename OtherNumber>
268 template <
typename OtherNumber>
277 template <
typename OtherNumber>
286 template <
typename OtherNumber>
295 template <
typename OtherNumber>
304 template <
typename OtherNumber>
355 template <
class Iterator>
364 template <
class Archive>
381 template <
int,
int,
typename>
460template <
int rank_,
int dim,
typename Number>
464 static_assert(rank_ >= 1,
465 "Tensors must have a rank greater than or equal to one.");
466 static_assert(dim >= 0,
467 "Tensors must have a dimension greater than or equal to zero.");
481 static constexpr unsigned int rank = rank_;
506 std::conditional_t<rank_ == 1, Number,
Tensor<rank_ - 1, dim, Number>>;
521 Number[(dim != 0) ? dim : 1],
551 template <
typename ElementType,
typename MemorySpace>
562 template <
typename OtherNumber>
569 template <
typename OtherNumber>
576 template <
typename OtherNumber>
580#ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
611 constexpr const Number &
655 template <
typename OtherNumber>
676#ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
693 template <
typename OtherNumber>
700 template <
typename OtherNumber>
709 template <
typename OtherNumber>
718 template <
typename OtherNumber>
728 template <
typename OtherNumber>
737 template <
typename OtherNumber>
795 template <
class Iterator>
818 static constexpr std::size_t
826 template <
class Archive>
842#if DEAL_II_KOKKOS_VERSION_GTE(3, 7, 0)
843 std::conditional_t<rank_ == 1,
844 Kokkos::Array<Number, dim>,
845 Kokkos::Array<
Tensor<rank_ - 1, dim, Number>, dim>>
847 std::conditional_t<rank_ == 1,
848 std::array<Number, dim>,
849 std::array<
Tensor<rank_ - 1, dim, Number>, dim>>
859 template <
typename ArrayLike, std::size_t... Indices>
861 Tensor(
const ArrayLike &initializer, std::index_sequence<Indices...>);
864 template <
int,
int,
typename>
869 friend class Point<dim, Number>;
880 template <
int rank,
int dim,
typename T,
typename U>
881 struct ProductTypeImpl<
Tensor<rank, dim, T>,
std::complex<U>>
887 template <
int rank,
int dim,
typename T,
typename U>
888 struct ProductTypeImpl<
Tensor<rank, dim,
std::complex<T>>, std::complex<U>>
894 template <
typename T,
int rank,
int dim,
typename U>
895 struct ProductTypeImpl<
std::complex<T>,
Tensor<rank, dim, U>>
901 template <
int rank,
int dim,
typename T,
typename U>
902 struct ProductTypeImpl<
std::complex<T>,
Tensor<rank, dim, std::complex<U>>>
913 template <
int rank,
int dim,
typename T>
914 struct NumberType<
Tensor<rank, dim,
T>>
937template <
int dim,
typename Number>
947template <
int dim,
typename Number>
948template <
typename OtherNumber>
956template <
int dim,
typename Number>
957template <
typename OtherNumber>
964# ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
965template <
int dim,
typename Number>
973template <
int dim,
typename Number>
976 :
value{std::move(other.value)}
982template <
int dim,
typename Number>
987 ExcMessage(
"Cannot access an object of type Tensor<0,0,Number>"));
992template <
int dim,
typename Number>
995 operator
const Number &()
const
998 ExcMessage(
"Cannot access an object of type Tensor<0,0,Number>"));
1004template <
int dim,
typename Number>
1005template <
typename OtherNumber>
1014# if defined(__INTEL_COMPILER) || defined(DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG)
1015template <
int dim,
typename Number>
1024# ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
1025template <
int dim,
typename Number>
1029 value = std::move(other.value);
1036template <
int dim,
typename Number>
1037template <
typename OtherNumber>
1046template <
int dim,
typename Number>
1047template <
typename OtherNumber>
1048constexpr inline bool
1051# ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING
1052 Assert(!(std::is_same_v<Number, adouble> ||
1053 std::is_same_v<OtherNumber, adouble>),
1055 "The Tensor equality operator for ADOL-C taped numbers has not yet "
1056 "been extended to support advanced branching."));
1063template <
int dim,
typename Number>
1064template <
typename OtherNumber>
1068 return !((*this) == p);
1072template <
int dim,
typename Number>
1073template <
typename OtherNumber>
1082template <
int dim,
typename Number>
1083template <
typename OtherNumber>
1095 namespace ComplexWorkaround
1097 template <
typename Number,
typename OtherNumber>
1099 multiply_assign_scalar(Number &val,
const OtherNumber &s)
1104 template <
typename Number,
typename OtherNumber>
1106 multiply_assign_scalar(std::complex<Number> &val,
const OtherNumber &s)
1108# if DEAL_II_KOKKOS_VERSION_GTE(3, 6, 0)
1109 KOKKOS_IF_ON_HOST((val *= s;))
1110 KOKKOS_IF_ON_DEVICE(({
1114 "This function is not implemented for std::complex<Number>!\n");
1125template <
int dim,
typename Number>
1126template <
typename OtherNumber>
1130 internal::ComplexWorkaround::multiply_assign_scalar(value, s);
1136template <
int dim,
typename Number>
1137template <
typename OtherNumber>
1146template <
int dim,
typename Number>
1154template <
int dim,
typename Number>
1159 ExcMessage(
"Cannot access an object of type Tensor<0,0,Number>"));
1164template <
int dim,
typename Number>
1170 ExcMessage(
"Cannot access an object of type Tensor<0,0,Number>"));
1176template <
int dim,
typename Number>
1177constexpr inline void
1187template <
int dim,
typename Number>
1188template <
class Iterator>
1194 ExcMessage(
"Cannot unroll an object of type Tensor<0,0,Number>"));
1196 ExcMessage(
"The provided iterator range must contain at least one "
1203template <
int dim,
typename Number>
1204template <
class Archive>
1212template <
int dim,
typename Number>
1218template <
int rank_,
int dim,
typename Number>
1219template <
typename ArrayLike, std::size_t... indices>
1222 std::index_sequence<indices...>)
1239 if constexpr (rank_ == 1)
1245 static_assert(
sizeof...(indices) == dim,
1246 "dim should match the number of indices");
1250# if defined(DEAL_II_HAVE_CXX20) && !defined(__NVCC__)
1252template <
int rank_,
int dim,
typename Number>
1287 []<
std::size_t... I>(
1288 const std::index_sequence<I...> &) constexpr -> decltype(
values) {
1289 if constexpr (dim == 0)
1293 else if constexpr (rank_ == 1)
1295 auto get_zero_and_ignore_argument = [](
int) {
1298 return {{(get_zero_and_ignore_argument(I))...}};
1302 auto get_zero_and_ignore_argument = [](
int) {
1305 return {{(get_zero_and_ignore_argument(I))...}};
1307 }(std::make_index_sequence<dim>()))
1323 namespace TensorInitialization
1325 template <
int rank,
int dim,
typename Number, std::size_t... I>
1326# if DEAL_II_KOKKOS_VERSION_GTE(3, 7, 0)
1327 constexpr Kokkos::Array<typename Tensor<rank, dim, Number>::value_type, dim>
1329 constexpr std::array<typename Tensor<rank, dim, Number>::value_type, dim>
1331 make_zero_array(
const std::index_sequence<I...> &)
1333 static_assert(
sizeof...(I) == dim,
"This is bad.");
1339 if constexpr (dim == 0)
1343 else if constexpr (rank == 1)
1345 auto get_zero_and_ignore_argument = [](
int) {
1348 return {{(get_zero_and_ignore_argument(I))...}};
1352 auto get_zero_and_ignore_argument = [](
int) {
1355 return {{(get_zero_and_ignore_argument(I))...}};
1362template <
int rank_,
int dim,
typename Number>
1366 std::make_index_sequence<dim>()))
1373template <
int rank_,
int dim,
typename Number>
1376 :
Tensor(initializer,
std::make_index_sequence<dim>{})
1381template <
int rank_,
int dim,
typename Number>
1382template <
typename ElementType,
typename MemorySpace>
1388 const int my_n_independent_components = n_independent_components;
1391 for (
unsigned int i = 0; i < my_n_independent_components; ++i)
1392 (*
this)[unrolled_to_component_indices(i)] = initializer[i];
1397template <
int rank_,
int dim,
typename Number>
1398template <
typename OtherNumber>
1402 :
Tensor(initializer,
std::make_index_sequence<dim>{})
1407template <
int rank_,
int dim,
typename Number>
1408template <
typename OtherNumber>
1412 :
Tensor(initializer,
std::make_index_sequence<dim>{})
1417template <
int rank_,
int dim,
typename Number>
1418template <
typename OtherNumber>
1420operator
Tensor<1, dim,
Tensor<rank_ - 1, dim, OtherNumber>>()
const
1428# ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
1429template <
int rank_,
int dim,
typename Number>
1437template <
int rank_,
int dim,
typename Number>
1440 :
values(std::move(other.values))
1446template <
int rank_,
int dim,
typename Number>
1452 ExcMessage(
"Cannot access an object of type Tensor<rank_,0,Number>"));
1460template <
int rank_,
int dim,
typename Number>
1466 ExcMessage(
"Cannot access an object of type Tensor<rank_,0,Number>"));
1474template <
int rank_,
int dim,
typename Number>
1479 ExcMessage(
"Cannot access an object of type Tensor<rank_,0,Number>"));
1481 return TensorAccessors::extract<rank_>(*
this, indices);
1486template <
int rank_,
int dim,
typename Number>
1491 ExcMessage(
"Cannot access an object of type Tensor<rank_,0,Number>"));
1493 return TensorAccessors::extract<rank_>(*
this, indices);
1498template <
int rank_,
int dim,
typename Number>
1502 static_assert(rank_ == 1,
1503 "This function is only available for rank-1 tensors "
1504 "because higher-rank tensors may not store their elements "
1505 "in a contiguous array.");
1507 return std::addressof(
1508 this->
operator[](this->unrolled_to_component_indices(0)));
1513template <
int rank_,
int dim,
typename Number>
1517 static_assert(rank_ == 1,
1518 "This function is only available for rank-1 tensors "
1519 "because higher-rank tensors may not store their elements "
1520 "in a contiguous array.");
1522 return std::addressof(
1523 this->
operator[](this->unrolled_to_component_indices(0)));
1528template <
int rank_,
int dim,
typename Number>
1532 static_assert(rank_ == 1,
1533 "This function is only available for rank-1 tensors "
1534 "because higher-rank tensors may not store their elements "
1535 "in a contiguous array.");
1537 return begin_raw() + n_independent_components;
1542template <
int rank_,
int dim,
typename Number>
1546 static_assert(rank_ == 1,
1547 "This function is only available for rank-1 tensors "
1548 "because higher-rank tensors may not store their elements "
1549 "in a contiguous array.");
1551 return begin_raw() + n_independent_components;
1556template <
int rank_,
int dim,
typename Number>
1557template <
typename OtherNumber>
1563 for (
unsigned int i = 0; i < dim; ++i)
1570template <
int rank_,
int dim,
typename Number>
1577 for (
unsigned int i = 0; i < dim; ++i)
1583# ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
1584template <
int rank_,
int dim,
typename Number>
1588 for (
unsigned int i = 0; i < dim; ++i)
1589 values[i] = other.
values[i];
1595template <
int rank_,
int dim,
typename Number>
1600 for (
unsigned int i = 0; i < dim; ++i)
1601 values[i] = other.
values[i];
1607template <
int rank_,
int dim,
typename Number>
1608template <
typename OtherNumber>
1609constexpr inline bool
1613# ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING
1614 Assert(!(std::is_same_v<Number, adouble> ||
1615 std::is_same_v<OtherNumber, adouble>),
1617 "The Tensor equality operator for ADOL-C taped numbers has not yet "
1618 "been extended to support advanced branching."));
1621 for (
unsigned int i = 0; i < dim; ++i)
1635constexpr inline bool
1642template <
int rank_,
int dim,
typename Number>
1643template <
typename OtherNumber>
1648 return !((*this) == p);
1652template <
int rank_,
int dim,
typename Number>
1653template <
typename OtherNumber>
1659 for (
unsigned int i = 0; i < dim; ++i)
1660 values[i] += p.
values[i];
1665template <
int rank_,
int dim,
typename Number>
1666template <
typename OtherNumber>
1672 for (
unsigned int i = 0; i < dim; ++i)
1673 values[i] -= p.
values[i];
1678template <
int rank_,
int dim,
typename Number>
1679template <
typename OtherNumber>
1684 for (
unsigned int i = 0; i < dim; ++i)
1691template <
int rank_,
int dim,
typename Number>
1692template <
typename OtherNumber>
1697 if constexpr (std::is_integral_v<
1699 std::is_same_v<Number, Differentiation::SD::Expression>)
1702 for (
unsigned int d = 0;
d < dim; ++
d)
1710 for (
unsigned int d = 0;
d < dim; ++
d)
1711 values[d] *= inverse_factor;
1718template <
int rank_,
int dim,
typename Number>
1725 for (
unsigned int i = 0; i < dim; ++i)
1726 tmp.
values[i] = -values[i];
1732template <
int rank_,
int dim,
typename Number>
1738 if constexpr ((rank_ == 1) && (dim == 1) && std::is_arithmetic_v<Number>)
1742 else if constexpr ((rank_ == 2) && (dim == 1) && std::is_arithmetic_v<Number>)
1755 return sqrt(norm_square());
1760template <
int rank_,
int dim,
typename Number>
1765 if constexpr (dim == 0)
1768 else if constexpr (rank_ == 1)
1774 for (
unsigned int i = 1; i < dim; ++i)
1785 for (
unsigned int i = 1; i < dim; ++i)
1786 s += values[i].norm_square();
1794template <
int rank_,
int dim,
typename Number>
1795template <
class Iterator>
1798 const Iterator
end)
const
1800 if constexpr (rank_ > 1)
1803 Iterator next =
begin;
1804 for (
unsigned int i = 0; i < dim; ++i)
1817 "The provided iterator range must contain at least 'dim' "
1825template <
int rank_,
int dim,
typename Number>
1826constexpr inline unsigned int
1830 unsigned int index = 0;
1831 for (
int r = 0; r < rank_; ++r)
1832 index = index * dim + indices[r];
1839template <
int rank_,
int dim,
typename Number>
1844 unsigned int dummy = n_independent_components;
1847 if constexpr (dim == 0)
1851 "A tensor with dimension 0 does not store any elements. "
1852 "There is no indexing that can address its elements."));
1859 unsigned int remainder = i;
1860 for (
int r = rank_ - 1; r >= 0; --r)
1862 indices[r] = remainder % dim;
1863 remainder = remainder / dim;
1872template <
int rank_,
int dim,
typename Number>
1873constexpr inline void
1876 for (
unsigned int i = 0; i < dim; ++i)
1881template <
int rank_,
int dim,
typename Number>
1882constexpr std::size_t
1889template <
int rank_,
int dim,
typename Number>
1890template <
class Archive>
1894 for (
int i = 0; i < dim; ++i)
1901template <
int rank_,
int dim,
typename Number>
1920template <
int rank_,
int dim,
typename Number>
1921inline std::ostream &
1924 for (
unsigned int i = 0; i < dim; ++i)
1928 for (
unsigned int j = 0; j < rank_; ++j)
1942template <
int dim,
typename Number>
1943inline std::ostream &
1946 out << static_cast<const Number &>(p);
1969template <
int dim,
typename Number,
typename Other>
1974 return object *
static_cast<const Number &
>(t);
1989template <
int dim,
typename Number,
typename Other>
1994 return static_cast<const Number &
>(t) *
object;
2009template <
int dim,
typename Number,
typename OtherNumber>
2015 return static_cast<const Number &
>(src1) *
2016 static_cast<const OtherNumber &
>(src2);
2027template <
int dim,
typename Number,
typename OtherNumber>
2035 return static_cast<const Number &
>(t) / factor;
2046template <
int dim,
typename Number,
typename OtherNumber>
2052 return static_cast<const Number &
>(p) +
static_cast<const OtherNumber &
>(q);
2063template <
int dim,
typename Number,
typename OtherNumber>
2069 return static_cast<const Number &
>(p) -
static_cast<const OtherNumber &
>(q);
2085template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2111template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2134template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2157template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2178template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2195template <
int dim,
typename Number,
typename OtherNumber>
2224template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2232 for (
unsigned int i = 0; i < dim; ++i)
2283template <
int rank_1,
2287 typename OtherNumber,
2288 typename = std::enable_if_t<rank_1 >= 1 && rank_2 >= 1>>
2290 typename Tensor<rank_1 + rank_2 - 2,
2302 if constexpr ((rank_1 == 1) && (rank_2 == 1))
2306 static_assert(dim > 0,
"Tensors cannot have dimension zero.");
2308 for (
unsigned int i = 1; i < dim; ++i)
2309 sum += src1[i] * src2[i];
2313 else if constexpr ((rank_1 == 2) && (rank_2 == 1))
2319 rank_1 + rank_2 - 2,
2322 for (
unsigned int i = 0; i < dim; ++i)
2323 result[i] += src1[i] * src2;
2332 rank_1 + rank_2 - 2,
2336 TensorAccessors::internal::
2337 ReorderedIndexView<0, rank_2, const Tensor<rank_2, dim, OtherNumber>>
2338 reordered = TensorAccessors::reordered_index_view<0, rank_2>(src2);
2339 TensorAccessors::contract<1, rank_1, rank_2, dim>(result,
2376template <
int index_1,
2382 typename OtherNumber>
2384 typename Tensor<rank_1 + rank_2 - 2,
2390 Assert(0 <= index_1 && index_1 < rank_1,
2392 "The specified index_1 must lie within the range [0,rank_1)"));
2393 Assert(0 <= index_2 && index_2 < rank_2,
2395 "The specified index_2 must lie within the range [0,rank_2)"));
2402 reord_01 = reordered_index_view<index_1, rank_1>(src1);
2408 reord_02 = reordered_index_view<index_2, rank_2>(src2);
2410 typename Tensor<rank_1 + rank_2 - 2,
2414 TensorAccessors::contract<1, rank_1, rank_2, dim>(result, reord_01, reord_02);
2449template <
int index_1,
2457 typename OtherNumber>
2459 typename Tensor<rank_1 + rank_2 - 4,
2465 Assert(0 <= index_1 && index_1 < rank_1,
2467 "The specified index_1 must lie within the range [0,rank_1)"));
2468 Assert(0 <= index_3 && index_3 < rank_1,
2470 "The specified index_3 must lie within the range [0,rank_1)"));
2471 Assert(index_1 != index_3,
2472 ExcMessage(
"index_1 and index_3 must not be the same"));
2473 Assert(0 <= index_2 && index_2 < rank_2,
2475 "The specified index_2 must lie within the range [0,rank_2)"));
2476 Assert(0 <= index_4 && index_4 < rank_2,
2478 "The specified index_4 must lie within the range [0,rank_2)"));
2479 Assert(index_2 != index_4,
2480 ExcMessage(
"index_2 and index_4 must not be the same"));
2487 reord_1 = TensorAccessors::reordered_index_view<index_1, rank_1>(src1);
2491 reord_2 = TensorAccessors::reordered_index_view<index_2, rank_2>(src2);
2497 (index_3 < index_1 ? index_3 : index_3 - 1),
2501 index_3<index_1 ? index_3 : index_3 - 1, rank_1>(reord_1);
2507 (index_4 < index_2 ? index_4 : index_4 - 1),
2511 index_4<index_2 ? index_4 : index_4 - 1, rank_2>(reord_2);
2513 typename Tensor<rank_1 + rank_2 - 4,
2517 TensorAccessors::contract<2, rank_1, rank_2, dim>(result, reord_3, reord_4);
2534template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2541 TensorAccessors::contract<rank, rank, rank, dim>(result, left, right);
2563template <
template <
int,
int,
typename>
class TensorT1,
2564 template <
int,
int,
typename>
class TensorT2,
2565 template <
int,
int,
typename>
class TensorT3,
2574 contract3(
const TensorT1<rank_1, dim, T1> &left,
2575 const TensorT2<rank_1 + rank_2, dim, T2> &middle,
2576 const TensorT3<rank_2, dim, T3> &right)
2580 return TensorAccessors::contract3<rank_1, rank_2, dim, return_type>(left,
2596template <
int rank_1,
2600 typename OtherNumber>
2606 typename Tensor<rank_1 + rank_2,
2610 TensorAccessors::contract<0, rank_1, rank_2, dim>(result, src1, src2);
2633template <
int dim,
typename Number>
2642 result[1] = -src[0];
2657template <
int dim,
typename Number1,
typename Number2>
2667 if constexpr (dim == 3)
2669 result[0] = src1[1] * src2[2] - src1[2] * src2[1];
2670 result[1] = src1[2] * src2[0] - src1[0] * src2[2];
2671 result[2] = src1[0] * src2[1] - src1[1] * src2[0];
2691template <
int dim,
typename Number>
2699 for (
unsigned int k = 0; k < dim; ++k)
2702 for (
unsigned int i = 0; i < dim - 1; ++i)
2703 for (
unsigned int j = 0; j < dim - 1; ++j)
2704 minor[i][j] = t[i][j < k ? j : j + 1];
2708 det += t[dim - 1][k] * cofactor;
2711 return ((dim % 2 == 0) ? 1. : -1.) * det;
2719template <
typename Number>
2731template <
typename Number>
2736 return t[0][0] * t[1][1] - t[1][0] * t[0][1];
2744template <
typename Number>
2755 return t[0][0] * C0 + t[0][1] * C1 + t[0][2] * C2;
2765template <
int dim,
typename Number>
2770 for (
unsigned int i = 1; i < dim; ++i)
2784template <
int dim,
typename Number>
2788 Number return_tensor[dim][dim];
2801template <
typename Number>
2809 return return_tensor;
2813template <
typename Number>
2820 1.0 / (t[0][0] * t[1][1] - t[1][0] * t[0][1]));
2821 return_tensor[0][0] = t[1][1];
2822 return_tensor[0][1] = -t[0][1];
2823 return_tensor[1][0] = -t[1][0];
2824 return_tensor[1][1] = t[0][0];
2825 return_tensor *= inv_det_t;
2827 return return_tensor;
2830template <
typename Number>
2836 const auto value = [](
const auto &t) {
2840 return_tensor[0][0] =
value(t[1][1] * t[2][2]) -
value(t[1][2] * t[2][1]);
2841 return_tensor[0][1] =
value(t[0][2] * t[2][1]) -
value(t[0][1] * t[2][2]);
2842 return_tensor[0][2] =
value(t[0][1] * t[1][2]) -
value(t[0][2] * t[1][1]);
2843 return_tensor[1][0] =
value(t[1][2] * t[2][0]) -
value(t[1][0] * t[2][2]);
2844 return_tensor[1][1] =
value(t[0][0] * t[2][2]) -
value(t[0][2] * t[2][0]);
2845 return_tensor[1][2] =
value(t[0][2] * t[1][0]) -
value(t[0][0] * t[1][2]);
2846 return_tensor[2][0] =
value(t[1][0] * t[2][1]) -
value(t[1][1] * t[2][0]);
2847 return_tensor[2][1] =
value(t[0][1] * t[2][0]) -
value(t[0][0] * t[2][1]);
2848 return_tensor[2][2] =
value(t[0][0] * t[1][1]) -
value(t[0][1] * t[1][0]);
2851 value(1.0 / (t[0][0] * return_tensor[0][0] + t[0][1] * return_tensor[1][0] +
2852 t[0][2] * return_tensor[2][0]));
2853 return_tensor *= inv_det_t;
2855 return return_tensor;
2866template <
int dim,
typename Number>
2871 for (
unsigned int i = 0; i < dim; ++i)
2874 for (
unsigned int j = i + 1; j < dim; ++j)
2897template <
int dim,
typename Number>
2918template <
int dim,
typename Number>
2989template <
int dim,
typename Number>
3001template <
int dim,
typename Number>
3006 for (
unsigned int j = 0; j < dim; ++j)
3009 for (
unsigned int i = 0; i < dim; ++i)
3027template <
int dim,
typename Number>
3032 for (
unsigned int i = 0; i < dim; ++i)
3035 for (
unsigned int j = 0; j < dim; ++j)
3053# ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING
3062 for (
unsigned int j = 0; j < dim; ++j)
3065 for (
unsigned int i = 0; i < dim; ++i)
3066 sum += fabs(t[i][j]);
3068 condassign(max, (sum > max), sum, max);
3080 for (
unsigned int i = 0; i < dim; ++i)
3083 for (
unsigned int j = 0; j < dim; ++j)
3084 sum +=
fabs(t[i][j]);
3086 condassign(max, (sum > max), sum, max);
* * reference operator*() const
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)
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)
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, OtherNumber >::type > operator-(const Tensor< 0, dim, Number > &p, const Tensor< 0, dim, OtherNumber > &q)
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
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 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)
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< 0, dim, typename ProductType< Number, OtherNumber >::type > operator+(const Tensor< 0, dim, Number > &p, const Tensor< 0, dim, OtherNumber > &q)
constexpr Tensor & operator+=(const Tensor< rank_, dim, OtherNumber > &)
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_HOST_DEVICE
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_HOST_DEVICE_ALWAYS_INLINE
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)
* * * RotationFunction< dim, Number >::RotationFunction Number(dim)
* * * * std::vector< Number > ThermoPlasticMaterial< dim, ViscoplasticYieldLaw, Number >::get_state_parameters const
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 > &)
typename internal::ProductTypeImpl< std::decay_t< T >, std::decay_t< U > >::type type
static constexpr 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)
constexpr Number determinant(const SymmetricTensor< 2, dim, Number > &)
constexpr SymmetricTensor< 2, dim, Number > invert(const SymmetricTensor< 2, dim, Number > &)
constexpr Number trace(const SymmetricTensor< 2, dim2, Number > &)
constexpr SymmetricTensor< 4, dim, Number > outer_product(const SymmetricTensor< 2, dim, Number > &t1, const SymmetricTensor< 2, dim, Number > &t2)
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)
Number l1_norm(const Tensor< 2, dim, Number > &t)