GMatElastic 0.5.3
Loading...
Searching...
No Matches
Cartesian3d.h
Go to the documentation of this file.
1
7#ifndef GMATTENSOR_CARTESIAN3D_H
8#define GMATTENSOR_CARTESIAN3D_H
9
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>
15
16#include "config.h"
17#include "detail.hpp"
18#include "version.h"
19
20namespace GMatTensor {
21
26namespace Cartesian3d {
27
34
41
48
55
75
95
115
135
155
171
182template <class T>
183inline auto Trace(const T& A);
184
191template <class T, class R>
192inline void trace(const T& A, R& ret);
193
205template <class T>
206inline auto Hydrostatic(const T& A);
207
214template <class T, class R>
215inline void hydrostatic(const T& A, R& ret);
216
224template <class T>
225inline auto Det(const T& A);
226
233template <class T, class R>
234inline void det(const T& A, R& ret);
235
251template <class T>
252inline auto A2_ddot_B2(const T& A, const T& B);
253
261template <class T, class R>
262inline void A2_ddot_B2(const T& A, const T& B, R& ret);
263
274template <class T>
275inline auto A2s_ddot_B2s(const T& A, const T& B);
276
284template <class T, class R>
285inline void A2s_ddot_B2s(const T& A, const T& B, R& ret);
286
297template <class T>
298inline auto Norm_deviatoric(const T& A);
299
306template <class T, class R>
307inline void norm_deviatoric(const T& A, R& ret);
308
320template <class T>
321inline auto Deviatoric(const T& A);
322
329template <class T, class R>
330inline void deviatoric(const T& A, R& ret);
331
346template <class T>
347inline auto Sym(const T& A);
348
355template <class T, class R>
356inline void sym(const T& A, R& ret);
357
365template <class T>
366inline auto Inv(const T& A);
367
374template <class T, class R>
375inline void inv(const T& A, R& ret);
376
385template <class T>
386inline auto Logs(const T& A);
387
394template <class T, class R>
395inline void logs(const T& A, R& ret);
396
411template <class T>
412inline auto A2_dot_A2T(const T& A);
413
420template <class T, class R>
421inline void A2_dot_A2T(const T& A, R& ret);
422
438template <class T>
439inline auto A2_dot_B2(const T& A, const T& B);
440
448template <class T, class R>
449inline void A2_dot_B2(const T& A, const T& B, R& ret);
450
466template <class T>
467inline auto A2_dyadic_B2(const T& A, const T& B);
468
476template <class T, class R>
477inline void A2_dyadic_B2(const T& A, const T& B, R& ret);
478
494template <class T, class U>
495inline auto A4_ddot_B2(const T& A, const U& B);
496
504template <class T, class U, class R>
505inline void A4_ddot_B2(const T& A, const U& B, R& ret);
506
522template <class T, class U>
523inline auto A4_dot_B2(const T& A, const U& B);
524
532template <class T, class U, class R>
533inline void A4_dot_B2(const T& A, const U& B, R& ret);
534
541template <class T>
542inline size_t underlying_size_A2(const T& A)
543{
544 return detail::impl_A2<T, 3>::toSizeT0(A.shape());
545}
546
553template <class T>
554inline size_t underlying_size_A4(const T& A)
555{
556 return detail::impl_A4<T, 3>::toSizeT0(A.shape());
557}
558
565template <class T>
566inline auto underlying_shape_A2(const T& A) -> std::array<size_t, detail::impl_A2<T, 3>::rank>
567{
568 return detail::impl_A2<T, 3>::toShapeT0(A.shape());
569}
570
577template <class T>
578inline auto underlying_shape_A4(const T& A) -> std::array<size_t, detail::impl_A4<T, 3>::rank>
579{
580 return detail::impl_A4<T, 3>::toShapeT0(A.shape());
581}
582
591template <size_t N>
592class Array {
593public:
597 constexpr static std::size_t rank = N;
598
599 Array() = default;
600
606 Array(const std::array<size_t, N>& shape);
607
613 const std::array<size_t, N>& shape() const;
614
620 const std::array<size_t, N + 2>& shape_tensor2() const;
621
627 const std::array<size_t, N + 4>& shape_tensor4() const;
628
635
642
649
656
663
670
677
684
685protected:
691 void init(const std::array<size_t, N>& shape);
692
694 static constexpr size_t m_ndim = 3;
695
697 static constexpr size_t m_stride_tensor2 = 9;
698
700 static constexpr size_t m_stride_tensor4 = 81;
701
703 size_t m_size;
704
706 std::array<size_t, N> m_shape;
707
709 std::array<size_t, N + 2> m_shape_tensor2;
710
712 std::array<size_t, N + 4> m_shape_tensor4;
713};
714
724namespace pointer {
725
731template <class T>
732inline void O2(T* ret);
733
739template <class T>
740inline void O4(T* ret);
741
747template <class T>
748inline void I2(T* ret);
749
755template <class T>
756inline void II(T* ret);
757
763template <class T>
764inline void I4(T* ret);
765
771template <class T>
772inline void I4rt(T* ret);
773
779template <class T>
780inline void I4s(T* ret);
781
787template <class T>
788inline void I4d(T* ret);
789
796template <class T>
797inline T Trace(const T* A);
798
805template <class T>
806inline T Hydrostatic(const T* A);
807
814template <class T>
815inline T Det(const T* A);
816
823template <class T>
824inline void sym(const T* A, T* ret);
825
833template <class T>
834inline T Inv(const T* A, T* ret);
835
843template <class T>
844inline T Hydrostatic_deviatoric(const T* A, T* ret);
845
854template <class T>
855inline T Deviatoric_ddot_deviatoric(const T* A);
856
863template <class T>
864inline T Norm_deviatoric(const T* A);
865
873template <class T>
874inline T A2_ddot_B2(const T* A, const T* B);
875
883template <class T>
884inline T A2s_ddot_B2s(const T* A, const T* B);
885
893template <class T>
894inline void A2_dyadic_B2(const T* A, const T* B, T* ret);
895
903template <class T>
904inline void A4_dot_B2(const T* A, const T* B, T* ret);
905
913template <class T>
914inline void A2_dot_B2(const T* A, const T* B, T* ret);
915
922template <class T>
923inline void A2_dot_A2T(const T* A, T* ret);
924
932template <class T>
933inline void A4_ddot_B2(const T* A, const T* B, T* ret);
934
949template <class T>
950inline void A4_ddot_B4_ddot_C4(const T* A, const T* B, const T* C, T* ret);
951
966template <class T>
967inline void A2_dot_B2_dot_C2T(const T* A, const T* B, const T* C, T* ret);
968
981template <class T>
982void eigs(const T* A, T* vec, T* val);
983
992template <class T>
993void from_eigs(const T* vec, const T* val, T* ret);
994
1001template <class T>
1002void logs(const T* A, T* ret);
1003
1004} // namespace pointer
1005
1006} // namespace Cartesian3d
1007} // namespace GMatTensor
1008
1009#include "Cartesian3d.hpp"
1010#include "Cartesian3d_Array.hpp"
1011
1012#endif
Implementation of GMatTensor/Cartesian3d.h.
Implementation of GMatTensor/Cartesian3d.h.
array_type::tensor< double, N+4 > I4d() const
Array of Cartesian3d::I4d()
const std::array< size_t, N+2 > & shape_tensor2() const
Shape of the array of second-order tensors.
std::array< size_t, N+4 > m_shape_tensor4
Shape of an array of 4th-order tensors == [m_shape, 3, 3, 3, 3].
Definition: Cartesian3d.h:712
array_type::tensor< double, N+4 > I4s() const
Array of Cartesian3d::I4s()
array_type::tensor< double, N+4 > I4() const
Array of Cartesian3d::I4()
static constexpr size_t m_stride_tensor4
Storage stride for 4th-order tensors ( ).
Definition: Cartesian3d.h:700
static constexpr size_t m_ndim
Number of dimensions of tensors.
Definition: Cartesian3d.h:694
std::array< size_t, N > m_shape
Shape of the array (of scalars).
Definition: Cartesian3d.h:706
const std::array< size_t, N > & shape() const
Shape of the array (of scalars).
array_type::tensor< double, N+4 > II() const
Array of Cartesian3d::II()
void init(const std::array< size_t, N > &shape)
Constructor 'alias'.
array_type::tensor< double, N+4 > O4() const
Array of Cartesian3d::O4()
std::array< size_t, N+2 > m_shape_tensor2
Shape of an array of 2nd-order tensors == [m_shape, 3, 3].
Definition: Cartesian3d.h:709
static constexpr std::size_t rank
Rank of the array (the actual rank is increased with the tensor-rank).
Definition: Cartesian3d.h:597
size_t m_size
Size of the array (of scalars) == prod(m_shape).
Definition: Cartesian3d.h:703
array_type::tensor< double, N+2 > O2() const
Array of Cartesian3d::O2()
const std::array< size_t, N+4 > & shape_tensor4() const
Shape of the array of fourth-order tensors.
array_type::tensor< double, N+2 > I2() const
Array of Cartesian3d::I2()
array_type::tensor< double, N+4 > I4rt() const
Array of Cartesian3d::I4rt()
static constexpr size_t m_stride_tensor2
Storage stride for 2nd-order tensors ( ).
Definition: Cartesian3d.h:697
void logs(const T *A, T *ret)
See Cartesian3d::Logs()
void A2_dyadic_B2(const T *A, const T *B, T *ret)
See Cartesian3d::A2_dyadic_B2()
void from_eigs(const T *vec, const T *val, T *ret)
Reconstruct tensor from eigenvalues/-vectors (reverse operation of eigs()) Symmetric tensors only,...
void A2_dot_B2_dot_C2T(const T *A, const T *B, const T *C, T *ret)
Product.
T Inv(const T *A, T *ret)
See Cartesian3d::Inv(), returns Cartesian3d::Det()
void eigs(const T *A, T *vec, T *val)
Get eigenvalues/-vectors such that.
T A2s_ddot_B2s(const T *A, const T *B)
See Cartesian3d::A2s_ddot_B2s()
void A4_dot_B2(const T *A, const T *B, T *ret)
See Cartesian3d::A4_dot_B2()
T Det(const T *A)
See Cartesian3d::Det()
T Trace(const T *A)
See Cartesian3d::Trace()
T Hydrostatic(const T *A)
See Cartesian3d::Hydrostatic()
T Deviatoric_ddot_deviatoric(const T *A)
Double tensor contraction of the tensor's deviator.
void A2_dot_A2T(const T *A, T *ret)
See Cartesian3d::A2_dot_A2T()
T Norm_deviatoric(const T *A)
See Cartesian3d::Norm_deviatoric()
void A2_dot_B2(const T *A, const T *B, T *ret)
See Cartesian3d::A2_dot_B2()
T A2_ddot_B2(const T *A, const T *B)
See Cartesian3d::A2_ddot_B2()
void A4_ddot_B2(const T *A, const T *B, T *ret)
See Cartesian3d::A4_ddot_B2()
void sym(const T *A, T *ret)
See Cartesian3d::Sym()
T Hydrostatic_deviatoric(const T *A, T *ret)
Returns Cartesian3d::Hydrostatic() and computes Cartesian3d::Deviatoric()
void A4_ddot_B4_ddot_C4(const T *A, const T *B, const T *C, T *ret)
Product.
void hydrostatic(const T &A, R &ret)
Same as Hydrostatic() but writes to externally allocated output.
auto Deviatoric(const T &A)
Deviatoric part of a tensor:
auto A2_dyadic_B2(const T &A, const T &B)
Dyadic product.
size_t underlying_size_A2(const T &A)
Size of the underlying array.
Definition: Cartesian3d.h:542
auto Sym(const T &A)
Symmetric part of a tensor:
auto underlying_shape_A2(const T &A) -> std::array< size_t, detail::impl_A2< T, 3 >::rank >
Shape of the underlying array.
Definition: Cartesian3d.h:566
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.
void trace(const T &A, R &ret)
Same as Trace() but writes to externally allocated output.
Definition: Cartesian3d.hpp:90
auto Logs(const T &A)
Logarithm.
array_type::tensor< double, 2 > I2()
2nd-order identity tensor.
Definition: Cartesian3d.hpp:47
array_type::tensor< double, 2 > O2()
2nd-order null tensor (all components equal to zero).
Definition: Cartesian3d.hpp:35
auto A2_dot_B2(const T &A, const T &B)
Dot-product (single tensor contraction)
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.
Definition: Cartesian3d.hpp:61
array_type::tensor< double, 4 > II()
Result of the dyadic product of two 2nd-order identity tensors (see I2()).
Definition: Cartesian3d.hpp:54
auto A2_ddot_B2(const T &A, const T &B)
Double tensor contraction.
array_type::tensor< double, 4 > I4rt()
Right-transposed fourth order unit tensor.
Definition: Cartesian3d.hpp:68
array_type::tensor< double, 4 > I4d()
Fourth order deviatoric projection.
Definition: Cartesian3d.hpp:82
void det(const T &A, R &ret)
Same as Det() but writes to externally allocated output.
void logs(const T &A, R &ret)
Same as Logs() but writes to externally allocated output.
array_type::tensor< double, 4 > Random4()
Random 4th-order tensor (for example for use in testing).
Definition: Cartesian3d.hpp:29
void sym(const T &A, R &ret)
Same as Sym() but writes to externally allocated output.
array_type::tensor< double, 4 > I4s()
Fourth order symmetric projection.
Definition: Cartesian3d.hpp:75
auto Det(const T &A)
Determinant.
auto underlying_shape_A4(const T &A) -> std::array< size_t, detail::impl_A4< T, 3 >::rank >
Shape of the underlying array.
Definition: Cartesian3d.h:578
array_type::tensor< double, 4 > O4()
4th-order null tensor (all components equal to zero).
Definition: Cartesian3d.hpp:41
auto Inv(const T &A)
Inverse.
void inv(const T &A, R &ret)
Same as Inv() but writes to externally allocated output.
auto Norm_deviatoric(const T &A)
Norm of the tensor's deviator:
size_t underlying_size_A4(const T &A)
Size of the underlying array.
Definition: Cartesian3d.h:554
auto Trace(const T &A)
Trace or 2nd-order tensor.
Definition: Cartesian3d.hpp:96
auto A4_dot_B2(const T &A, const U &B)
Tensor contraction.
void norm_deviatoric(const T &A, R &ret)
Same as Norm_deviatoric() but writes to externally allocated output.
auto A4_ddot_B2(const T &A, const U &B)
Double tensor contraction.
auto Hydrostatic(const T &A)
Hydrostatic part of a tensor.
array_type::tensor< double, 2 > Random2()
Random 2nd-order tensor (for example for use in testing).
Definition: Cartesian3d.hpp:23
auto A2_dot_A2T(const T &A)
Dot-product (single tensor contraction)
xt::xtensor< T, N > tensor
Fixed (static) rank array.
Definition: config.h:86
Tensor products / operations.
Definition: Cartesian2d.h:20