v0.13.1
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/* This file is part of MoFEM.
60 * MoFEM is free software: you can redistribute it and/or modify it under
62 * Free Software Foundation, either version 3 of the License, or (at your
63 * option) any later version.
64 *
65 * MoFEM is distributed in the hope that it will be useful, but WITHOUT
66 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
67 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
68 * License for more details.
69 *
70 * You should have received a copy of the GNU Lesser General Public
72
73#pragma once
74
75namespace EigenMatrix {
76
77template <typename T, int Dim> using Val = const FTensor::Tensor1<T, Dim>;
78template <typename T, int Dim> using Vec = const FTensor::Tensor2<T, Dim, Dim>;
79template <typename T> using Fun = boost::function<T(const T)>;
80
81/**
82 * @brief Get the Mat object
83 *
84 * \f[
85 * \mathbf{B} = f(\mathbf{A})
86 * \f]
87 *
88 * \f[
89 * B_{ij} = \sum_{a}^d f(\lambda^a) n^a_i n^a_j
90 * \f]
91 * where \f$a\f$ is eigen value number.
92 *
93 * @param t_val eigen values
94 * @param t_vec eigen vector
95 * @param f function
96 * @return FTensor::Tensor2_symmetric<double, 3>
97 */
100
101/**
102 * @copydoc EigenMatrix::getMat
103 */
107
108/**
109 * @brief Get the Diff Mat object
110 *
111 * \f[
112 * P_{ijkl} = \frac{\partial B_{ij}}{\partial A_{kl}}
113 * \f]
114 *
115 * \note Eiegn vetore are in rows.
116 *
117 * @param t_val eigen values
118 * @param t_vec eigen vector
119 * @param f function
120 * @param d_f directive of function
121 * @param nb number of nonequal eigen valuse
122 * @return FTensor::Ddg<double, 3, 3>
123 */
126 Fun<double> d_f, const int nb);
127/**
128 * @copydoc EigenMatrix::getDiffMat
129 */
133 Fun<double> d_f, const int nb);
134
135/**
136 * @brief Get the Diff Diff Mat object
137 *
138 * \f[
139 * LS_{klmn} =
140 * S_{ij} \frac{\partial^2 B_{ij}}{\partial A_{kl} \partial A_{mn} }
141 * \f]
142 *
143 * \note Eiegn vetore are in rows.
144 *
145 * @param t_val eiegn values
146 * @param t_vec eigen vectors
147 * @param f function
148 * @param d_f directive of function
149 * @param dd_f second directive of function
150 * @param t_S S tensor
151 * @param nb number of nonzero eigen values
152 * @return FTensor::Ddg<double, 3, 3>
153 */
157 FTensor::Tensor2_symmetric<double, 3> &t_S, const int nb);
158
159/**
160 * @copydoc EigenMatrix::getDiffDiffMat
161 */
166 const int nb);
167/**
168 * @copydoc EigenMatrix::getDiffMat
169 */
174 FTensor::Tensor2<double, 3, 3> &t_S, const int nb);
175
176/**
177 * @copydoc EigenMatrix::getMat
178 */
181
182/**
183 * @copydoc EigenMatrix::getDiffMat
184 */
187 Fun<double> d_f, const int nb);
188
189/**
190 * @copydoc EigenMatrix::getDiffDiffMat
191 */
196 const int nb);
197
198/**
199 * @copydoc EigenMatrix::getDiffDiffMat
200 */
204 FTensor::Tensor2_symmetric<double, 2> &t_S, const int nb);
205
206} // 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)
auto dd_f
Definition: HenckyOps.hpp:21
auto d_f
Definition: HenckyOps.hpp:20