7#ifndef GMATTENSOR_CARTESIAN2D_H
8#define GMATTENSOR_CARTESIAN2D_H
10#include <xtensor/xadapt.hpp>
11#include <xtensor/xnoalias.hpp>
12#include <xtensor/xrandom.hpp>
13#include <xtensor/xtensor.hpp>
14#include <xtensor/xview.hpp>
26namespace Cartesian2d {
183inline auto Trace(
const T& A);
191template <
class T,
class R>
192inline void trace(
const T& A, R& ret);
214template <
class T,
class R>
233inline auto A2_ddot_B2(
const T& A,
const T& B);
242template <
class T,
class R>
243inline void A2_ddot_B2(
const T& A,
const T& B, R& ret);
265template <
class T,
class R>
266inline void A2s_ddot_B2s(
const T& A,
const T& B, R& ret);
287template <
class T,
class R>
310template <
class T,
class R>
328inline auto Sym(
const T& A);
336template <
class T,
class R>
337inline void sym(
const T& A, R& ret);
355inline auto A2_dot_B2(
const T& A,
const T& B);
364template <
class T,
class R>
365inline void A2_dot_B2(
const T& A,
const T& B, R& ret);
392template <
class T,
class R>
393inline void A2_dyadic_B2(
const T& A,
const T& B, R& ret);
410template <
class T,
class U>
411inline auto A4_ddot_B2(
const T& A,
const U& B);
420template <
class T,
class U,
class R>
421inline void A4_ddot_B2(
const T& A,
const U& B, R& ret);
432 return detail::impl_A2<T, 2>::toSizeT0(A.shape());
444 return detail::impl_A4<T, 2>::toSizeT0(A.shape());
456 return detail::impl_A2<T, 2>::toShapeT0(A.shape());
468 return detail::impl_A4<T, 2>::toShapeT0(A.shape());
485 constexpr static std::size_t
rank = N;
501 const std::array<size_t, N>&
shape()
const;
579 void init(
const std::array<size_t, N>&
shape);
620inline void O2(T* ret);
628inline void O4(T* ret);
636inline void I2(T* ret);
644inline void II(T* ret);
652inline void I4(T* ret);
660inline void I4rt(T* ret);
668inline void I4s(T* ret);
676inline void I4d(T* ret);
685inline T
Trace(
const T* A);
703inline void sym(
const T* A, T* ret);
763inline void A2_dyadic_B2(
const T* A,
const T* B, T* ret);
773inline void A2_dot_B2(
const T* A,
const T* B, T* ret);
783inline void A4_ddot_B2(
const T* A,
const T* B, T* ret);
Implementation of GMatTensor/Cartesian2d.h.
Implementation of GMatTensor/Cartesian2d.h.
array_type::tensor< double, N+4 > I4d() const
Array of Cartesian2d::I4d()
std::array< size_t, N+4 > m_shape_tensor4
Shape of an array of 4th-order tensors == [m_shape, 2, 2, 2, 2].
array_type::tensor< double, N+4 > O4() const
Array of Cartesian2d::O4()
const std::array< size_t, N+2 > & shape_tensor2() const
Shape of the array of second-order tensors.
static constexpr size_t m_stride_tensor2
Storage stride for 2nd-order tensors ( ).
size_t m_size
Size of the array (of scalars) == prod(m_shape).
const std::array< size_t, N+4 > & shape_tensor4() const
Shape of the array of fourth-order tensors.
array_type::tensor< double, N+4 > II() const
Array of Cartesian2d::II()
static constexpr size_t m_stride_tensor4
Storage stride for 4th-order tensors ( ).
array_type::tensor< double, N+4 > I4s() const
Array of Cartesian2d::I4s()
std::array< size_t, N+2 > m_shape_tensor2
Shape of an array of 2nd-order tensors == [m_shape, 2, 2].
static constexpr size_t m_ndim
Number of dimensions of tensors.
array_type::tensor< double, N+4 > I4() const
Array of Cartesian2d::I4()
array_type::tensor< double, N+2 > I2() const
Array of Cartesian2d::I2()
void init(const std::array< size_t, N > &shape)
Constructor 'alias'.
array_type::tensor< double, N+4 > I4rt() const
Array of Cartesian2d::I4rt()
const std::array< size_t, N > & shape() const
Shape of the array (of scalars).
std::array< size_t, N > m_shape
Shape of the array (of scalars).
static constexpr std::size_t rank
Rank of the array (the actual rank is increased with the tensor-rank).
array_type::tensor< double, N+2 > O2() const
Array of Cartesian2d::O2()
T Deviatoric_ddot_deviatoric(const T *A)
Double tensor contraction of the tensor's deviator.
T A2_ddot_B2(const T *A, const T *B)
See Cartesian2d::A2_ddot_B2()
T Trace(const T *A)
See Cartesian2d::Trace()
void A4_ddot_B2(const T *A, const T *B, T *ret)
See Cartesian2d::A4_ddot_B2()
void A2_dot_B2(const T *A, const T *B, T *ret)
See Cartesian2d::A2_dot_B2()
void A2_dyadic_B2(const T *A, const T *B, T *ret)
See Cartesian2d::A2_dyadic_B2()
T A2s_ddot_B2s(const T *A, const T *B)
See Cartesian2d::A2s_ddot_B2s()
T Norm_deviatoric(const T *A)
See Cartesian2d::Norm_deviatoric()
void sym(const T *A, T *ret)
See Cartesian2d::Sym()
T Hydrostatic_deviatoric(const T *A, T *ret)
Returns Cartesian2d::Hydrostatic() and computes Cartesian2d::Deviatoric()
T Hydrostatic(const T *A)
See Cartesian2d::Hydrostatic()
array_type::tensor< double, 4 > Random4()
Random 4th-order tensor (for example for use in testing).
array_type::tensor< double, 2 > O2()
2nd-order null tensor (all components equal to zero).
array_type::tensor< double, 2 > I2()
2nd-order identity tensor.
auto Deviatoric(const T &A)
Deviatoric part of a tensor:
auto Norm_deviatoric(const T &A)
Norm of the tensor's deviator:
auto Hydrostatic(const T &A)
Hydrostatic part of a tensor.
void hydrostatic(const T &A, R &ret)
Same as Hydrostatic() but writes to externally allocated output.
auto Sym(const T &A)
Symmetric part of a tensor:
size_t underlying_size_A2(const T &A)
Size of the underlying array.
array_type::tensor< double, 4 > II()
Result of the dyadic product of two 2nd-order identity tensors (see I2()).
void deviatoric(const T &A, R &ret)
Same as Deviatoric() but writes to externally allocated output.
array_type::tensor< double, 4 > I4()
Fourth order unit tensor.
auto A2_ddot_B2(const T &A, const T &B)
Double tensor contraction.
void sym(const T &A, R &ret)
Same as Sym() but writes to externally allocated output.
auto A4_ddot_B2(const T &A, const U &B)
Double tensor contraction.
void norm_deviatoric(const T &A, R &ret)
Same as Norm_deviatoric() but writes to externally allocated output.
void trace(const T &A, R &ret)
Same as Trace() but writes to externally allocated output.
array_type::tensor< double, 4 > I4s()
Fourth order symmetric projection.
auto Trace(const T &A)
Trace or 2nd-order tensor.
array_type::tensor< double, 2 > Random2()
Random 2nd-order tensor (for example for use in testing).
auto A2_dot_B2(const T &A, const T &B)
Dot-product (single tensor contraction)
array_type::tensor< double, 4 > O4()
4th-order null tensor (all components equal to zero).
array_type::tensor< double, 4 > I4rt()
Right-transposed fourth order unit tensor.
array_type::tensor< double, 4 > I4d()
Fourth order deviatoric projection.
size_t underlying_size_A4(const T &A)
Size of the underlying array.
auto underlying_shape_A2(const T &A) -> std::array< size_t, detail::impl_A2< T, 2 >::rank >
Shape of the underlying array.
auto underlying_shape_A4(const T &A) -> std::array< size_t, detail::impl_A4< T, 2 >::rank >
Shape of the underlying array.
auto A2s_ddot_B2s(const T &A, const T &B)
Same as A2_ddot_B2(const T& A, const T& B, R& ret) but for symmetric tensors.
auto A2_dyadic_B2(const T &A, const T &B)
Dyadic product.
xt::xtensor< T, N > tensor
Fixed (static) rank array.
Tensor products / operations.