GMatElastic 0.5.3
Loading...
Searching...
No Matches
Cartesian2d.h
Go to the documentation of this file.
1
7#ifndef GMATTENSOR_CARTESIAN2D_H
8#define GMATTENSOR_CARTESIAN2D_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 Cartesian2d {
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
232template <class T>
233inline auto A2_ddot_B2(const T& A, const T& B);
234
242template <class T, class R>
243inline void A2_ddot_B2(const T& A, const T& B, R& ret);
244
255template <class T>
256inline auto A2s_ddot_B2s(const T& A, const T& B);
257
265template <class T, class R>
266inline void A2s_ddot_B2s(const T& A, const T& B, R& ret);
267
278template <class T>
279inline auto Norm_deviatoric(const T& A);
280
287template <class T, class R>
288inline void norm_deviatoric(const T& A, R& ret);
289
301template <class T>
302inline auto Deviatoric(const T& A);
303
310template <class T, class R>
311inline void deviatoric(const T& A, R& ret);
312
327template <class T>
328inline auto Sym(const T& A);
329
336template <class T, class R>
337inline void sym(const T& A, R& ret);
338
354template <class T>
355inline auto A2_dot_B2(const T& A, const T& B);
356
364template <class T, class R>
365inline void A2_dot_B2(const T& A, const T& B, R& ret);
366
382template <class T>
383inline auto A2_dyadic_B2(const T& A, const T& B);
384
392template <class T, class R>
393inline void A2_dyadic_B2(const T& A, const T& B, R& ret);
394
410template <class T, class U>
411inline auto A4_ddot_B2(const T& A, const U& B);
412
420template <class T, class U, class R>
421inline void A4_ddot_B2(const T& A, const U& B, R& ret);
422
429template <class T>
430inline size_t underlying_size_A2(const T& A)
431{
432 return detail::impl_A2<T, 2>::toSizeT0(A.shape());
433}
434
441template <class T>
442inline size_t underlying_size_A4(const T& A)
443{
444 return detail::impl_A4<T, 2>::toSizeT0(A.shape());
445}
446
453template <class T>
454inline auto underlying_shape_A2(const T& A) -> std::array<size_t, detail::impl_A2<T, 2>::rank>
455{
456 return detail::impl_A2<T, 2>::toShapeT0(A.shape());
457}
458
465template <class T>
466inline auto underlying_shape_A4(const T& A) -> std::array<size_t, detail::impl_A4<T, 2>::rank>
467{
468 return detail::impl_A4<T, 2>::toShapeT0(A.shape());
469}
470
479template <size_t N>
480class Array {
481public:
485 constexpr static std::size_t rank = N;
486
487 Array() = default;
488
494 Array(const std::array<size_t, N>& shape);
495
501 const std::array<size_t, N>& shape() const;
502
508 const std::array<size_t, N + 2>& shape_tensor2() const;
509
515 const std::array<size_t, N + 4>& shape_tensor4() const;
516
523
530
537
544
551
558
565
572
573protected:
579 void init(const std::array<size_t, N>& shape);
580
582 static constexpr size_t m_ndim = 2;
583
585 static constexpr size_t m_stride_tensor2 = 4;
586
588 static constexpr size_t m_stride_tensor4 = 16;
589
591 size_t m_size;
592
594 std::array<size_t, N> m_shape;
595
597 std::array<size_t, N + 2> m_shape_tensor2;
598
600 std::array<size_t, N + 4> m_shape_tensor4;
601};
602
612namespace pointer {
613
619template <class T>
620inline void O2(T* ret);
621
627template <class T>
628inline void O4(T* ret);
629
635template <class T>
636inline void I2(T* ret);
637
643template <class T>
644inline void II(T* ret);
645
651template <class T>
652inline void I4(T* ret);
653
659template <class T>
660inline void I4rt(T* ret);
661
667template <class T>
668inline void I4s(T* ret);
669
675template <class T>
676inline void I4d(T* ret);
677
684template <class T>
685inline T Trace(const T* A);
686
693template <class T>
694inline T Hydrostatic(const T* A);
695
702template <class T>
703inline void sym(const T* A, T* ret);
704
712template <class T>
713inline T Hydrostatic_deviatoric(const T* A, T* ret);
714
723template <class T>
724inline T Deviatoric_ddot_deviatoric(const T* A);
725
732template <class T>
733inline T Norm_deviatoric(const T* A);
734
742template <class T>
743inline T A2_ddot_B2(const T* A, const T* B);
744
752template <class T>
753inline T A2s_ddot_B2s(const T* A, const T* B);
754
762template <class T>
763inline void A2_dyadic_B2(const T* A, const T* B, T* ret);
764
772template <class T>
773inline void A2_dot_B2(const T* A, const T* B, T* ret);
774
782template <class T>
783inline void A4_ddot_B2(const T* A, const T* B, T* ret);
784
785} // namespace pointer
786
787} // namespace Cartesian2d
788} // namespace GMatTensor
789
790#include "Cartesian2d.hpp"
791#include "Cartesian2d_Array.hpp"
792
793#endif
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].
Definition: Cartesian2d.h:600
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 ( ).
Definition: Cartesian2d.h:585
size_t m_size
Size of the array (of scalars) == prod(m_shape).
Definition: Cartesian2d.h:591
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 ( ).
Definition: Cartesian2d.h:588
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].
Definition: Cartesian2d.h:597
static constexpr size_t m_ndim
Number of dimensions of tensors.
Definition: Cartesian2d.h:582
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).
Definition: Cartesian2d.h:594
static constexpr std::size_t rank
Rank of the array (the actual rank is increased with the tensor-rank).
Definition: Cartesian2d.h:485
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).
Definition: Cartesian2d.hpp:29
array_type::tensor< double, 2 > O2()
2nd-order null tensor (all components equal to zero).
Definition: Cartesian2d.hpp:35
array_type::tensor< double, 2 > I2()
2nd-order identity tensor.
Definition: Cartesian2d.hpp:47
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.
Definition: Cartesian2d.h:430
array_type::tensor< double, 4 > II()
Result of the dyadic product of two 2nd-order identity tensors (see I2()).
Definition: Cartesian2d.hpp:54
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: Cartesian2d.hpp:61
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.
Definition: Cartesian2d.hpp:90
array_type::tensor< double, 4 > I4s()
Fourth order symmetric projection.
Definition: Cartesian2d.hpp:75
auto Trace(const T &A)
Trace or 2nd-order tensor.
Definition: Cartesian2d.hpp:96
array_type::tensor< double, 2 > Random2()
Random 2nd-order tensor (for example for use in testing).
Definition: Cartesian2d.hpp:23
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).
Definition: Cartesian2d.hpp:41
array_type::tensor< double, 4 > I4rt()
Right-transposed fourth order unit tensor.
Definition: Cartesian2d.hpp:68
array_type::tensor< double, 4 > I4d()
Fourth order deviatoric projection.
Definition: Cartesian2d.hpp:82
size_t underlying_size_A4(const T &A)
Size of the underlying array.
Definition: Cartesian2d.h:442
auto underlying_shape_A2(const T &A) -> std::array< size_t, detail::impl_A2< T, 2 >::rank >
Shape of the underlying array.
Definition: Cartesian2d.h:454
auto underlying_shape_A4(const T &A) -> std::array< size_t, detail::impl_A4< T, 2 >::rank >
Shape of the underlying array.
Definition: Cartesian2d.h:466
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.
Definition: config.h:86
Tensor products / operations.
Definition: Cartesian2d.h:20