Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
Coeff2Hermite.h
Go to the documentation of this file.
1/* This file is part of MoDELib, the Mechanics Of Defects Evolution Library.
2 *
3 *
4 * MoDELib is distributed without any warranty under the
5 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
6 */
7
8/**********************************************************************************************************************/
9/**********************************************************************************************************************/
10#ifndef model_COEFF2HERMITE_H_
11#define model_COEFF2HERMITE_H_
12
13#include <Eigen/Dense>
14#include <CTM.h>
16
17namespace model {
18
19
20 /* FillC2H0 *******************************************************************************/
21 // case i,j
22 template<short unsigned int P,short unsigned int i, short unsigned int j>
23 struct FillC2H0 : public FillC2H0<P,i,j-1>{
24 FillC2H0(Eigen::Matrix<double,(P+1)/2,(P+1)>& C2H0) : FillC2H0<P,i,j-1>::FillC2H0(C2H0){
25 C2H0(i,j) = 0.0;
26 }
27 };
28
29 // case i,i
30 template<short unsigned int P,short unsigned int i>
31 struct FillC2H0<P,i,i> : public FillC2H0<P,i,i-1>{
32 enum {j=i};
33 FillC2H0(Eigen::Matrix<double,(P+1)/2,(P+1)>& C2H0) : FillC2H0<P,i,j-1>::FillC2H0(C2H0){
34 C2H0(i,j) = CTM::factorial(i);
35 }
36 };
37
38 // case i,0, i!=0
39 template<short unsigned int P,short unsigned int i>
40 struct FillC2H0<P,i,0> : public FillC2H0<P,i-1,P>{
41 enum {j=0};
42 FillC2H0(Eigen::Matrix<double,(P+1)/2,(P+1)>& C2H0) : FillC2H0<P,i-1,P>::FillC2H0(C2H0){
43 C2H0(i,j) = 0.0;
44 }
45 };
46
47 // case i=j=0
48 template<short unsigned int P>
49 struct FillC2H0<P,0,0>{
50 enum {i=0};
51 enum {j=0};
52 FillC2H0(Eigen::Matrix<double,(P+1)/2,(P+1)>& C2H0){
53 C2H0(i,j) = CTM::factorial(i);
54 }
55 };
56
57 /* FillC2H1 *******************************************************************************/
58 // case i,j
59 template<short unsigned int P,short unsigned int i, short unsigned int j>
60 struct FillC2H1 : public FillC2H1<P,i,j-1>{
61 FillC2H1(Eigen::Matrix<double,(P+1)/2,(P+1)>& C2H1) : FillC2H1<P,i,j-1>::FillC2H1(C2H1){
63 }
64 };
65
66 // case i,0, i!=0
67 template<short unsigned int P,short unsigned int i>
68 struct FillC2H1<P,i,0> : public FillC2H1<P,i-1,P>{
69 enum {j=0};
70 FillC2H1(Eigen::Matrix<double,(P+1)/2,(P+1)>& C2H1) : FillC2H1<P,i-1,P>::FillC2H1(C2H1){
72 }
73 };
74
75 // case i=j=0
76 template<short unsigned int P>
77 struct FillC2H1<P,0,0>{
78 enum {i=0, j=0};
79 FillC2H1(Eigen::Matrix<double,(P+1)/2,(P+1)>& C2H1){
81 }
82 };
83
84
85 /**********************************************************************************************************************/
86 /* Coeff2Hermite<polyDegree> class template ***************************************************************************/
87 /**********************************************************************************************************************/
164
165 template<short unsigned int polyDegree>
167
168 enum {polyCoeff=polyDegree+1};
169
170 static Eigen::Matrix<double,polyCoeff,polyCoeff> get_C2H(){
171 Eigen::Matrix<double,polyCoeff/2,polyCoeff> temp0;
172 FillC2H0<polyDegree,(polyDegree-1)/2,polyDegree> FH0(temp0);
173
174 Eigen::Matrix<double,polyCoeff/2,polyCoeff> temp1;
175 FillC2H1<polyDegree,(polyDegree-1)/2,polyDegree> FH1(temp1);
176
177 Eigen::Matrix<double,polyCoeff,polyCoeff> temp;
178 temp<<temp0,temp1;
179 return temp;
180 }
181
182 public:
183
184 static const Eigen::Matrix<double,polyDegree+1,polyDegree+1> C2H;
185 static const Eigen::Matrix<double,polyDegree+1,polyDegree+1> C2HT;
186
187 static const Eigen::Matrix<double,polyDegree+1,polyDegree+1> H2C;
188 static const Eigen::Matrix<double,polyDegree+1,polyDegree+1> H2CT;
189
190
191 /* c2h ***********************************************************/
192 template<short unsigned int dim>
193 static Eigen::Matrix<double,dim,polyCoeff> c2h(const Eigen::Matrix<double,dim,polyCoeff>& C){
197 return C*C2HT;
198 }
199
200
201 /* h2c ***********************************************************/
202 template<short unsigned int dim>
203 static Eigen::Matrix<double,dim,polyCoeff> h2c(const Eigen::Matrix<double,dim,polyCoeff>& H){
207 return H*H2CT;
208 }
209
210 };
211
212 /*************************************************************/
213 // Static const data members are computed only once at runtime
214 template<short unsigned int polyDegree>
215 const Eigen::Matrix<double,polyDegree+1,polyDegree+1> Coeff2Hermite<polyDegree>::C2H =Coeff2Hermite<polyDegree>::get_C2H();
216
217 template<short unsigned int polyDegree>
218 const Eigen::Matrix<double,polyDegree+1,polyDegree+1> Coeff2Hermite<polyDegree>::C2HT=Coeff2Hermite<polyDegree>::get_C2H().transpose();
219
220 template<short unsigned int polyDegree>
221 const Eigen::Matrix<double,polyDegree+1,polyDegree+1> Coeff2Hermite<polyDegree>::H2C =Coeff2Hermite<polyDegree>::get_C2H().inverse();
222
223 template<short unsigned int polyDegree>
224 const Eigen::Matrix<double,polyDegree+1,polyDegree+1> Coeff2Hermite<polyDegree>::H2CT=Coeff2Hermite<polyDegree>::get_C2H().inverse().transpose();
225
226}// namespace model
227#endif
228/**********************************************************************************************************************/
229/**********************************************************************************************************************/
Class template that performs the transformation between the polynomial coefficient matrix and the He...
static const Eigen::Matrix< double, polyDegree+1, polyDegree+1 > H2C
static const Eigen::Matrix< double, polyDegree+1, polyDegree+1 > C2HT
static Eigen::Matrix< double, dim, polyCoeff > h2c(const Eigen::Matrix< double, dim, polyCoeff > &H)
static const Eigen::Matrix< double, polyDegree+1, polyDegree+1 > H2CT
static const Eigen::Matrix< double, polyDegree+1, polyDegree+1 > C2H
static Eigen::Matrix< double, dim, polyCoeff > c2h(const Eigen::Matrix< double, dim, polyCoeff > &C)
static constexpr int factorial(int n)
Definition CTM.h:26
FillC2H0(Eigen::Matrix< double,(P+1)/2,(P+1)> &C2H0)
FillC2H0(Eigen::Matrix< double,(P+1)/2,(P+1)> &C2H0)
FillC2H0(Eigen::Matrix< double,(P+1)/2,(P+1)> &C2H0)
FillC2H0(Eigen::Matrix< double,(P+1)/2,(P+1)> &C2H0)
FillC2H1(Eigen::Matrix< double,(P+1)/2,(P+1)> &C2H1)
FillC2H1(Eigen::Matrix< double,(P+1)/2,(P+1)> &C2H1)
FillC2H1(Eigen::Matrix< double,(P+1)/2,(P+1)> &C2H1)
int j
int i
vertex temp