Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
MulticomponentExpander.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#ifndef model_MulticomponentExpander_H_
9#define model_MulticomponentExpander_H_
10
11#include <Eigen/Dense>
12
13namespace model
14{
15
16
17 template<int c>
19 {
20
21 template<typename T, int N>
22 static Eigen::Matrix<T,c,c*N> expandSF(const Eigen::Matrix<T,1,N>& m)
23 {
24 Eigen::Matrix<T,c,c*N> temp;
25 for (int j=0;j<N;++j)
26 {
27 temp.template block<c,c>(0,c*j).setIdentity()*=m(j);
28 //temp.template block<c,c>(0,c*j)*=m(j);
29
30 }
31 return temp;
32 }
33
34 template<typename T,int dim, int N>
35 static Eigen::Matrix<T,c*dim,c*N> expandSFgrad(const Eigen::Matrix<T,dim,N>& m)
36 {
37 Eigen::Matrix<T,c*dim,c*N> temp(Eigen::Matrix<T,c*dim,c*N>::Zero());
38 for (int j=0;j<N;++j)
39 {
40 for (int i=0;i<c;++i)
41 {
42 temp.template block<dim,1>(dim*i,c*j+i).setIdentity()=m.col(j);
43 }
44 }
45 return temp;
46 }
47
48// template<typename T, int N>
49// static Eigen::Matrix<T,(c*(c+1))/2,c*N> expandSFdef(const Eigen::Matrix<T,c,N>& m)
50// {
51// Eigen::Matrix<T,(c*(c+1))/2,c*N> temp(Eigen::Matrix<T,(c*(c+1))/2,c*N>::Zero());
52//
53// for (int n=0;n<N;++n) // loop over shape functions
54// {
55// int row=0;
56// for (int k=0;k<c;++k) // k is the index of the diagonal
57// {
58// for (int j=0;j<c-k;++j)
59// {
60// temp(row,n*c+j+k)+=0.5*m(j ,n);
61// temp(row,n*c+j )+=0.5*m(j+k,n);
62// row++;
63// }
64// }
65// }
66// return temp;
67// }
68
69 template<typename T, int N>
70 static Eigen::Matrix<T,(c*(c+1))/2,c*N> expandSFdef(const Eigen::Matrix<T,c,N>& m)
71 {
76 Eigen::Matrix<T,(c*(c+1))/2,c*N> temp(Eigen::Matrix<T,(c*(c+1))/2,c*N>::Zero());
77
78 for (int n=0;n<N;++n) // loop over shape functions
79 {
80 int row=0;
81 for (int k=0;k<c;++k) // k is the index of the diagonal
82 {
83 for (int j=0;j<c-k;++j)
84 {
85 if(k==0)
86 {
87 temp(row,n*c+j)=m(j,n);
88 }
89 else
90 {
91 temp(row,n*c+j+k)=m(j ,n);
92 temp(row,n*c+j )=m(j+k,n);
93 }
94 row++;
95 }
96 }
97 }
98 return temp;
99 }
100
101 };
102
103 template<>
105 {
106
107 template<typename T, int N>
108 static const Eigen::Matrix<T,1,N>& expandSF(const Eigen::Matrix<T,1,N>& m)
109 {
110 return m;
111 }
112
113 template<typename T,int dim, int N>
114 static const Eigen::Matrix<T,dim,N>& expandSFgrad(const Eigen::Matrix<T,dim,N>& m)
115 {
116 return m;
117 }
118
119 template<typename T, int N>
120 static const Eigen::Matrix<T,1,N>& expandSFdef(const Eigen::Matrix<T,1,N>& m)
121 {
122 return m;
123 }
124
125
126 };
127
128
129} // close namespace
130#endif
c
Definition int_R.m:15
static const Eigen::Matrix< T, 1, N > & expandSFdef(const Eigen::Matrix< T, 1, N > &m)
static const Eigen::Matrix< T, dim, N > & expandSFgrad(const Eigen::Matrix< T, dim, N > &m)
static const Eigen::Matrix< T, 1, N > & expandSF(const Eigen::Matrix< T, 1, N > &m)
static Eigen::Matrix< T,(c *(c+1))/2, c *N > expandSFdef(const Eigen::Matrix< T, c, N > &m)
static Eigen::Matrix< T, c *dim, c *N > expandSFgrad(const Eigen::Matrix< T, dim, N > &m)
static Eigen::Matrix< T, c, c *N > expandSF(const Eigen::Matrix< T, 1, N > &m)
int j
int k
int i
vertex temp
void t struct mesh * m