v0.14.0
MatrixFunction.hpp
Go to the documentation of this file.
1 /** \file FunctionMatrix.hpp
2  \brief Get function from matrix
3  \ingroup ftensor
4 
5  For reference see \cite miehe2001algorithms
6 
7  Usage:
8 
9  To calculate exponent of matrix, first and second derivatives
10  \code
11  auto f = [](double v) { return exp(v); };
12  auto d_f = [](double v) { return exp(v); };
13  auto dd_f = [](double v) { return exp(v); };
14  \endcode
15 
16  Calculate matrix here t_L are vector of eigen values, and t_N is matrix of
17  eigen vectors.
18  \code
19  auto t_A = EigenMatrix::getMat(t_L, t_N, f);
20  \endcode
21  Return t_A is symmetric tensor rank two.
22 
23  Calculate derivative
24  \code
25  auto t_P = EigenMatrix::getDiffMat(t_L, t_N, f, d_f ,nb);
26  \endcode
27  where return t_SL is 4th order tensor (symmetry on first two and
28  second to indices, i.e. minor symmetrise)
29 
30  Calculate second derivative, L, such that S:L, for given S,
31  \code
32  FTensor::Tensor2<double, 3, 3> t_S{
33 
34  1., 0., 0.,
35 
36  0., 1., 0.,
37 
38  0., 0., 1.};
39 
40  auto t_SL = EigenMatrix::getDiffDiffMat( t_L, t_N, f, d_f, dd_f, t_S, nb)
41  \endcode
42  where return t_SL is 4th order tensor (symmetry on first two and
43  second to indices, i.e. minor symmetrise)
44 
45  You can calculate eigen values using lapack.
46 
47  Eiegn values should be sorted such that unique values are first, and last eiegn
48  value is reapitting. For example if eiegn values are \f[ \lambda = \{1,1,2} \f]
49  should be sorted such that
50  \f[
51  \lambda = \{1,2,1}
52  \f]
53  Eigen vectors should be updated, such that order of eigen vectors follow order
54  of eigen values.
55 
56  *
57  */
58 
59 
60 
61 #pragma once
62 
63 namespace EigenMatrix {
64 
65 template <typename T, int Dim> using Val = const FTensor::Tensor1<T, Dim>;
66 template <typename T, int Dim> using Vec = const FTensor::Tensor2<T, Dim, Dim>;
67 template <typename T> using Fun = boost::function<T(const T)>;
68 
69 /**
70  * @brief Get the Mat object
71  *
72  * \f[
73  * \mathbf{B} = f(\mathbf{A})
74  * \f]
75  *
76  * \f[
77  * B_{ij} = \sum_{a}^d f(\lambda^a) n^a_i n^a_j
78  * \f]
79  * where \f$a\f$ is eigen value number.
80  *
81  * @param t_val eigen values
82  * @param t_vec eigen vector
83  * @param f function
84  * @return FTensor::Tensor2_symmetric<double, 3>
85  */
88 
89 /**
90  * @copydoc EigenMatrix::getMat
91  */
95 
96 /**
97  * @brief Get the Diff Mat object
98  *
99  * \f[
100  * P_{ijkl} = \frac{\partial B_{ij}}{\partial A_{kl}}
101  * \f]
102  *
103  * \note Eiegn vetore are in rows.
104  *
105  * @param t_val eigen values
106  * @param t_vec eigen vector
107  * @param f function
108  * @param d_f directive of function
109  * @param nb number of nonequal eigen valuse
110  * @return FTensor::Ddg<double, 3, 3>
111  */
113  Vec<double, 3> &t_vec, Fun<double> f,
114  Fun<double> d_f, const int nb);
115 /**
116  * @copydoc EigenMatrix::getDiffMat
117  */
121  Fun<double> d_f, const int nb);
122 
123 /**
124  * @brief Get the Diff Diff Mat object
125  *
126  * \f[
127  * LS_{klmn} =
128  * S_{ij} \frac{\partial^2 B_{ij}}{\partial A_{kl} \partial A_{mn} }
129  * \f]
130  *
131  * \note Eigen vector are in rows.
132  *
133  * @param t_val eigen values
134  * @param t_vec eigen vectors
135  * @param f function
136  * @param d_f directive of function
137  * @param dd_f second directive of function
138  * @param t_S S tensor
139  * @param nb number of nonzero eigen values
140  * @return FTensor::Ddg<double, 3, 3>
141  */
145  FTensor::Tensor2_symmetric<double, 3> &t_S, const int nb);
146 
147 /**
148  * @copydoc EigenMatrix::getDiffDiffMat
149  */
154  FTensor::Tensor2_symmetric<double, 3> &t_S, const int nb);
155 
156 /**
157  * @copydoc EigenMatrix::getDiffDiffMat
158  */
160  Vec<double, 3> &t_vec, Fun<double> f,
163  const int nb);
164 /**
165  * @copydoc EigenMatrix::getDiffDiffMat
166  */
171  FTensor::Tensor2<double, 3, 3> &t_S, const int nb);
172 
173 /**
174  * @copydoc EigenMatrix::getMat
175  */
178 
179 /**
180  * @copydoc EigenMatrix::getDiffMat
181  */
183  Vec<double, 2> &t_vec, Fun<double> f,
184  Fun<double> d_f, const int nb);
185 
186 /**
187  * @copydoc EigenMatrix::getDiffDiffMat
188  */
190  Vec<double, 2> &t_vec, Fun<double> f,
193  const int nb);
194 
195 /**
196  * @copydoc EigenMatrix::getDiffDiffMat
197  */
201  FTensor::Tensor2_symmetric<double, 2> &t_S, const int nb);
202 
203 } // namespace EigenMatrix
EigenMatrix::getMat
FTensor::Tensor2_symmetric< double, 3 > getMat(Val< double, 3 > &t_val, Vec< double, 3 > &t_vec, Fun< double > f)
Get the Mat object.
Definition: MatrixFunction.cpp:53
FTensor::Tensor1
Definition: Tensor1_value.hpp:8
HenckyOps::d_f
auto d_f
Definition: HenckyOps.hpp:16
FTensor::Tensor2_symmetric
Definition: Tensor2_symmetric_value.hpp:13
FTensor::Tensor2
Definition: Tensor2_value.hpp:16
EigenMatrix
Definition: MatrixFunction.cpp:8
FTensor::PackPtr
Definition: FTensor.hpp:54
HenckyOps::dd_f
auto dd_f
Definition: HenckyOps.hpp:17
HenckyOps::f
auto f
Definition: HenckyOps.hpp:15
FTensor::Ddg< double, 3, 3 >
EigenMatrix::getDiffDiffMat
FTensor::Ddg< double, 3, 3 > getDiffDiffMat(Val< double, 3 > &t_val, Vec< double, 3 > &t_vec, Fun< double > f, Fun< double > d_f, Fun< double > dd_f, FTensor::Tensor2< double, 3, 3 > &t_S, const int nb)
Definition: MatrixFunction.cpp:78
EigenMatrix::Fun
boost::function< T(const T)> Fun
Definition: MatrixFunction.hpp:67
EigenMatrix::getDiffMat
FTensor::Ddg< double, 3, 3 > getDiffMat(Val< double, 3 > &t_val, Vec< double, 3 > &t_vec, Fun< double > f, Fun< double > d_f, const int nb)
Get the Diff Mat object.
Definition: MatrixFunction.cpp:64