v0.10.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  where <3> means that are three unique eigen values. Return t_A is symmetric
22  tensor rank two.
23 
24  Calculate directive
25  \code
26  auto t_P = EigenMatrix::getDiffMat(t_L, t_N, f, d_f ,nb);
27  \endcode
28  where return t_SL is 4th order tensor (symmetry on first two and
29  second to indices, i.e. minor symmetrise)
30 
31  Calculate second derivative, L, such that S:L, for given S,
32  \code
33  FTensor::Tensor2<double, 3, 3> t_S{
34 
35  1., 0., 0.,
36 
37  0., 1., 0.,
38 
39  0., 0., 1.};
40 
41  auto t_SL = EigenMatrix::getDiffDiffMat( t_L, t_N, f, d_f, dd_f, t_S, nb)
42  \endcode
43  where return t_SL is 4th order tensor (symmetry on first two and
44  second to indices, i.e. minor symmetrise)
45 
46  You can calculate eigen values using lapack.
47 
48  *
49  */
50 
51 /* This file is part of MoFEM.
52  * MoFEM is free software: you can redistribute it and/or modify it under
53  * the terms of the GNU Lesser General Public License as published by the
54  * Free Software Foundation, either version 3 of the License, or (at your
55  * option) any later version.
56  *
57  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
58  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
59  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
60  * License for more details.
61  *
62  * You should have received a copy of the GNU Lesser General Public
63  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>. */
64 
65 #pragma once
66 
67 namespace EigenMatrix {
68 
69 template <typename T, int Dim> using Val = const FTensor::Tensor1<T, Dim>;
70 template <typename T, int Dim> using Vec = const FTensor::Tensor2<T, Dim, Dim>;
71 template <typename T> using Fun = boost::function<T(const T)>;
72 
73 /**
74  * @brief Get the Mat object
75  *
76  * \f[
77  * \mathbf{B} = f(\mathbf{A})
78  * \f]
79  *
80  * \f[
81  * B_{ij} = \sum_{a}^d f(\lambda^a) n^a_i n^a_j
82  * \f]
83  * where \f$a\f$ is eigen value number.
84  *
85  * @param t_val eigen values
86  * @param t_vec eigen vector
87  * @param f function
88  * @return FTensor::Tensor2_symmetric<double, 3>
89  */
92 
93 /**
94  * @copydoc EigenMatrix::getMat
95  */
99 
100 /**
101  * @brief Get the Diff Mat object
102  *
103  * \f[
104  * P_{ijkl} = \frac{\partial B_{ij}}{\partial A_{kl}}
105  * \f]
106  *
107  * \note Eiegn vetore are in rows.
108  *
109  * @param t_val eigen values
110  * @param t_vec eigen vector
111  * @param f function
112  * @param d_f directive of function
113  * @param nb number of nonequal eigen valuse
114  * @return FTensor::Ddg<double, 3, 3>
115  */
117  Vec<double, 3> &t_vec, Fun<double> f,
118  Fun<double> d_f, const int nb);
119 /**
120  * @copydoc EigenMatrix::getDiffMat
121  */
125  Fun<double> d_f, const int nb);
126 
127 /**
128  * @brief Get the Diff Diff Mat object
129  *
130  * \f[
131  * LS_{klmn} =
132  * S_{ij} \frac{\partial^2 B_{ij}}{\partial A_{kl} \partial A_{mn} }
133  * \f]
134  *
135  * \note Eiegn vetore are in rows.
136  *
137  * @param t_val eiegn values
138  * @param t_vec eigen vectors
139  * @param f function
140  * @param d_f directive of function
141  * @param dd_f second directive of function
142  * @param t_S S tensor
143  * @param nb number of nonzero eigen values
144  * @return FTensor::Ddg<double, 3, 3>
145  */
147  Vec<double, 3> &t_vec, Fun<double> f,
150  const int nb);
151 /**
152  * @copydoc EigenMatrix::getDiffMat
153  */
158  FTensor::Tensor2<double, 3, 3> &t_S, const int nb);
159 
160 /**
161  * @copydoc EigenMatrix::getDiffDiffMat
162  */
166  FTensor::Tensor2_symmetric<double, 3> &t_S, const int nb);
167 
168 /**
169  * @copydoc EigenMatrix::getMat
170  */
172  Vec<double, 2> &t_vec,
173  Fun<double> f);
174 
175 /**
176  * @copydoc EigenMatrix::getDiffMat
177  */
179  Vec<double, 2> &t_vec, Fun<double> f,
180  Fun<double> d_f, const int nb);
181 
182 /**
183  * @copydoc EigenMatrix::getDiffDiffMat
184  */
186  Vec<double, 2> &t_vec, Fun<double> f,
189  const int nb);
190 
191 /**
192  * @copydoc EigenMatrix::getDiffDiffMat
193  */
197  FTensor::Tensor2_symmetric<double, 2> &t_S, const int nb);
198 
199 } // namespace EigenMatrix
const double T
boost::function< T(const T)> Fun
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.
FTensor::Tensor2_symmetric< double, 3 > getMat(Val< double, 3 > &t_val, Vec< double, 3 > &t_vec, Fun< double > f)
Get the Mat object.
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)
Get the Diff Diff Mat object.
auto dd_f
Definition: HenckyOps.hpp:21
auto d_f
Definition: HenckyOps.hpp:20