Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
PolyhedronInclusion_yang.cpp
Go to the documentation of this file.
1/* This file is part of MODEL, the Mechanics Of Defect Evolution Library.
2 *
3 * Copyright (C) 2018 by Giacomo Po <gpo@ucla.edu>.
4 * Copyright (C) 2018 by Yinan Cui <gpo@ucla.edu>.
5 *
6 * model is distributed without any warranty under the
7 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
8 */
9
10#ifndef model_PolyhedronInclusion_cpp_
11#define model_PolyhedronInclusion_cpp_
12
13
15#include <numbers>
16
17namespace model
18{
19
20
21// template <int dim>
22// void PolyhedronInclusion<dim>::addSlipSystems(const std::vector<std::shared_ptr<SlipSystem>>& slipSystems)
23// {
24//
25// for(const auto& slipSystem : slipSystems)
26// {
27// if(gammaSurfaceMap.find(slipSystem->gammaSurface.get())==gammaSurfaceMap.end())
28// {// current slipSystem gammaSurface not found
29//
30// // GammaSurface temp();
31// //
32// // gammaSurfaceMap.emaplace(slipSystem->gammaSurface.get(),temp);
33// }
34// }
35//
36// }
37
38// template <int dim>
39// double PolyhedronInclusion<dim>::misfitEnergy(const Eigen::Matrix<double,3,1>& b, const GammaSurface* const matrixGammaSurface) const
40// {
41// const auto iter(gammaSurfaceMap.find(matrixGammaSurface));
42// return iter==gammaSurfaceMap.end()? 0.0 : iter->second(b);
43// }
44
45
46
47
48 template <int dim>
50 const std::map<size_t,std::vector<size_t>>& faceIDs,
51 const MatrixDim& _eT,
52 const double& _nu,
53 const double& _mu,
54 const double& _mobilityReduction,
55 const int& _phaseID,
56 const int& _masterID,
57 const std::shared_ptr<SecondPhase<dim>>& sph) :
58 /* init */ EshelbyInclusionBase<dim>(_eT,_nu,_mu,_mobilityReduction,_phaseID,sph)
59 /* init */,delta(MatrixDim::Identity())
60 /* init */,nodes(nodesMap)
61 /* init */,faces(getFaces(nodesMap,faceIDs))
62 /* init */,masterID(_masterID)
63 {
64// std::cout<<"Creating PolyhedronInclusion "<<this->sID<<" (type "<<this->phaseID<<"):\n eT="<<this->eT<<std::endl;
65 VectorDim iC(VectorDim::Zero()); // inclusion center
66 for(const auto& face : faces)
67 {
68 for(const auto& nodePair : face.second)
69 {
70 iC+=nodePair.second/face.second.size()/faces.size();
71 }
72 }
73
74 for(const auto& face : faces)
75 {
76 VectorDim C(VectorDim::Zero()); // face center
77 for(const auto& nodePair : face.second)
78 {
79// const auto nodeIter(nodes.find(nodeID));
80 C+=nodePair.second;
81// if(nodeIter!=nodes.end())
82// {
83// C+=nodeIter->second.P;
84// }
85// else
86// {
87// throw std::runtime_error("PolyhedronInclusion: nodeID not found in nodes.");
88// }
89 }
90 C/=face.second.size();
91
92 VectorDim nA(VectorDim::Zero()); // normal
93// const VectorDim P0(nodes.find(face.second.front())->second.P);
94 const VectorDim P0(face.second.front().second);
95 for(size_t k=0;k<face.second.size();++k)
96 {
97 const size_t k1(k<face.second.size()-1? k+1 : 0);
98// const VectorDim Pk(nodes.find(face.second[k])->second.P);
99// const VectorDim Pk1(nodes.find(face.second[k1])->second.P);
100 const VectorDim Pk(face.second[k].second);
101 const VectorDim Pk1(face.second[k1].second);
102 nA+= 0.5*(Pk-P0).cross(Pk1-Pk);
103 }
104
105
106 // Check if the connection is right-handed
107 if( (C-iC).dot(nA)<0.0 )
108 {
109 nA*=-1.0;
110 }
111 //std::cout<<nA.transpose()<<std::endl;
112 //std::cout<<C.transpose()<<std::endl;
113 //std::cout<<iC.transpose()<<std::endl;
114
115 Plane<3> plane(C,nA);
116 for(const auto& nodePair : face.second)
117 {
118// const auto nodeIter(nodes.find(nodeID));
119// if(nodeIter!=nodes.end())
120// {
121 if(!plane.contains(nodePair.second))
122 {
123 throw std::runtime_error("PolyhedronInclusion: face plane does not include face vertex.");
124 }
125// }
126 }
127 this->emplace(face.first,plane);
128 }
129 }
130
131template <int dim>
132typename PolyhedronInclusion<dim>::VectorDim PolyhedronInclusion<dim>::center() const
133{
134 VectorDim C(VectorDim::Zero()); // inclusion center
135 for(const auto& face : faces)
136 {
137 for(const auto& nodePair : face.second)
138 {
139 C+=nodePair.second/face.second.size()/faces.size();
140 }
141 }
142 return C;
143}
144
145template <int dim>
146const std::map<size_t,Plane<dim>>& PolyhedronInclusion<dim>::planes() const
147{
148 return *this;
149}
150
151template <int dim>
153{
154 bool contained(true);
155 for(const auto& plane : this->planes())
156 {
157 contained=(contained && plane.second.isAbove(x));
158 }
159 return contained;
160}
161
162template <int dim>
163std::map<size_t,std::vector<std::pair<size_t,typename PolyhedronInclusion<dim>::VectorDim>>> PolyhedronInclusion<dim>::getFaces(const std::map<size_t,PolyhedronInclusionNodeIO<dim>>& nodesMap,
164 const std::map<size_t,std::vector<size_t>>& faceIDs)
165{
166 std::map<size_t,std::vector<std::pair<size_t,VectorDim>>> temp;
167 for(const auto& fID : faceIDs)
168 {
169 std::vector<std::pair<size_t,VectorDim>> tempV;
170 for(const auto& nID : fID.second)
171 {
172 const auto nodeIter(nodesMap.find(nID));
173 if(nodeIter!=nodesMap.end())
174 {
175 tempV.emplace_back(nID,nodeIter->second.P);
176 }
177 else
178 {
179 throw std::runtime_error("PolyhedronInclusion node not found.");
180 }
181 }
182 temp.emplace(fID.first,tempV);
183 }
184 return temp;
185}
186
187template <int dim>
188double PolyhedronInclusion<dim>::Phi_u_II_a(double a, double b, double le)//correct for asin
189{
190
191 if (a != 0 && b != 0 && le != 0) {
192 //std::cout << "second: " <<a * le * abs(b) / (b * sqrt((a * a + b * b) * (b * b + le * le)))<<std::endl;
193 //const double xx = a * le * abs(b) / (b * sqrt((a * a + b * b) * (b * b + le * le)));
194 double temp = a * le * abs(b) / (b * sqrt((a * a + b * b) * (b * b + le * le)));
195 //std::cout << " xx= " << xx << ", asin(xx)= " << asin(xx) <<std::endl;
196 if (temp > 1.0)
197 {
198 temp = 1.0-DBL_EPSILON;//使用 DBL_EPSILON 代替 FLT_EPSILON,以匹配 double 类型的精度
199 }
200 else if (temp < -1.0)
201 {
202 temp = -1.0+DBL_EPSILON;
203 }
204 return -a / abs(a) * atan(le / b) + asin(temp);//保证atanh函数在[-1,1]区间内
205 }
206 else if (a == 0) {
207 return 0.0;
208 }
209 else if (a != 0) {
210 return 0.0;
211 }
212
213 // a, b, le equals zero
214 return 0.0;
215}
216
217
218template <int dim>
219double PolyhedronInclusion<dim>::Phi_u_II_b(double a, double b, double le)//correct for atant
220{
221 double dis = sqrt(a * a + b * b + le * le);
222 auto adjust_temp = [](double temp) {
223 if (temp >= 1.0)
224 {
225 return 1.0-DBL_EPSILON;//使用 DBL_EPSILON 代替 FLT_EPSILON,以匹配 double 类型的精度
226 }
227 else if (temp <= -1.0)
228 {
229 return -1.0+DBL_EPSILON;
230 }
231 return temp;//保证atanh函数在(-1,1)区间内
232 };
233 if (a != 0 && b != 0 && le != 0) {
234 double temp = adjust_temp(le / dis);
235 return (1.0 / (b * b + le * le)) * (
236 -le * dis + le * abs(a) + (b * b + le * le) * atanh(temp));
237 }
238 else if (a == 0) {
239 if (b != 0) { // le may equal zero, all includes
240 double temp = adjust_temp(le / dis);
241 return -le / dis + atanh(temp);
242 }
243 else { // b ==0, le != 0
244 return 0.0;
245 }
246 }
247 else if (a != 0) {
248 if (b != 0 && le == 0) {
249 return 0.0;
250 }
251 else if (b == 0 && le == 0) {
252 return 0.0;
253 }
254 else if (b == 0 && le != 0) {
255 double temp = adjust_temp(le / dis);
256 return (-dis + abs(a)) / le + atanh(temp);
257 }
258 }
259
260 // a, b, le equals zero
261 return 0.0;
262}
263
264template <int dim>
265double PolyhedronInclusion<dim>::Phi_u_II_le(double a, double b, double le)
266{
267 if (a != 0 && b != 0 && le != 0) {
268 return b * (a * a + b * b + le * le - sqrt(a * a + b * b + le * le) * abs(a)) / ((b * b + le * le) * sqrt(a * a + b * b + le * le));
269 }
270 else if (a == 0) {
271 if (b != 0 || le != 0) {
272 return b / sqrt(b * b + le * le);
273 }
274 else {
275 return 0.0;
276 }
277 }
278 else if (a != 0) {
279 if (b != 0 && le == 0) {
280 return (sqrt(a * a + b * b) - abs(a)) / b;
281 }
282 else if (b == 0 && le != 0) {
283 return 0.0;
284 }
285 else if (b == 0 && le == 0) {
286 return 0.0;
287 }
288 }
289
290 return 0.0;
291}
292
293//template <int dim>
294//double PolyhedronInclusion<dim>::PHI_ij(int i, int j, double a, double b, double lm, double lp, const VectorDim& Svnorm, const VectorDim& Vnorm, const VectorDim& Vdir)
295//{
296// return -(Svnorm[i]) * (-(Phi_u_II_a(a, b, lp) - Phi_u_II_a(a, b, lm)) * Svnorm[j]
297// - (Phi_u_II_b(a, b, lp) - Phi_u_II_b(a, b, lm)) * Vnorm[j]
298// - (Phi_u_II_le(a, b, lp)) * Vdir[j] + (Phi_u_II_le(a, b, lm)) * Vdir[j]);
299//}
300
301//template <int dim>
302//double PolyhedronInclusion<dim>::PHI_ij(int i, int j, const VectorDim& x) const
303//{
304// double result=0.0;
305// for(const auto& face : faces)
306// {
307// const auto& P0(face.second[0].second);
308// const auto& P1(face.second[1].second);
309// const auto& P2(face.second[2].second);
310// const VectorDim Svnorm((P1-P0).cross(P2-P1).normalized());
311// const double a(Svnorm.dot(P0-x));
312// for(size_t e=0;e<face.second.size();++e)
313// {
314// const size_t e1(e<face.second.size()-1? e+1 : 0);
315// const VectorDim& vm(face.second[e].second);
316// const VectorDim& vp(face.second[e1].second);
317// const VectorDim Vdir((vp-vm).normalized());
318// const VectorDim Vnorm(Vdir.cross(Svnorm));
319// const double b((vp-x).dot(Vnorm));
320// const double lm((vm-x).dot(Vdir));
321// const double lp((vp-x).dot(Vdir));
322// result+=PHI_ij(i,j,a,b,lm,lp,Svnorm,Vnorm,Vdir);
323// }
324// }
325// return result;
326//}
327
328template <int dim>
329double PolyhedronInclusion<dim>::Psi_I1_a_a_a(double a, double b, double le)
330{
331 double dis = sqrt(a * a + b * b + le * le);
332 if (a < 0 && b != 0 && le != 0) {
333 return a * b * le / ((a * a + b * b) * dis) + 2.0 * atan(le / b) + 2.0 * atan(a * le / (b * dis));
334 }
335 else if (a > 0 && b != 0 && le != 0) {
336 return a * b * le / ((a * a + b * b) * dis) - 2.0 * atan(le / b) + 2.0 * atan(a * le / (b * dis));
337 }
338
339 return 0.0;
340}
341
342template <int dim>
343double PolyhedronInclusion<dim>::Psi_I1_a_a_b(double a, double b, double le)//correct for atant
344{
345 double dis = sqrt(a * a + b * b + le * le);
346 auto adjust_temp = [](double temp) {
347 if (temp >= 1.0)
348 {
349 return 1.0-DBL_EPSILON;//使用 DBL_EPSILON 代替 FLT_EPSILON,以匹配 double 类型的精度
350 }
351 else if (temp <= -1.0)
352 {
353 return -1.0+DBL_EPSILON;
354 }
355 return temp;//保证atanh函数在(-1,1)区间内
356 };
357 if (a < 0 && b != 0 && le != 0) {
358 double temp = adjust_temp(le / dis);
359 return -le * (2.0 * a * a + b * b + a * b * b / dis) / ((a * a + b * b) * (dis - a)) + atanh(temp);
360 }
361 else if (a > 0 && b != 0 && le != 0) {
362 double temp = adjust_temp(le / dis);
363 return 2.0 * a * le / (b * b + le * le) + (le / dis) * (-2.0 + b * b / (a * a + b * b) - 2.0 * a * a / (b * b + le * le)) + atanh(temp);
364 }
365 else if (a == 0) {
366 if (b != 0) {
367 double temp = adjust_temp(le / dis);
368 return -le / dis + atanh(temp);
369 }
370 else { // include b = 0, le != 0, this is infinite
371 return 0.0;
372 }
373 }
374 else if (a != 0) {
375 if (b != 0 && le == 0) {
376 return 0.0;
377 }
378 else if (b == 0 && le != 0) {
379 double temp = adjust_temp(le / dis);
380 return 2.0 * (abs(a) - dis) / le + atanh(temp);
381 }
382 else if (b == 0 && le == 0) {
383 return 0.0;
384 }
385 }
386
387 return 0.0;
388}
389
390template <int dim>
391double PolyhedronInclusion<dim>::Psi_I1_a_a_le(double a, double b, double le)
392{
393 double dis = sqrt(a * a + b * b + le * le);
394 if (a != 0 && b != 0 && le != 0) {
395 return (b / (b * b + le * le)) * (-2.0 * abs(a) + dis + (a * a) / dis);
396 }
397 else if (a == 0) {
398 if (b != 0) {
399 return b / dis;
400 }
401 else {
402 return 0.0;
403 }
404 }
405 else if (a != 0) {
406 if (b != 0 && le == 0) {
407 return ((2.0 * a * a + b * b) / dis - 2.0 * abs(a)) / b;
408 }
409 else if (b == 0 && le != 0) {
410 return 0.0;
411 }
412 else if (b == 0 && le == 0) {
413 return 0.0;
414 }
415 }
416
417 return 0.0;
418}
419
420template <int dim>
421double PolyhedronInclusion<dim>::Psi_I1_a_b_b(double a, double b, double le)
422{
423 double dis = sqrt(a * a + b * b + le * le);
424 if (a != 0 && b != 0 && le != 0) {
425 return (a * b * le / ((a * a + b * b) * pow(b * b + le * le, 2.0) * dis)) * (
426 2.0 * pow(a, 4.0) - le * le * (b * b + le * le) + a * a * (3.0 * b * b + le * le) - 2.0 * (a * a + b * b) * dis * abs(a)
427 );
428 }
429
430 return 0.0;
431
432}
433
434template <int dim>
435double PolyhedronInclusion<dim>::Psi_I1_a_b_le(double a, double b, double le)
436{
437 double dis = sqrt(a * a + b * b + le * le);
438 if (a != 0 && b != 0 && le != 0) {
439 return (a / (pow(b * b + le * le, 2.0) * dis)) * (
440 -pow(a * b, 2.0) + (a * a + b * b) * le * le + pow(le, 4.0) + (b * b - le * le) * dis * abs(a)
441 );
442 }
443 else if (a == 0) {
444 return 0.0;
445 }
446 else if (a != 0) {
447 if (b != 0 && le == 0) {
448 return a * (-a * a / dis + abs(a)) / (b * b);
449 }
450 else if (b == 0 && le != 0) {
451 return a * (dis - abs(a)) / (le * le);
452 }
453 else if (b == 0 && le == 0) {
454 return 0.5 * a / abs(a);
455 }
456 }
457
458 return 0.0;
459}
460
461template <int dim>
462double PolyhedronInclusion<dim>::Psi_I1_a_le_le(double a, double b, double le)
463{
464 double dis = sqrt(a * a + b * b + le * le);
465 if (a != 0 && b != 0 && le != 0) {
466 return -a * b * le * (
467 a * a + dis * dis - 2.0 * dis * abs(a)
468 ) / (pow(b * b + le * le, 2.0) * dis);
469 }
470
471 return 0.0;
472}
473
474template <int dim>
475double PolyhedronInclusion<dim>::Psi_I1_b_b_b(double a, double b, double le)// correct for atanh
476{
477 double dis = sqrt(a * a + b * b + le * le);
478 auto adjust_temp = [](double temp) {
479 if (temp >= 1.0)
480 {
481 return 1.0-DBL_EPSILON;//使用 DBL_EPSILON 代替 FLT_EPSILON,以匹配 double 类型的精度
482 }
483 else if (temp <= -1.0)
484 {
485 return -1.0+DBL_EPSILON;
486 }
487 return temp;//保证atanh函数在(-1,1)区间内
488 };
489 if (a != 0 && b != 0 && le != 0) {
490 double temp = adjust_temp(le / dis);
491 return (1.0 / (3.0 * (a * a + b * b) * pow(b * b + le * le, 3.0) * dis)) * (
492 2.0 * pow(a, 6.0) * le * (-3.0 * b * b + le * le) - b * b * le * pow(b * b + le * le, 2.0) * (3.0 * b * b + 4.0 * le * le)
493 - a * a * le * (b * b + le * le) * (3.0 * pow(b, 4.0) + pow(le, 4.0)) + pow(a, 4.0) * (-9.0 * pow(b, 4.0) * le + pow(le, 5.0))
494 )
495 - 2.0 * le * (-3.0 * b * b + le * le) * pow(abs(a), 3.0) / (3.0 * pow(b * b + le * le, 3.0))
496 + atanh(temp);
497 }
498 else if (a == 0) {
499 if (b != 0) {
500 double temp = adjust_temp(le / dis);
501 return -le * (3.0 * b * b + 4.0 * le * le) / (3.0 * dis * dis * dis) + atanh(temp);
502 }
503 else { // infinite
504 return 0.0;
505 }
506 }
507 else if (a != 0) {
508 if (b != 0 && le == 0) {
509 return 0.0;
510 }
511 else if (b == 0 && le != 0) {
512 double temp = adjust_temp(le / dis);
513 return (1.0 / (3.0 * pow(le, 3.0) * dis)) * (2.0 * pow(a, 4.0) + a * a * le * le - pow(le, 4.0)) - 2.0 * pow(abs(a), 3.0) / (3.0 * le * le * le) + atanh(temp);
514 }
515 else if (b == 0 && le == 0) {
516 return 0.0;
517 }
518 }
519
520 return 0.0;
521}
522
523template <int dim>
524double PolyhedronInclusion<dim>::Psi_I1_b_b_le(double a, double b, double le)
525{
526 double dis = sqrt(a * a + b * b + le * le);
527 if (a != 0 && b != 0 && le != 0) {
528 return (b / (3.0 * pow(b * b + le * le, 3.0) * dis)) * (
529 2.0 * pow(a, 4.0) * (b * b - 3.0 * le * le) + a * a * (b * b - 3.0 * le * le) * (b * b + le * le)
530 + pow(b * b + le * le, 2.0) * (2.0 * b * b + 3.0 * le * le) - 2.0 * (b * b - 3.0 * le * le) * dis * pow(abs(a), 3.0)
531 );
532 }
533 else if (a == 0) {
534 if (b != 0) {
535 return b * (2.0 * b * b + 3.0 * le * le) / (3.0 * dis * dis * dis);
536 }
537 else {
538 return 0.0;
539 }
540 }
541 else if (a != 0) {
542 if (b != 0 && le == 0) {
543 return (2.0 * pow(a, 4.0) + pow(a * b, 2.0) + 2.0 * pow(b, 4.0) - 2.0 * dis * pow(abs(a), 3.0)) / (3.0 * pow(b, 3.0) * dis);
544 }
545 else if (b == 0 && le != 0) {
546 return 0.0;
547 }
548 else if (b == 0 && le == 0) {
549 return 0.0;
550 }
551 }
552
553 return 0.0;
554}
555
556template <int dim>
557double PolyhedronInclusion<dim>::Psi_I1_b_le_le(double a, double b, double le)
558{
559 double dis = sqrt(a * a + b * b + le * le);
560 if (a != 0 && b != 0 && le != 0) {
561 return (le / (3.0 * pow(b * b + le * le, 3.0) * dis)) * (
562 pow(a, 4.0) * (6.0 * b * b - 2.0 * le * le) + a * a * (3.0 * b * b - le * le) * (b * b + le * le)
563 + le * le * pow(b * b + le * le, 2.0) + 2.0 * (-3.0 * b * b + le * le) * dis * pow(abs(a), 3.0)
564 );
565 }
566 else if (a == 0) {
567 if (b != 0) {
568 return pow(le, 3.0) / (3.0 * dis * dis * dis);
569 }
570 else if (le != 0) {
571 return 0.0;
572 }
573 else {
574 return 0.0;
575 }
576 }
577 else if (a != 0) {
578 if (b != 0 && le == 0) {
579 return 0.0;
580 }
581 else if (b == 0 && le != 0) {
582 return (-2.0 * pow(a, 4.0) - pow(a * le, 2.0) + pow(le, 4.0) + 2.0 * dis * pow(abs(a), 3.0)) / (3.0 * dis * pow(le, 3.0));
583 }
584 else if (b == 0 && le == 0) {
585 return 0.0;
586 }
587 }
588
589 return 0.0;
590}
591
592template <int dim>
593double PolyhedronInclusion<dim>::Psi_I1_le_le_le(double a, double b, double le)
594{
595 double dis = sqrt(a * a + b * b + le * le);
596 if (a != 0 && b != 0 && le != 0) {
597 return (b / (3.0 * pow(b * b + le * le, 3.0) * dis)) * (
598 -2.0 * pow(a, 4.0) * (b * b - 3.0 * le * le) - a * a * (b * b - 3.0 * le * le) * (b * b + le * le)
599 + b * b * pow(b * b + le * le, 2.0) + 2.0 * (b * b - 3.0 * le * le) * dis * pow(abs(a), 3.0)
600 );
601 }
602 else if (a == 0) {
603 if (b != 0) {
604 return pow(b, 3.0) / (3.0 * dis * dis * dis);
605 }
606 else {
607 return 0.0;
608 }
609 }
610 else if (a != 0) {
611 if (b != 0 && le == 0) {
612 return (-2.0 * pow(a, 4.0) - pow(a * b, 2.0) + pow(b, 4.0) + 2.0 * dis * pow(abs(a), 3.0)) / (3.0 * dis * pow(b, 3.0));
613 }
614 else if (b == 0 && le != 0) {
615 return 0.0;
616 }
617 else if (b == 0 && le == 0) {
618 return 0.0;
619 }
620 }
621
622 return 0.0;
623}
624
625
626//template <int dim>
627//double PolyhedronInclusion<dim>::PSI_ijkl(int i, int j, int k, int l, double a, double b, double lm, double lp, const VectorDim& Svnorm, const VectorDim& Vnorm, const VectorDim& Vdir)
628//{
629// return (-(Psi_I1_a_a_a(a, b, lp) - Psi_I1_a_a_a(a, b, lm)) * Svnorm[i] * Svnorm[j] * Svnorm[k] - (Psi_I1_b_b_b(a, b, lp) - Psi_I1_b_b_b(a, b, lm)) * Vnorm[i] * Vnorm[j] * Vnorm[k]
630// - (Psi_I1_le_le_le(a, b, lp) - Psi_I1_le_le_le(a, b, lm)) * Vdir[i] * Vdir[j] * Vdir[k] - (Psi_I1_a_a_b(a, b, lp) - Psi_I1_a_a_b(a, b, lm)) * (Svnorm[i] * Svnorm[j] * Vnorm[k] + Svnorm[i] * Vnorm[j] * Svnorm[k] + Vnorm[i] * Svnorm[j] * Svnorm[k])
631// - (Psi_I1_a_a_le(a, b, lp) - Psi_I1_a_a_le(a, b, lm)) * (Svnorm[i] * Svnorm[j] * Vdir[k] + Svnorm[i] * Vdir[j] * Svnorm[k] + Vdir[i] * Svnorm[j] * Svnorm[k]) - (Psi_I1_a_b_b(a, b, lp) - Psi_I1_a_b_b(a, b, lm)) * (Svnorm[i] * Vnorm[j] * Vnorm[k] + Svnorm[j] * Vnorm[i] * Vnorm[k] + Svnorm[k] * Vnorm[j] * Vnorm[i])
632// - (Psi_I1_b_b_le(a, b, lp) - Psi_I1_b_b_le(a, b, lm)) * (Vdir[i] * Vnorm[j] * Vnorm[k] + Vdir[j] * Vnorm[i] * Vnorm[k] + Vdir[k] * Vnorm[i] * Vnorm[j]) - (Psi_I1_a_le_le(a, b, lp) - Psi_I1_a_le_le(a, b, lm)) * (Svnorm[i] * Vdir[j] * Vdir[k] + Svnorm[j] * Vdir[i] * Vdir[k] + Svnorm[k] * Vdir[i] * Vdir[j])
633// - (Psi_I1_b_le_le(a, b, lp) - Psi_I1_b_le_le(a, b, lm)) * (Vnorm[i] * Vdir[j] * Vdir[k] + Vnorm[j] * Vdir[i] * Vdir[k] + Vnorm[k] * Vdir[i] * Vdir[j])
634// - (Psi_I1_a_b_le(a, b, lp) - Psi_I1_a_b_le(a, b, lm)) * (Svnorm[i] * Vnorm[j] * Vdir[k] + Svnorm[i] * Vnorm[k] * Vdir[j] + Svnorm[j] * Vnorm[i] * Vdir[k] + Svnorm[k] * Vnorm[i] * Vdir[j] + Svnorm[j] * Vnorm[k] * Vdir[i] + Svnorm[k] * Vnorm[j] * Vdir[i])) * (-Svnorm[l]);
635//}
636
637
638//template <int dim>
639//double PolyhedronInclusion<dim>::PSI_ijkl(int i, int j, int k, int l, const VectorDim& x) const
640//{
641// double result=0.0;
642// for(const auto& face : faces)
643// {
644// const auto& P0(face.second[0].second);
645// const auto& P1(face.second[1].second);
646// const auto& P2(face.second[2].second);
647// const VectorDim Svnorm((P1-P0).cross(P2-P1).normalized());
648// const double a(Svnorm.dot(P0-x));
649// for(size_t e=0;e<face.second.size();++e)
650// {
651// const size_t e1(e<face.second.size()-1? e+1 : 0);
652// const VectorDim& vm(face.second[e].second);
653// const VectorDim& vp(face.second[e1].second);
654// const VectorDim Vdir((vp-vm).normalized());
655// const VectorDim Vnorm(Vdir.cross(Svnorm));
656// const double b((vp-x).dot(Vnorm));
657// const double lm((vm-x).dot(Vdir));
658// const double lp((vp-x).dot(Vdir));
659// result+=PSI_ijkl(i,j,k,l,a,b,lm,lp,Svnorm,Vnorm,Vdir);
660// }
661// }
662// return result;
663//}
664
665// template <int dim>
666// double PolyhedronInclusion<dim>::eshelbyTensorComponent(const int&i,const int&j,const int&k,const int&l,const VectorDim& x) const
667// {
668// auto delta_xy = [] (const int x, const int y) -> int {return x==y;};
675//
676// return 0.125/(std::numbers::pi*(1.0-this->nu))*(PSI_ijkl(i,j,k,l,x)
677// -2.0*this->nu*delta_xy(k,l)*PHI_ij(i,j,x)
678// -(1.0-this->nu)*(PHI_ij(i,l,x)*delta_xy(j,k)
679// +PHI_ij(j,k,x)*delta_xy(i,l)
680// +PHI_ij(j,l,x)*delta_xy(i,k)
681// +PHI_ij(i,k,x)*delta_xy(j,l)));
682// }
683
684template <int dim>
685double PolyhedronInclusion<dim>::eshelbyTensorComponent(const int&i,const int&j,const int&k,const int&l,const MatrixDim& PHI,const MatrixDim& delta, const Psi_I1& psi,const VectorDim& Svnorm,const VectorDim& Vnorm,const VectorDim& Vdir) const
686{
687
688 const double psi_val= (-psi.I1_a_a_a * Svnorm[i] * Svnorm[j] * Svnorm[k] - psi.I1_b_b_b * Vnorm[i] * Vnorm[j] * Vnorm[k]
689 - psi.I1_le_le_le * Vdir[i] * Vdir[j] * Vdir[k] - psi.I1_a_a_b * (Svnorm[i] * Svnorm[j] * Vnorm[k] + Svnorm[i] * Vnorm[j] * Svnorm[k] + Vnorm[i] * Svnorm[j] * Svnorm[k])
690 - psi.I1_a_a_le * (Svnorm[i] * Svnorm[j] * Vdir[k] + Svnorm[i] * Vdir[j] * Svnorm[k] + Vdir[i] * Svnorm[j] * Svnorm[k]) - psi.I1_a_b_b * (Svnorm[i] * Vnorm[j] * Vnorm[k] + Svnorm[j] * Vnorm[i] * Vnorm[k] + Svnorm[k] * Vnorm[j] * Vnorm[i])
691 - psi.I1_b_b_le * (Vdir[i] * Vnorm[j] * Vnorm[k] + Vdir[j] * Vnorm[i] * Vnorm[k] + Vdir[k] * Vnorm[i] * Vnorm[j]) - psi.I1_a_le_le * (Svnorm[i] * Vdir[j] * Vdir[k] + Svnorm[j] * Vdir[i] * Vdir[k] + Svnorm[k] * Vdir[i] * Vdir[j])
692 - psi.I1_b_le_le * (Vnorm[i] * Vdir[j] * Vdir[k] + Vnorm[j] * Vdir[i] * Vdir[k] + Vnorm[k] * Vdir[i] * Vdir[j])
693 - psi.I1_a_b_le * (Svnorm[i] * Vnorm[j] * Vdir[k] + Svnorm[i] * Vnorm[k] * Vdir[j] + Svnorm[j] * Vnorm[i] * Vdir[k] + Svnorm[k] * Vnorm[i] * Vdir[j] + Svnorm[j] * Vnorm[k] * Vdir[i] + Svnorm[k] * Vnorm[j] * Vdir[i])) * (-Svnorm[l]);
694
695 //return psi_val;
696 return 0.125/(std::numbers::pi*(1.0-this->nu))*(psi_val
697 -2.0*this->nu*delta(k,l)*PHI(i,j)
698 -(1.0-this->nu)*(PHI(i,l)*delta(j,k)
699 +PHI(j,k)*delta(i,l)
700 +PHI(j,l)*delta(i,k)
701 +PHI(i,k)*delta(j,l)));
702}
703
704 template <int dim>
705 typename PolyhedronInclusion<dim>::MatrixVoigtSize PolyhedronInclusion<dim>::eshelbyTensorVoigt(const VectorDim& x) const
706 {
707 Eigen::Matrix<double,voigtSize,voigtSize> temp(Eigen::Matrix<double,voigtSize,voigtSize>::Zero());
708 double psi_ijkl[3][3][3][3];
709 Psi_I1 psi;
710
711 for(const auto& face : faces)
712 {
713 const auto& P0(face.second[0].second);
714 const auto& P1(face.second[1].second);
715 const auto& P2(face.second[2].second);
716 const VectorDim Svnorm((P1-P0).cross(P2-P1).normalized());
717 //std::cout<<"x"<<x.transpose()<<std::endl;
718 //std::cout<<"P0"<<P0.transpose()<<std::endl;
719 //std::cout<<"P1"<<P1.transpose()<<std::endl;
720 //std::cout<<"P2"<<P2.transpose()<<std::endl;
721 const double a(Svnorm.dot(P0-x));
722 for(size_t e=0;e<face.second.size();++e)
723 {
724 const size_t e1(e<face.second.size()-1? e+1 : 0);
725 const VectorDim& vm(face.second[e].second);
726 const VectorDim& vp(face.second[e1].second);
727 const VectorDim Vdir((vp-vm).normalized());
728 const VectorDim Vnorm(Vdir.cross(Svnorm));
729 const double b((vp-x).dot(Vnorm));
730 const double lm((vm-x).dot(Vdir));
731 const double lp((vp-x).dot(Vdir));
732
733 psi.I1_a_a_a=Psi_I1_a_a_a(a, b, lp) - Psi_I1_a_a_a(a, b, lm);
734 psi.I1_b_b_b=Psi_I1_b_b_b(a, b, lp) - Psi_I1_b_b_b(a, b, lm);
735 psi.I1_le_le_le=Psi_I1_le_le_le(a, b, lp) - Psi_I1_le_le_le(a, b, lm);
736 psi.I1_a_a_b=Psi_I1_a_a_b(a, b, lp) - Psi_I1_a_a_b(a, b, lm);
737 psi.I1_a_a_le=Psi_I1_a_a_le(a, b, lp) - Psi_I1_a_a_le(a, b, lm);
738 psi.I1_a_b_b=Psi_I1_a_b_b(a, b, lp) - Psi_I1_a_b_b(a, b, lm);
739 psi.I1_b_b_le=Psi_I1_b_b_le(a, b, lp) - Psi_I1_b_b_le(a, b, lm);
740 psi.I1_a_le_le=Psi_I1_a_le_le(a, b, lp) - Psi_I1_a_le_le(a, b, lm);
741 psi.I1_b_le_le=Psi_I1_b_le_le(a, b, lp) - Psi_I1_b_le_le(a, b, lm);
742 psi.I1_a_b_le=Psi_I1_a_b_le(a, b, lp) - Psi_I1_a_b_le(a, b, lm);
743
744 //std::cout<<"psi.I1_a_a_a"<<psi.I1_a_a_a<<std::endl;
745 //std::cout<<"psi.I1_b_b_b"<<psi.I1_b_b_b<<std::endl;
746 //std::cout<<"psi.I1_le_le_le"<<psi.I1_le_le_le<<std::endl;
747 //std::cout<<"psi.I1_a_a_b"<<psi.I1_a_a_b<<std::endl;
748 //std::cout<<"psi.I1_a_a_le"<<psi.I1_a_a_le<<std::endl;
749 //std::cout<<"psi.I1_a_b_b"<<psi.I1_a_b_b<<std::endl;
750 //std::cout<<"psi.I1_b_b_le"<<psi.I1_b_b_le<<std::endl;
751 //std::cout<<"psi.I1_a_le_le"<<psi.I1_a_le_le<<std::endl;
752 //std::cout<<"psi.I1_b_le_le"<<psi.I1_b_le_le<<std::endl;
753 //std::cout<<"psi.I1_a_b_le"<<psi.I1_a_b_le<<std::endl;
754
755 const VectorDim PHI_j(-(Phi_u_II_a(a, b, lp) - Phi_u_II_a(a, b, lm))*Svnorm
756 -(Phi_u_II_b(a, b, lp) - Phi_u_II_b(a, b, lm))*Vnorm
757 -(Phi_u_II_le(a, b, lp))*Vdir + (Phi_u_II_le(a, b, lm))*Vdir);
758 //std::cout << "a = " << a << ", b = " << b << ", lp = " << lp << ", lm = " << lm << std::endl;
759 //std::cout<<"Phi_u_II_a(a, b, lp)"<<Phi_u_II_a(a, b, lp)<<std::endl;
760 //std::cout<<"Phi_u_II_a(a, b, lm)"<<Phi_u_II_a(a, b, lm)<<std::endl;
761 //std::cout<<"Phi_u_II_b(a, b, lp)"<<Phi_u_II_b(a, b, lp)<<std::endl;
762 //std::cout<<"Phi_u_II_b(a, b, lm)"<<Phi_u_II_b(a, b, lm)<<std::endl;
763 //std::cout<<"Phi_u_II_le(a, b, lp)"<<Phi_u_II_le(a, b, lp)<<std::endl;
764 //std::cout<<"Phi_u_II_le(a, b, lm)"<<Phi_u_II_le(a, b, lm)<<std::endl;
765
766 //std::cout<<"PHI_j"<<PHI_j<<std::endl;
767 const MatrixDim PHI(-Svnorm*PHI_j.transpose());
768 //std::cout<<"PHI"<<PHI<<std::endl;
769
770 for(int iV=0;iV<voigtTraits.voigtSize;++iV)
771 {
772 const size_t i(voigtTraits.tensorIndex(iV,0));
773 const size_t j(voigtTraits.tensorIndex(iV,1));
774
775 for(int jV=0;jV<voigtTraits.voigtSize;++jV)
776 {
777 const size_t k(voigtTraits.tensorIndex(jV,0));
778 const size_t l(voigtTraits.tensorIndex(jV,1));
779 temp(iV,jV)+=eshelbyTensorComponent(i,j,k,l,PHI,delta,psi,Svnorm,Vnorm,Vdir);
780
781 //psi_ijkl[i][j][k][l]+=eshelbyTensorComponent(i,j,k,l,PHI,delta,psi,Svnorm,Vnorm,Vdir);
782 }
783 }
784
785
786 }
787 }
788 for(int iV=0;iV<voigtTraits.voigtSize;++iV)
789 {
790 for(int jV=0;jV<voigtTraits.voigtSize;++jV)
791 { // Correct for Voigt to tensor correction
792 if (iV==jV && jV>=3)
793 temp(iV,jV)*=2.0;
794 }
795 }
796
797
798 //std::cout<<"x"<<x<<std::endl;
799 //Printing the values
800 //for ( int i = 0; i < 3; i++) {
801 //for ( int j = 0; j < 3; j++) {
802 //for (int k = 0; k < 3; k++) {
803 //for (int l = 0; l < 3; l++) {
804 //std::cout << "Value of eshelbyTensor[" << i << "][" << j << "][" << k << "][" << l
805 //<< "] :- " << psi_ijkl[i][j][k][l]<< std::endl;
806 //std::cout << "\n"<< std::endl;
807 //}
808 //}
809 //}
810 //}
811
812
813 // 11 22 33 12 23 13 -> 00 11 22 01 12 02
814
815
816 // 0000, 0011, 0022, 0001, 0012, 0002
817 // 1100, 1111, 1122, 1101, 1112, 1102
818
819
820// temp(voigtTraits.voigtIndex(0,0),voigtTraits.voigtIndex(0,0))=eshelbyTensorComponent(0,0,0,0,x);
821// temp(voigtTraits.voigtIndex(0,0),voigtTraits.voigtIndex(1,1))=eshelbyTensorComponent(0,0,1,1,x);
822// temp(voigtTraits.voigtIndex(0,0),voigtTraits.voigtIndex(2,2))=eshelbyTensorComponent(0,0,2,2,x);
823// temp(voigtTraits.voigtIndex(0,0),voigtTraits.voigtIndex(0,1))=eshelbyTensorComponent(0,0,0,1,x);
824// temp(voigtTraits.voigtIndex(0,0),voigtTraits.voigtIndex(1,2))=eshelbyTensorComponent(0,0,1,2,x);
825// temp(voigtTraits.voigtIndex(0,0),voigtTraits.voigtIndex(2,0))=eshelbyTensorComponent(0,0,2,0,x);
826//
827// temp(voigtTraits.voigtIndex(1,1),voigtTraits.voigtIndex(0,0))=eshelbyTensorComponent(1,1,0,0,x);
828// temp(voigtTraits.voigtIndex(1,1),voigtTraits.voigtIndex(1,1))=eshelbyTensorComponent(1,1,1,1,x);
829// temp(voigtTraits.voigtIndex(1,1),voigtTraits.voigtIndex(2,2))=eshelbyTensorComponent(1,1,2,2,x);
830// temp(voigtTraits.voigtIndex(1,1),voigtTraits.voigtIndex(1,2))=eshelbyTensorComponent(1,1,1,2,x);
831// temp(voigtTraits.voigtIndex(1,1),voigtTraits.voigtIndex(2,0))=eshelbyTensorComponent(1,1,2,0,x);
832// temp(voigtTraits.voigtIndex(1,1),voigtTraits.voigtIndex(0,1))=eshelbyTensorComponent(1,1,0,1,x);
833//
834// temp(voigtTraits.voigtIndex(2,2),voigtTraits.voigtIndex(0,0))=eshelbyTensorComponent(2,2,0,0,x);
835// temp(voigtTraits.voigtIndex(2,2),voigtTraits.voigtIndex(1,1))=eshelbyTensorComponent(2,2,1,1,x);
836// temp(voigtTraits.voigtIndex(2,2),voigtTraits.voigtIndex(2,2))=eshelbyTensorComponent(2,2,2,2,x);
837// temp(voigtTraits.voigtIndex(2,2),voigtTraits.voigtIndex(1,2))=eshelbyTensorComponent(2,2,1,2,x);
838// temp(voigtTraits.voigtIndex(2,2),voigtTraits.voigtIndex(2,0))=eshelbyTensorComponent(2,2,2,0,x);
839// temp(voigtTraits.voigtIndex(2,2),voigtTraits.voigtIndex(0,1))=eshelbyTensorComponent(2,2,0,1,x);
840//
841// temp(voigtTraits.voigtIndex(0,1),voigtTraits.voigtIndex(0,1))=2.0*eshelbyTensorComponent(0,1,0,1,x);
842// temp(voigtTraits.voigtIndex(0,1),voigtTraits.voigtIndex(0,0))=2.0*eshelbyTensorComponent(0,1,0,0,x);
843// temp(voigtTraits.voigtIndex(0,1),voigtTraits.voigtIndex(1,1))=2.0*eshelbyTensorComponent(0,1,1,1,x);
844// temp(voigtTraits.voigtIndex(0,1),voigtTraits.voigtIndex(2,2))=2.0*eshelbyTensorComponent(0,1,2,2,x);
845// temp(voigtTraits.voigtIndex(0,1),voigtTraits.voigtIndex(1,2))=2.0*eshelbyTensorComponent(0,1,1,2,x);
846// temp(voigtTraits.voigtIndex(0,1),voigtTraits.voigtIndex(2,0))=2.0*eshelbyTensorComponent(0,1,2,0,x);
847//
848// temp(voigtTraits.voigtIndex(2,0),voigtTraits.voigtIndex(2,0))=2.0*eshelbyTensorComponent(2,0,2,0,x);
849// temp(voigtTraits.voigtIndex(2,0),voigtTraits.voigtIndex(0,0))=2.0*eshelbyTensorComponent(2,0,0,0,x);
850// temp(voigtTraits.voigtIndex(2,0),voigtTraits.voigtIndex(1,1))=2.0*eshelbyTensorComponent(2,0,1,1,x);
851// temp(voigtTraits.voigtIndex(2,0),voigtTraits.voigtIndex(2,2))=2.0*eshelbyTensorComponent(2,0,2,2,x);
852// temp(voigtTraits.voigtIndex(2,0),voigtTraits.voigtIndex(1,2))=2.0*eshelbyTensorComponent(2,0,1,2,x);
853// temp(voigtTraits.voigtIndex(2,0),voigtTraits.voigtIndex(0,1))=2.0*eshelbyTensorComponent(2,0,0,1,x);
854//
855// temp(voigtTraits.voigtIndex(1,2),voigtTraits.voigtIndex(1,2))=2.0*eshelbyTensorComponent(1,2,1,2,x);
856// temp(voigtTraits.voigtIndex(1,2),voigtTraits.voigtIndex(0,0))=2.0*eshelbyTensorComponent(1,2,0,0,x);
857// temp(voigtTraits.voigtIndex(1,2),voigtTraits.voigtIndex(1,1))=2.0*eshelbyTensorComponent(1,2,1,1,x);
858// temp(voigtTraits.voigtIndex(1,2),voigtTraits.voigtIndex(2,2))=2.0*eshelbyTensorComponent(1,2,2,2,x);
859// temp(voigtTraits.voigtIndex(1,2),voigtTraits.voigtIndex(2,0))=2.0*eshelbyTensorComponent(1,2,2,0,x);
860// temp(voigtTraits.voigtIndex(1,2),voigtTraits.voigtIndex(0,1))=2.0*eshelbyTensorComponent(1,2,0,1,x);
861
862
863 return temp;
864 }
865
866
867 template <int dim>
868 typename PolyhedronInclusion<dim>::MatrixDim PolyhedronInclusion<dim>::strain(const VectorDim& x) const
869 {
870 return this->eTNorm>FLT_EPSILON? voigtTraits.v2m(eshelbyTensorVoigt(x)*voigtTraits.m2v(this->eT,true),true) : MatrixDim::Zero();
871 //std::cout<<"eshelbyTensor"<<eshelbyTensorVoigt(x)<<std::endl;
872 }
873
874 template <int dim>
875 typename PolyhedronInclusion<dim>::MatrixDim PolyhedronInclusion<dim>::elasticStrain(const VectorDim& x) const
876 {
877 if(contains(x))
878 {
879 return strain(x)-this->eT;
880 }
881 else
882 {
883 return strain(x);
884 }
885 }
886
887 template <int dim>
888 typename PolyhedronInclusion<dim>::MatrixDim PolyhedronInclusion<dim>::stress(const VectorDim& x) const
889 {
890 if(this->masterID>=0)
891 {
892 return MatrixDim::Zero();
893 }
894 const MatrixDim elStrain(elasticStrain(x));
895 return this->lambda*elStrain.trace()*MatrixDim::Identity()+2.0*this->mu*elStrain;
896 }
897
898 template <int dim>
900 //const typename PolyhedronInclusion<dim>::VoigtSizeMatrixType PolyhedronInclusion<dim>::voigtOrder=(PolyhedronInclusion<dim>::VoigtSizeMatrixType()<<0,0,0,1,0,2,1,1,1,2,2,2).finished();
901
902 template class PolyhedronInclusion<3>;
903
904}
905#endif
EshelbyInclusionBase(const MatrixDim &_eT, const double &_nu, const double &_mu, const double &_mobilityReduction, const int &_phaseID, const std::shared_ptr< SecondPhase< dim > > &sph)
MatrixDim stress(const VectorDim &x) const override
const std::map< size_t, std::vector< std::pair< size_t, VectorDim > > > faces
const std::map< size_t, PolyhedronInclusionNodeIO< dim > > & nodes
static double Psi_I1_a_a_b(double a, double b, double le)
static double Psi_I1_b_le_le(double a, double b, double le)
static double Psi_I1_b_b_le(double a, double b, double le)
static std::map< size_t, std::vector< std::pair< size_t, VectorDim > > > getFaces(const std::map< size_t, PolyhedronInclusionNodeIO< dim > > &nodesMap, const std::map< size_t, std::vector< size_t > > &faceIDs)
static double Psi_I1_a_b_b(double a, double b, double le)
static double Phi_u_II_le(double a, double b, double le)
static const SymmetricVoigtTraits< dim > voigtTraits
const std::map< size_t, Plane< dim > > & planes() const
static double Phi_u_II_a(double a, double b, double le)
static double Psi_I1_b_b_b(double a, double b, double le)
static double Psi_I1_a_a_a(double a, double b, double le)
PolyhedronInclusion(const std::map< size_t, PolyhedronInclusionNodeIO< dim > > &nodesMap, const std::map< size_t, std::vector< size_t > > &faceIDs, const MatrixDim &_eT, const double &_nu, const double &_mu, const double &_mobilityReduction, const int &_phaseID, const std::shared_ptr< SecondPhase< dim > > &sph)
static double Psi_I1_a_le_le(double a, double b, double le)
static double Psi_I1_a_b_le(double a, double b, double le)
MatrixVoigtSize eshelbyTensorVoigt(const VectorDim &x) const
double eshelbyTensorComponent(const int &i, const int &j, const int &k, const int &l, const MatrixDim &PHI, const MatrixDim &delta, const Psi_I1 &psi, const VectorDim &Svnorm, const VectorDim &Vnorm, const VectorDim &Vdir) const
static double Psi_I1_a_a_le(double a, double b, double le)
static double Psi_I1_le_le_le(double a, double b, double le)
static double Phi_u_II_b(double a, double b, double le)
a
Definition int_R.m:14
b
Definition int_R.m:16
x
Definition int_R.m:12
const SymmetricVoigtTraits< dim > PolyhedronInclusion< dim >::voigtTraits
Eigen::Matrix< double, 3, 1 > VectorDim
Definition pyMoDELib.cxx:66
Eigen::Matrix< size_t, voigtSize, 2 > VoigtSizeMatrixType
Definition VoigtTraits.h:22
const double mu
const double nu
int j
int k
int i
int e
vertex temp