-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathconstitutiveModel.cpp
More file actions
231 lines (152 loc) · 6.67 KB
/
constitutiveModel.cpp
File metadata and controls
231 lines (152 loc) · 6.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
//
// Created by ziyinqu on 11/9/17.
//
#include "constitutiveModel.h"
#include <cmath>
#include <iostream>
using namespace std;
void corotatedPiolaDouble(Matrix3d defGrad, double& energy, Eigen::Matrix3d& piola){
double E = 50;
double nu = 0.3;
double lambda = E * nu / (((double)1 + nu) * ((double)1 - (double)2 * nu));
double mu = E / ((double)2 * ((double)1 + nu));
//cout << "DefGrad: " << defGrad << endl;
SVDResultDouble svdResult = SingularValueDecomposition3DDouble(defGrad);
Matrix3d U, sigma, V;
U = svdResult.U;
sigma = svdResult.SIGMA;
V = svdResult.V;
//cout << "U: " << U << endl;
//cout << "Sigma: " << sigma << endl;
//cout << "V: " << V << endl;
Matrix3d R = U * V.transpose();
double J = defGrad.determinant();
piola = (2 * mu * (defGrad - R)) + (lambda * (J-1) * J * (defGrad.inverse().transpose()));
energy = mu * (defGrad - R).squaredNorm() + (lambda / 2) * (J - 1) * (J - 1);
return;
}
void corotatedPiola(Matrix3f defGrad, Eigen::Matrix3f& piola){
//cout << "Using Corotated Model!!" << endl;
float E = 50;
float nu = 0.3;
float lambda = E * nu / (((float)1 + nu) * ((float)1 - (float)2 * nu));
float mu = E / ((float)2 * ((float)1 + nu));
//cout << "DefGrad: " << defGrad << endl;
SVDResult svdResult = SingularValueDecomposition3D(defGrad);
Matrix3f U, sigma, V;
U = svdResult.U;
sigma = svdResult.SIGMA;
V = svdResult.V;
//cout << "U: " << U << endl;
//cout << "Sigma: " << sigma << endl;
//cout << "V: " << V << endl;
Matrix3f R = U * V.transpose();
float J = defGrad.determinant();
Matrix3f JFinvT;
// JFinvT(0, 0) = defGrad(1, 1) * defGrad(2, 2) - defGrad(1, 2) * defGrad(2, 1);
// JFinvT(0, 1) = defGrad(1, 2) * defGrad(2, 0) - defGrad(1, 0) * defGrad(2, 2);
// JFinvT(0, 2) = defGrad(1, 0) * defGrad(2, 1) - defGrad(1, 1) * defGrad(2, 0);
// JFinvT(1, 0) = defGrad(0, 2) * defGrad(2, 1) - defGrad(0, 1) * defGrad(2, 2);
// JFinvT(1, 1) = defGrad(0, 0) * defGrad(2, 2) - defGrad(0, 2) * defGrad(2, 0);
// JFinvT(1, 2) = defGrad(0, 1) * defGrad(2, 0) - defGrad(0, 0) * defGrad(2, 1);
// JFinvT(2, 0) = defGrad(0, 1) * defGrad(1, 2) - defGrad(0, 2) * defGrad(1, 1);
// JFinvT(2, 1) = defGrad(0, 2) * defGrad(1, 0) - defGrad(0, 0) * defGrad(1, 2);
// JFinvT(2, 2) = defGrad(0, 0) * defGrad(1, 1) - defGrad(0, 1) * defGrad(1, 0);
piola = (2 * mu * (defGrad - R)) + (lambda * (J-1) * J * (defGrad.transpose().inverse()));
// piola = (2 * mu * (defGrad - R)) + (lambda * (J-1) * JFinvT);
}
void neoHookeanPiola(Matrix3f defGrad, Eigen::Matrix3f& piola){
//cout << "Using NeoHookean Model!!" << endl;
float E = 50;
float nu = 0.3;
float mu = E / ((float)2 * ((float)1 + nu));
float lambda = E * nu / (((float)1 + nu) * ((float)1 - ((float)2*nu)));
SVDResult svdResult = SingularValueDecomposition3D(defGrad);
Matrix3f U, sigma, V;
U = svdResult.U;
sigma = svdResult.SIGMA;
V = svdResult.V;
Matrix3f R = U * V.transpose();
float J = defGrad.determinant();
piola = (mu * (defGrad - defGrad.transpose().inverse())) + (lambda * log(J) * defGrad.transpose().inverse());
}
void neoHookeanPiolaDouble(Matrix3d defGrad, double& energy, Eigen::Matrix3d& piola){
double E = 50;
double nu = 0.3;
double mu = E / ((double)2 * ((double)1 + nu));
double lambda = E * nu / (((double)1 + nu) * ((double)1 - ((double)2*nu)));
SVDResultDouble svdResult = SingularValueDecomposition3DDouble(defGrad);
Matrix3d U, sigma, V;
U = svdResult.U;
sigma = svdResult.SIGMA;
V = svdResult.V;
Matrix3d R = U * V.transpose();
double J = defGrad.determinant();
piola = (mu * (defGrad - defGrad.transpose().inverse())) + (lambda * log(J) * defGrad.transpose().inverse());
Matrix3d fTf = defGrad.transpose() * defGrad;
energy = ((mu / (double)2) * (fTf.trace() - (double)3)) - (mu * log(J)) + ((lambda/(double)2) * log(J) * log(J));
}
void stVernantPiola(Matrix3f defGrad, Eigen::Matrix3f& piola){
//cout << "Using St Vernant Model!!" << endl;
float E = 50;
float nu = 0.3;
float mu = E / ((float)2 * ((float)1 + nu));
float lambda = E * nu / (((float)1 + nu) * ((float)1 - ((float)2*nu)));
SVDResult svdResult = SingularValueDecomposition3D(defGrad);
Matrix3f U, sigma, V;
U = svdResult.U;
sigma = svdResult.SIGMA;
V = svdResult.V;
Matrix3f R = U * V.transpose();
float J = defGrad.determinant();
Matrix3f logSigma = Matrix3f::Zero();
logSigma(0,0) = log(sigma(0,0));
logSigma(1,1) = log(sigma(1,1));
logSigma(2,2) = log(sigma(2,2));
Matrix3f piolaSingular = (2 * mu * logSigma * sigma.inverse()) + (lambda * logSigma.trace() * sigma.inverse()); //calculate singular value view of piola
//now calculate actual P!
piola = U * piolaSingular * V.transpose();
}
void stVernantPiolaDouble(Matrix3d defGrad, double& energy, Eigen::Matrix3d& piola){
double E = 50;
double nu = 0.3;
double mu = E / ((double)2 * ((double)1 + nu));
double lambda = E * nu / (((double)1 + nu) * ((double)1 - ((double)2*nu)));
SVDResultDouble svdResult = SingularValueDecomposition3DDouble(defGrad);
Matrix3d U, sigma, V;
U = svdResult.U;
sigma = svdResult.SIGMA;
V = svdResult.V;
Matrix3d R = U * V.transpose();
double J = defGrad.determinant();
Matrix3d logSigma = Matrix3d::Zero();
logSigma(0,0) = log(sigma(0,0));
logSigma(1,1) = log(sigma(1,1));
logSigma(2,2) = log(sigma(2,2));
Matrix3d piolaSingular = (2 * mu * logSigma * sigma.inverse()) + (lambda * logSigma.trace() * sigma.inverse()); //calculate singular value view of piola
//now calculate actual P!
piola = U * piolaSingular * V.transpose();
energy = (mu * (logSigma * logSigma).trace()) + ((lambda/(double)2) * (logSigma.trace()) * logSigma.trace());
}
void snowPiola(Matrix3f defGrad, Matrix3f Fp, Matrix3f Fe, Matrix3f& piola){
// initla Lame parameters
float E = 50;
float nu = 0.2;
float lambda = E * nu / (((float)1 + nu) * ((float)1 - (float)2 * nu));
float mu = E / ((float)2 * ((float)1 + nu));
float hc = 10;
float Jp = Fp.determinant();
float Je = Fe.determinant();
float muFp = mu*exp(10*(1-Jp));
float lambdaFp = lambda*exp(10*(1-Jp));
SVDResult svdResult = SingularValueDecomposition3D(Fe);
Matrix3f Ue, sigmae, Ve;
Ue = svdResult.U;
sigmae = svdResult.SIGMA;
Ve= svdResult.V;
//cout << "U: " << U << endl;
//cout << "Sigma: " << sigma << endl;
//cout << "V: " << V << endl;
Matrix3f Re = Ue * Ve.transpose();
piola = (2 * muFp * (Fe - Re)) + (lambdaFp * (Je-1) * Je * (Fe.transpose().inverse()));
}