v0.13.2
Loading...
Searching...
No Matches
MatrixFunction.cpp
Go to the documentation of this file.
1#include <type_traits>
2#include <FTensor.hpp>
3#include <MoFEM.hpp>
4#include <Includes.hpp>
5#include <MatrixFunction.hpp>
7
8namespace EigenMatrix {
9
10template <typename T, int Dim>
13 return EigenMatrixImp<T, T, 3, Dim>(t_val, t_vec).getMat(f);
14}
15
16template <typename T, int Dim>
18 Vec<T, Dim> &t_vec, Fun<double> f,
19 Fun<double> d_f, const int nb) {
20 switch (nb) {
21 case 1:
22 return EigenMatrixImp<T, T, 1, Dim>(t_val, t_vec).getDiffMat(f, d_f);
23 case 2:
24 return EigenMatrixImp<T, T, 2, Dim>(t_val, t_vec).getDiffMat(f, d_f);
25 case 3:
26 break;
27 default:
28 THROW_MESSAGE("third parameter should be 1,2 or 3");
29 }
30 return EigenMatrixImp<T, T, 3, Dim>(t_val, t_vec).getDiffMat(f, d_f);
31};
32
33template <typename T, typename S, int Dim>
36 Fun<double> d_f, Fun<double> dd_f, S &t_S, const int nb) {
37 switch (nb) {
38 case 1:
39 return EigenMatrixImp<T, T, 1, Dim>(t_val, t_vec)
40 .getDiffDiffMat(f, d_f, dd_f, t_S);
41 case 2:
42 return EigenMatrixImp<T, T, 2, Dim>(t_val, t_vec)
43 .getDiffDiffMat(f, d_f, dd_f, t_S);
44 case 3:
45 break;
46 default:
47 THROW_MESSAGE("third parameter should be 1,2 or 3");
48 }
49 return EigenMatrixImp<T, T, 3, Dim>(t_val, t_vec)
50 .getDiffDiffMat(f, d_f, dd_f, t_S);
51};
52
54 Vec<double, 3> &t_vec, Fun<double> f) {
55 return getMatImpl<double, 3>(t_val, t_vec, f);
56}
57
61 return getMatImpl<FTensor::PackPtr<double *, 1>, 3>(t_val, t_vec, f);
62}
63
66 Fun<double> d_f, const int nb) {
67 return getDiffMatImpl<double, 3>(t_val, t_vec, f, d_f, nb);
68}
69
73 Fun<double> d_f, const int nb) {
74 return getDiffMatImpl<FTensor::PackPtr<double *, 1>, 3>(t_val, t_vec, f, d_f,
75 nb);
76}
77
80 Fun<double> d_f, Fun<double> dd_f,
82 const int nb) {
83 return getDiffDiffMatImpl<double, FTensor::Tensor2<double, 3, 3>, 3>(
84 t_val, t_vec, f, d_f, dd_f, t_S, nb);
85}
86
90 Fun<double> d_f, Fun<double> dd_f,
91 FTensor::Tensor2<double, 3, 3> &t_S, const int nb) {
92 return getDiffDiffMatImpl<FTensor::PackPtr<double *, 1>,
94 t_val, t_vec, f, d_f, dd_f, t_S, nb);
95}
96
99 Fun<double> d_f, Fun<double> dd_f,
100 FTensor::Tensor2_symmetric<double, 3> &t_S, const int nb) {
101 return getDiffDiffMatImpl<double, FTensor::Tensor2_symmetric<double, 3>, 3>(
102 t_val, t_vec, f, d_f, dd_f, t_S, nb);
103}
104
106 Vec<double, 2> &t_vec,
107 Fun<double> f) {
108 return getMatImpl<double, 2>(t_val, t_vec, f);
109}
110
112 Vec<double, 2> &t_vec, Fun<double> f,
113 Fun<double> d_f, const int nb) {
114 return getDiffMatImpl<double, 2>(t_val, t_vec, f, d_f, nb);
115}
116
118 Vec<double, 2> &t_vec, Fun<double> f,
119 Fun<double> d_f, Fun<double> dd_f,
121 const int nb) {
122 return getDiffDiffMatImpl<double, FTensor::Tensor2<double, 2, 2>, 2>(
123 t_val, t_vec, f, d_f, dd_f, t_S, nb);
124}
125
128 Fun<double> d_f, Fun<double> dd_f,
129 FTensor::Tensor2_symmetric<double, 2> &t_S, const int nb) {
130 return getDiffDiffMatImpl<double, FTensor::Tensor2_symmetric<double, 2>, 2>(
131 t_val, t_vec, f, d_f, dd_f, t_S, nb);
132}
133
134} // namespace EigenMatrix
Tensors class implemented by Walter Landry.
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
Definition: definitions.h:561
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, Dim, Dim > getDiffDiffMatImpl(Val< T, Dim > &t_val, Vec< T, Dim > &t_vec, Fun< double > f, Fun< double > d_f, Fun< double > dd_f, S &t_S, const int nb)
FTensor::Ddg< double, Dim, Dim > getDiffMatImpl(Val< T, Dim > &t_val, Vec< T, Dim > &t_vec, Fun< double > f, Fun< double > d_f, const int nb)
FTensor::Tensor2_symmetric< double, Dim > getMatImpl(Val< T, Dim > &t_val, Vec< T, Dim > &t_vec, Fun< double > f)
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 getDiffMat(Fun f, Fun d_f)
Get derivative of matrix.
auto getDiffDiffMat(Fun f, Fun d_f, Fun dd_f, T &t_S)
Get second direvarive of matrix.