Collection of several utilities for dealing with Eigen tensors. More...
Functions | |
template<typename Derived , typename T , auto rank> | |
Eigen::Tensor< typename Derived::Scalar, rank > | Ikarus::tensorView (const Eigen::EigenBase< Derived > &matrix, const std::array< T, rank > &dims) |
View an Eigen matrix as an Eigen Tensor with specified dimensions. More... | |
auto | Ikarus::dyadic (const auto &A_ij, const auto &B_kl) |
Computes the dyadic product of two Eigen tensors. More... | |
template<typename ST , int size> | |
auto | Ikarus::dyadic (const Eigen::Vector< ST, size > &a, const Eigen::Vector< ST, size > &b) |
Computes the dyadic product of two first order Tensors (here: Eigen::Vector). More... | |
template<typename ScalarType = double, int dim = 3> | |
auto | Ikarus::symmetricIdentityFourthOrder () |
Generates a symmetric identity fourth-order tensor. More... | |
template<typename ScalarType = double, int dim = 3> | |
auto | Ikarus::symmetricFourthOrder (const auto &A, const auto &B) |
Generates a symmetric fourth-order tensor based on two second-order input tensors. More... | |
template<typename ScalarType = double, int dim = 3> | |
auto | Ikarus::identityFourthOrder () |
Generates an identity fourth-order tensor. More... | |
template<typename AType , typename BType > | |
auto | Ikarus::fourthOrderIKJL (const Eigen::MatrixBase< AType > &A, const Eigen::MatrixBase< BType > &B) |
Computes the IKJL product of two matrices. More... | |
template<typename ScalarType , long int dim> | |
auto | Ikarus::symTwoSlots (const Eigen::TensorFixedSize< ScalarType, Eigen::Sizes< dim, dim, dim, dim > > &t, const std::array< size_t, 2 > &slots) |
Creates a symmetric fourth-order tensor in the two specified slots of the input tensor. More... | |
template<int dim = 3> requires (dim == 2 or dim == 3) | |
constexpr Eigen::Index | Ikarus::toVoigt (Eigen::Index i, Eigen::Index j) noexcept |
Converts 2D indices to Voigt notation index. More... | |
template<typename ScalarType = double> | |
Eigen::Matrix< ScalarType, 6, 6 > | Ikarus::toVoigt (const Eigen::TensorFixedSize< ScalarType, Eigen::Sizes< 3, 3, 3, 3 > > &ft) |
Converts a fourth-order tensor of fixed size 3x3x3x3 to a Voigt notation matrix of size 6x6. More... | |
template<typename ST , int size, int Options, int maxSize> requires ((size > 0 and size <= 3) or (maxSize > 0 and maxSize <= 3 and size == Eigen::Dynamic)) | |
auto | Ikarus::toVoigt (const Eigen::Matrix< ST, size, size, Options, maxSize, maxSize > &E, bool isStrain=true) |
Converts a square 2x2 or 3x3 matrix to a Voigt notation vector. More... | |
template<typename ST , int size, int Options, int maxSize> requires ((size == 1 or size == 3 or size == 6) or ((maxSize == 1 or maxSize == 3 or maxSize == 6) and size == Eigen::Dynamic)) | |
auto | Ikarus::fromVoigt (const Eigen::Matrix< ST, size, 1, Options, maxSize, 1 > &EVoigt, bool isStrain=true) |
Converts a vector given in Voigt notation to a matrix. More... | |
constexpr std::array< size_t, 2 > | Ikarus::fromVoigt (size_t i) |
Converts a Voigt notation index to matrix indices. More... | |
template<typename ScalarType > | |
auto | Ikarus::fromVoigt (const Eigen::Matrix< ScalarType, 6, 6 > &CVoigt) |
Converts a matrix in Voigt notation to a Fourth-order tensor. More... | |
auto Ikarus::dyadic | ( | const auto & | A_ij, |
const auto & | B_kl | ||
) |
The components of the result read
\[ \CI_{ijkl} = A_{ij}B_{kl}. \]
A_ij | First tensor. |
B_kl | Second tensor. |
auto Ikarus::dyadic | ( | const Eigen::Vector< ST, size > & | a, |
const Eigen::Vector< ST, size > & | b | ||
) |
The components of the result read
\[ A_{ij} = a_{i}b_{j}. \]
a_i | First tensor. |
b_j | Second tensor. |
auto Ikarus::fourthOrderIKJL | ( | const Eigen::MatrixBase< AType > & | A, |
const Eigen::MatrixBase< BType > & | B | ||
) |
The components of the result read
\[ \CI_{ijkl} = A_{ik}B_{jl}, \]
which simply swaps the inner slots j
and k
AType | Type of the first matrix. |
BType | Type of the second matrix. |
A | First matrix. |
B | Second matrix. |
auto Ikarus::fromVoigt | ( | const Eigen::Matrix< ScalarType, 6, 6 > & | CVoigt | ) |
ScalarType | Scalar type of the matrix elements. |
CVoigt | Voigt notation matrix. |
This function converts a Voigt notation matrix to the corresponding 4th-order tensor. The function uses the fromVoigt
function to map matrix indices to tensor indices. The resulting tensor is symmetric due to symmetry considerations.
auto Ikarus::fromVoigt | ( | const Eigen::Matrix< ST, size, 1, Options, maxSize, 1 > & | EVoigt, |
bool | isStrain = true |
||
) |
ST | Scalar type of the vector elements. |
size | Size of the Voigt notation vector. |
EVoigt | Voigt notation vector. |
isStrain | Flag indicating whether the vector represents a strain (default is true). |
This function converts a vector given in Voigt notation to the corresponding matrix. The conversion depends on the size The parameter isStrain
is used to determine the conversion factor for off-diagonal components, which need to be divided by 2 in the matrix representation if the quantity is a strain tensor.
The function requires that the size of the Voigt notation vector is valid (1, 3, or 6).
|
constexpr |
i | Voigt notation index. |
This function converts a Voigt notation index to the corresponding matrix indices. The mapping is based on the assumption that the Voigt notation indices 0, 1, and 2 represent the diagonal components 00
, 11
, and 22
, respectively. The remaining Voigt notation indices (3, 4, and 5) correspond to the off-diagonal components (12
and 21
, 02
and 20
, 01
and 10
).
The function asserts that the input index is within the valid range for Voigt notation (0 to 5).
auto Ikarus::identityFourthOrder | ( | ) |
The components of the result read
\[ \CI_{ijkl} = \de_{ij}\de_{kl}. \]
ScalarType | Type of the elements in the tensor. |
dim | Dimension of the tensor. |
auto Ikarus::symmetricFourthOrder | ( | const auto & | A, |
const auto & | B | ||
) |
The components of the result read
\[ \CI_{ijkl} = \frac{1}{2} \left(A_{ik}B_{jl}+A_{il}B_{jk} \right) . \]
ScalarType | Type of the elements in the tensors. |
dim | Dimension of the tensors. |
A | First tensor. |
B | Second tensor. |
auto Ikarus::symmetricIdentityFourthOrder | ( | ) |
ScalarType | Type of the elements in the tensor. |
dim | Dimension of the tensor. |
auto Ikarus::symTwoSlots | ( | const Eigen::TensorFixedSize< ScalarType, Eigen::Sizes< dim, dim, dim, dim > > & | t, |
const std::array< size_t, 2 > & | slots | ||
) |
ScalarType | Type of the elements in the tensor. |
t | Input tensor. |
slots | Indices of the slots to be swapped. |
Eigen::Tensor< typename Derived::Scalar, rank > Ikarus::tensorView | ( | const Eigen::EigenBase< Derived > & | matrix, |
const std::array< T, rank > & | dims | ||
) |
Derived | Type of the input Eigen matrix. |
T | Type of the elements in the matrix. |
rank | Rank of the resulting Tensor. |
matrix | Input Eigen matrix to be cast. |
dims | Dimensions of the resulting Tensor. |
auto Ikarus::toVoigt | ( | const Eigen::Matrix< ST, size, size, Options, maxSize, maxSize > & | E, |
bool | isStrain = true |
||
) |
ST | Data type of the matrix elements. |
size | Number of rows and columns of the square matrix. |
Options | Eigen matrix options. |
E | Input matrix of size (size x size). |
isStrain | Flag indicating whether the conversion is for strain (true) or not (false). |
This function converts a square matrix to a Voigt notation vector, which contains the unique components of the input matrix. The mapping from the matrix indices to the Voigt notation indices is performed by the toVoigt function.
The optional isStrain parameter allows the user to specify whether the conversion is intended for strain calculations. If isStrain is true, the off-diagonal components are multiplied by 2, providing the correct Voigt notation for symmetric strain tensors.
Eigen::Matrix< ScalarType, 6, 6 > Ikarus::toVoigt | ( | const Eigen::TensorFixedSize< ScalarType, Eigen::Sizes< 3, 3, 3, 3 > > & | ft | ) |
ScalarType | Data type of the tensor elements. |
ft | Fourth-order tensor . |
This function converts a fourth-order tensor to a Voigt notation matrix, which is a symmetric 6x6 matrix containing the unique components of the input tensor. The mapping from the tensor indices to the Voigt notation indices is performed by the toVoigt function.
|
constexprnoexcept |
dim | dimension (either 2d or 3d), defaults to 3 |
i | Row index. |
j | Column index. |
This function converts 2D indices (i, j) to a Voigt notation index. The Voigt notation is used to represent the six unique components of a symmetric 3x3 matrix in a one-dimensional array.
If the input indices are not within the valid range (0, 1, 2), an assertion failure is triggered.