funcy  1.6.1
strain_tensor.h
1 #pragma once
2 
3 #include <funcy/concepts.h>
4 #include <funcy/linalg/concepts.h>
5 #include <funcy/linalg/transpose.h>
6 #include <funcy/util/chainer.h>
7 #include <funcy/util/mathop_traits.h>
8 
9 namespace funcy::linalg
10 {
20  template < class Mat >
21  class RightCauchyGreenStrainTensor : public Chainer< RightCauchyGreenStrainTensor< Mat > >
22  {
23  public:
24  RightCauchyGreenStrainTensor() = default;
29  explicit RightCauchyGreenStrainTensor( const Mat& F )
30  {
31  update( F );
32  }
33 
35  void update( const Mat& F )
36  {
37  FT = detail::transpose( F );
38  FTF = multiply_via_traits( FT, F );
39  }
40 
42  const Mat& d0() const noexcept
43  {
44  return FTF;
45  }
46 
48  Mat d1( const Mat& dF1 ) const
49  {
50  Mat FTdF1 = multiply_via_traits( FT, dF1 );
51  return detail::add_transposed( FTdF1 );
52  }
53 
55  Mat d2( const Mat& dF1, const Mat& dF2 ) const
56  {
57  Mat dF2TdF1 = multiply_via_traits( detail::transpose( dF2 ), dF1 );
58  return detail::add_transposed( dF2TdF1 );
59  }
60 
61  private:
62  Mat FT, FTF;
63  };
64 
71  template < class Mat >
72  class LeftCauchyGreenStrainTensor : public Chainer< LeftCauchyGreenStrainTensor< Mat > >
73  {
74  public:
75  LeftCauchyGreenStrainTensor() = default;
80  explicit LeftCauchyGreenStrainTensor( const Mat& F )
81  {
82  update( F );
83  }
84 
86  void update( const Mat& F )
87  {
88  FT = detail::transpose( F );
89  FFT = multiply_via_traits( F, FT );
90  }
91 
93  const Mat& d0() const noexcept
94  {
95  return FFT;
96  }
97 
99  Mat d1( const Mat& dF1 ) const
100  {
101  Mat FTdF1 = multiply_via_traits( dF1, FT );
102  return detail::add_transposed( FTdF1 );
103  }
104 
106  Mat d2( const Mat& dF1, const Mat& dF2 ) const
107  {
108  Mat dF1dF2T = multiply_via_traits( dF1, detail::transpose( dF2 ) );
109  return detail::add_transposed( dF1dF2T );
110  }
111 
112  private:
113  Mat FT, FFT;
114  };
115 
121  template < class Mat >
122  auto strain_tensor( const Mat& A )
123  {
124  return RightCauchyGreenStrainTensor{ A };
125  }
126 
133  template < Function F >
134  auto strain_tensor( const F& f )
135  {
137  }
138 
144  template < class Mat >
145  auto left_strain_tensor( const Mat& A )
146  {
147  return LeftCauchyGreenStrainTensor{ A };
148  }
149 
156  template < Function F >
157  auto left_strain_tensor( const F& f )
158  {
160  }
162 } // namespace funcy::linalg
RightCauchyGreenStrainTensor(const Mat &F)
Constructor.
Definition: strain_tensor.h:29
Mat d1(const Mat &dF1) const
First directional derivative .
Definition: strain_tensor.h:99
auto strain_tensor(const Mat &A)
Generate the right Cauchy-Green strain tensor .
Definition: strain_tensor.h:122
LeftCauchyGreenStrainTensor(const Mat &F)
Constructor.
Definition: strain_tensor.h:80
const Mat & d0() const noexcept
Function value .
Definition: strain_tensor.h:93
Left Cauchy-Green strain tensor for a symmetric matrix .
Definition: strain_tensor.h:72
auto left_strain_tensor(const Mat &A)
Generate the left Cauchy-Green strain tensor .
Definition: strain_tensor.h:145
void update(const Mat &F)
Reset point of evaluation.
Definition: strain_tensor.h:35
Functionality from linear algebra such as (modified) principal and mixed matrix invariants.
Mat d1(const Mat &dF1) const
First directional derivative .
Definition: strain_tensor.h:48
Mat d2(const Mat &dF1, const Mat &dF2) const
Second directional derivative .
Definition: strain_tensor.h:106
auto transpose(const Mat &A)
Generate .
Definition: transpose.h:151
Right Cauchy-Green strain tensor for a symmetric matrix .
Definition: strain_tensor.h:21
Mat d2(const Mat &dF1, const Mat &dF2) const
Second directional derivative .
Definition: strain_tensor.h:55
const Mat & d0() const noexcept
Function value .
Definition: strain_tensor.h:42
void update(const Mat &F)
Reset point of evaluation.
Definition: strain_tensor.h:86