Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
BarycentricTraits.cpp
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#ifndef model_BarycentricTraits_cpp_
9#define model_BarycentricTraits_cpp_
10
11#include <BarycentricTraits.h>
12
13namespace model
14{
15
16
17 template<short int dim>
19 {
22 return X2L* (VectorHigherDimD()<< X, 1.0).finished();
23 }
24
25
26 template<short int dim>
28 {
31 assert(dim==1);
32 return X2L* (VectorHigherDimD()<< X, 1.0).finished();
33 }
34
35
36 template<short int dim>
38 {
41 return (L2X* L).template segment<dim>(0);
42 }
43
44
45 template<short int dim>
46 Eigen::Matrix<double,dim+1,1> BarycentricTraits<dim>::face2domainBary(const Eigen::Matrix<double,dim,1>& b1,const int& boundaryFace)
47 {
48 // Transform to barycentric coordinate on the volume, adding a zero on the boundaryFace-face
49 Eigen::Matrix<double,dim+1,1> bary;
50 for (int k=0;k<dim;++k)
51 {
52 bary((k<boundaryFace)? k : k+1)=b1(k);
53 }
54 bary(boundaryFace)=0.0;
55 return bary;
56 }
57
58
59
60 template<short int dim>
61 typename BarycentricTraits<dim>::MatrixHigherDimD BarycentricTraits<dim>::get_L2X()
62 {/*!/returns the barycentric-to-standard coordinate transformation matrix.
63 *
64 * For example, in 2d, the transformation is:
65 * \f[
66 * \left[\begin{array}{lll}
67 * v_{11}&v_{21}&v_{31}\\
68 * v_{12}&v_{22}&v_{32}\\
69 * 1&1&1\\
70 * \end{array}
71 * \right]
72 * \left[\begin{array}{l}
73 * \lambda_1\\
74 * \lambda_2\\
75 * \lambda_3\\
76 * \end{array}
77 * \right]=
78 * \left[\begin{array}{c}
79 * s_1\\
80 * s_2\\
81 * 1\\
82 * \end{array}
83 * \right]
84 * \f]
85 *
86 * In the sandard domain, we now adopt the convention that, for i<n,
87 * the i-th vertex is on the i-th axis at a unit distance from the
88 * origin, while the n-th vertex is the origin. With this convention,
89 * plugging in the coordinates of the standard vertices, we obtain:
90 * \f[
91 * \underbrace{\left[\begin{array}{lll}
92 * 1&0&0\\
93 * 0&1&0\\
94 * 1&1&1\\
95 * \end{array}
96 * \right]}_{L2X}
97 * \left[\begin{array}{l}
98 * \lambda_1\\
99 * \lambda_2\\
100 * \lambda_3\\
101 * \end{array}
102 * \right]=
103 * \left[\begin{array}{c}
104 * s_1\\
105 * s_2\\
106 * 1\\
107 * \end{array}
108 * \right]
109 * \f]
110 */
111 MatrixHigherDimD temp(MatrixHigherDimD::Identity());
112 temp.template block<1,dim>(dim,0)=Eigen::Matrix<double,1,dim>::Ones();
113 return temp;
114 }
115
116
117 template<short int dim>
118 typename BarycentricTraits<dim>::MatrixHigherDimD BarycentricTraits<dim>::get_X2L()
119 {/*!/returns the standard-2-barycentric coordinate transformation matrix,
120 * that is the inverse ofget_L2X().
121 */
122 MatrixHigherDimD temp(MatrixHigherDimD::Identity());
123 temp.template block<1,dim>(dim,0)= -Eigen::Matrix<double,1,dim>::Ones();
124 return temp;
125 }
126
127
128 template<short int dim>
129 typename BarycentricTraits<dim>::MatrixDimHigherDimD BarycentricTraits<dim>::get_NdA()
130 {/*!/returns a matrix having in columns the non-unitary outward normals
131 * in the standard simplex. The norm of the normal is the ratio between
132 * the area of the face to the area of a dim-1 Simplex.
133 */
134 MatrixHigherDimDimD temp(-get_L2X().template block<dim+1,dim>(0,0));
135 for (int r=0;r<dim;++r)
136 {
137 temp.row(r).normalize(); // norm of first dim-1 normals is unitary
138 }
139 temp.row(dim)*=-1.0; // flip direction of the inclined face normal
140 return temp.transpose();
141 }
142
143
144
145 // Declare static data member
146// template<short int dim>
147// const typename BarycentricTraits<dim>::MatrixHigherDimD BarycentricTraits<dim>::L2X=BarycentricTraits<dim>::get_L2X();
148//
149// template<short int dim>
150// const typename BarycentricTraits<dim>::MatrixHigherDimD BarycentricTraits<dim>::X2L=BarycentricTraits<dim>::get_X2L();
151//
152// template<short int dim>
153// const typename BarycentricTraits<dim>::MatrixHigherDimDimD BarycentricTraits<dim>::dLdX=BarycentricTraits<dim>::X2L. template block<dim+1,dim>(0,0);
154//
155// template<short int dim>
156// const typename BarycentricTraits<dim>::MatrixDimHigherDimD BarycentricTraits<dim>::NdA=BarycentricTraits<dim>::get_NdA();
157
158 template struct BarycentricTraits<1>;
159 template struct BarycentricTraits<2>;
160 template struct BarycentricTraits<3>;
161}
162#endif
float r
Definition plotLoops.py:41
Eigen::Matrix< double, dim,1 > VectorDimD
Eigen::Matrix< double, dim, dim+1 > MatrixDimHigherDimD
static VectorHigherDimD x2l(const VectorDimD &X)
static VectorDimD l2x(const VectorHigherDimD &L)
Eigen::Matrix< double, dim+1, dim+1 > MatrixHigherDimD
static Eigen::Matrix< double, dim+1, 1 > face2domainBary(const Eigen::Matrix< double, dim, 1 > &b1, const int &boundaryFace)
static const MatrixHigherDimD X2L
Eigen::Matrix< double, dim+1, 1 > VectorHigherDimD
static const MatrixHigherDimD L2X
int k
vertex temp