v0.16.0
Loading...
Searching...
No Matches
PlasticOpsGeneric.hpp
Go to the documentation of this file.
1
2
3/** \file PlasticOpsGeneric.hpp
4 * \example mofem/tutorials/adv-0_plasticity/src/PlasticOpsGeneric.hpp
5 */
6
7namespace PlasticOps {
8
9//! [Lambda functions]
10template <int DIM> inline auto diff_tensor(FTensor::Number<DIM>) {
11 FTensor::Index<'i', DIM> i;
12 FTensor::Index<'j', DIM> j;
13 FTensor::Index<'k', DIM> k;
14 FTensor::Index<'l', DIM> l;
17 t_diff(i, j, k, l) = (t_kd(i, k) ^ t_kd(j, l)) / 4.;
18 return t_diff;
19};
20
21template <int DIM> inline auto symm_L_tensor(FTensor::Number<DIM>) {
22 FTensor::Index<'i', DIM> i;
23 FTensor::Index<'j', DIM> j;
24 constexpr auto size_symm = (DIM * (DIM + 1)) / 2;
27 t_L(i, j, L) = 0;
28 if constexpr (DIM == 2) {
29 t_L(0, 0, 0) = 1;
30 t_L(1, 0, 1) = 1;
31 t_L(1, 1, 2) = 1;
32 } else {
33 t_L(0, 0, 0) = 1;
34 t_L(1, 0, 1) = 1;
35 t_L(2, 0, 2) = 1;
36 t_L(1, 1, 3) = 1;
37 t_L(2, 1, 4) = 1;
38 t_L(2, 2, 5) = 1;
39 }
40 return t_L;
41}
42
43template <int DIM> inline auto diff_symmetrize(FTensor::Number<DIM>) {
44
45 FTensor::Index<'i', DIM> i;
46 FTensor::Index<'j', DIM> j;
47 FTensor::Index<'k', DIM> k;
48 FTensor::Index<'l', DIM> l;
49
51
52 t_diff(i, j, k, l) = 0;
53 t_diff(0, 0, 0, 0) = 1;
54 t_diff(1, 1, 1, 1) = 1;
55
56 t_diff(1, 0, 1, 0) = 0.5;
57 t_diff(1, 0, 0, 1) = 0.5;
58
59 t_diff(0, 1, 0, 1) = 0.5;
60 t_diff(0, 1, 1, 0) = 0.5;
61
62 if constexpr (DIM == 3) {
63 t_diff(2, 2, 2, 2) = 1;
64
65 t_diff(2, 0, 2, 0) = 0.5;
66 t_diff(2, 0, 0, 2) = 0.5;
67 t_diff(0, 2, 0, 2) = 0.5;
68 t_diff(0, 2, 2, 0) = 0.5;
69
70 t_diff(2, 1, 2, 1) = 0.5;
71 t_diff(2, 1, 1, 2) = 0.5;
72 t_diff(1, 2, 1, 2) = 0.5;
73 t_diff(1, 2, 2, 1) = 0.5;
74 }
75
76 return t_diff;
77};
78
79template <typename T>
80inline double trace(FTensor::Tensor2_symmetric<T, 2> &t_stress) {
81 constexpr double third = boost::math::constants::third<double>();
82 return (t_stress(0, 0) + t_stress(1, 1)) * third;
83};
84
85template <typename T>
86inline double trace(FTensor::Tensor2_symmetric<T, 3> &t_stress) {
87 constexpr double third = boost::math::constants::third<double>();
88 return (t_stress(0, 0) + t_stress(1, 1) + t_stress(2, 2)) * third;
89};
90
91template <typename T, int DIM>
92inline auto deviator(
93
96
97) {
99 t_dev(I, J) = 0;
100 for (int ii = 0; ii != DIM; ++ii)
101 for (int jj = ii; jj != DIM; ++jj)
102 t_dev(ii, jj) = t_stress(ii, jj);
103 t_dev(0, 0) -= trace;
104 t_dev(1, 1) -= trace;
105 t_dev(2, 2) -= trace;
106 for (int ii = 0; ii != DIM; ++ii)
107 for (int jj = ii; jj != DIM; ++jj)
108 t_dev(ii, jj) -= t_alpha(ii, jj);
109 return t_dev;
110};
111
112template <typename T>
113inline auto deviator(FTensor::Tensor2_symmetric<T, 2> &t_stress, double trace,
115 return deviator(t_stress, trace, t_alpha, FTensor::Number<2>());
116};
117
118template <typename T>
119inline auto deviator(FTensor::Tensor2_symmetric<T, 3> &t_stress, double trace,
121 return deviator(t_stress, trace, t_alpha, FTensor::Number<3>());
122};
123
124template <int DIM>
127 FTensor::Index<'k', DIM> k;
128 FTensor::Index<'l', DIM> l;
129 FTensor::Ddg<double, 3, DIM> t_diff_deviator;
130 t_diff_deviator(I, J, k, l) = 0;
131 for (int ii = 0; ii != DIM; ++ii)
132 for (int jj = ii; jj != DIM; ++jj)
133 for (int kk = 0; kk != DIM; ++kk)
134 for (int ll = kk; ll != DIM; ++ll)
135 t_diff_deviator(ii, jj, kk, ll) = t_diff_stress(ii, jj, kk, ll);
136
137 constexpr double third = boost::math::constants::third<double>();
138
139 t_diff_deviator(0, 0, 0, 0) -= third;
140 t_diff_deviator(0, 0, 1, 1) -= third;
141
142 t_diff_deviator(1, 1, 0, 0) -= third;
143 t_diff_deviator(1, 1, 1, 1) -= third;
144
145 t_diff_deviator(2, 2, 0, 0) -= third;
146 t_diff_deviator(2, 2, 1, 1) -= third;
147
148 if constexpr (DIM == 3) {
149 t_diff_deviator(0, 0, 2, 2) -= third;
150 t_diff_deviator(1, 1, 2, 2) -= third;
151 t_diff_deviator(2, 2, 2, 2) -= third;
152 }
153
154 return t_diff_deviator;
155};
156
157inline auto diff_deviator(FTensor::Ddg<double, 2, 2> &&t_diff_stress) {
158 return diff_deviator(std::move(t_diff_stress), FTensor::Number<2>());
159}
160
161inline auto diff_deviator(FTensor::Ddg<double, 3, 3> &&t_diff_stress) {
162 return diff_deviator(std::move(t_diff_stress), FTensor::Number<3>());
163}
164
165/**
166 *
167
168\f[
169\begin{split}
170f&=\sqrt{s_{ij}s_{ij}}\\
171A_{ij}&=\frac{\partial f}{\partial \sigma_{ij}}=
172\frac{1}{f} s_{kl} \frac{\partial s_{kl}}{\partial \sigma_{ij}}\\
173\frac{\partial A_{ij}}{\partial \sigma_{kl}}&= \frac{\partial^2 f}{\partial
174\sigma_{ij}\partial\sigma_{mn}}= \frac{1}{f} \left( \frac{\partial
175s_{kl}}{\partial \sigma_{mn}}\frac{\partial s_{kl}}{\partial \sigma_{ij}}
176-A_{mn}A_{ij}
177\right)\\
178\frac{\partial f}{\partial \varepsilon_{ij}}&=A_{mn}D_{mnij}
179\\
180\frac{\partial A_{ij}}{\partial \varepsilon_{kl}}&=
181\frac{\partial A_{ij}}{\partial \sigma_{mn}} \frac{\partial
182\sigma_{mn}}{\partial \varepsilon_{kl}}= \frac{\partial A_{ij}}{\partial
183\sigma_{mn}} D_{mnkl}
184\end{split}
185\f]
186
187 */
188inline double
190 return std::sqrt(1.5 * t_stress_deviator(I, J) * t_stress_deviator(I, J)) +
191 std::numeric_limits<double>::epsilon();
192};
193
194template <int DIM>
195inline auto plastic_flow(long double f,
197 FTensor::Ddg<double, 3, DIM> &&t_diff_deviator) {
198 FTensor::Index<'k', DIM> k;
199 FTensor::Index<'l', DIM> l;
201 t_diff_f(k, l) =
202 (1.5 * (t_dev_stress(I, J) * t_diff_deviator(I, J, k, l))) / f;
203 return t_diff_f;
204};
205
206template <typename T, int DIM>
207inline auto
210 FTensor::Ddg<double, 3, DIM> &&t_diff_deviator) {
211 FTensor::Index<'i', DIM> i;
212 FTensor::Index<'j', DIM> j;
213 FTensor::Index<'k', DIM> k;
214 FTensor::Index<'l', DIM> l;
216 t_diff_flow(i, j, k, l) =
217 (1.5 * (t_diff_deviator(M, N, i, j) * t_diff_deviator(M, N, k, l) -
218 (2. / 3.) * t_flow(i, j) * t_flow(k, l))) /
219 f;
220 return t_diff_flow;
221};
222
223template <typename T, int DIM>
226 FTensor::Ddg<double, DIM, DIM> &&t_diff_plastic_flow_dstress) {
227 FTensor::Index<'i', DIM> i;
228 FTensor::Index<'j', DIM> j;
229 FTensor::Index<'k', DIM> k;
230 FTensor::Index<'l', DIM> l;
231 FTensor::Index<'m', DIM> m;
232 FTensor::Index<'n', DIM> n;
234 t_diff_flow(i, j, k, l) =
235 t_diff_plastic_flow_dstress(i, j, m, n) * t_D(m, n, k, l);
236 return t_diff_flow;
237};
238
239// inline double constrain_diff_sign(double x) {
240// const auto y = x / zeta;
241// if (y > std::numeric_limits<float>::max_exponent10 ||
242// y < std::numeric_limits<float>::min_exponent10) {
243// return 0;
244// } else {
245// const auto e = std::exp(y);
246// const auto ep1 = e + 1;
247// return (2 / zeta) * (e / (ep1 * ep1));
248// }
249// };
250
251inline double constrian_sign(double x, double dt) {
252 const auto y = x / (zeta / dt);
253 if (y > std::numeric_limits<float>::max_exponent10 ||
254 y < std::numeric_limits<float>::min_exponent10) {
255 if (x > 0)
256 return 1.;
257 else
258 return -1.;
259 } else {
260 const auto e = std::exp(y);
261 return (e - 1) / (1 + e);
262 }
263};
264
265inline double constrain_abs(double x, double dt) {
266 const auto y = -x / (zeta / dt);
267 if (y > std::numeric_limits<float>::max_exponent10 ||
268 y < std::numeric_limits<float>::min_exponent10) {
269 return std::abs(x);
270 } else {
271 const double e = std::exp(y);
272 return x + 2 * (zeta / dt) * std::log1p(e);
273 }
274};
275
276inline double w(double eqiv, double dot_tau, double f, double sigma_y,
277 double sigma_Y) {
278 return (1. / cn1) * ((f - sigma_y) / sigma_Y) + dot_tau;
279};
280
281/**
282
283\f[
284v^H \cdot \dot{\tau} +
285\left(\frac{\sigma_Y}{2}\right) \cdot
286\left(
287 \left(
288 c_{\textrm{n0}} \cdot c_{\textrm{n1}} \cdot \left(\dot{\tau} - \dot{e_{\textrm{p}}}\right)
289 \right) +
290 \left(
291 c_{\textrm{n1}} \cdot \left(\dot{\tau} - \frac{1}{c_{\textrm{n1}}} \cdot \frac{f - \sigma_y}{\sigma_Y} - \text{abs\_w}\right)
292 \right)
293\right)
294\f]
295 */
296inline double constraint(double eqiv, double dot_tau, double f, double sigma_y,
297 double abs_w, double vis_H, double sigma_Y) {
298
299 return
300
301 vis_H * dot_tau +
302 (sigma_Y / 2) *
303 (
304
305 (cn0 * cn1 * ((dot_tau - eqiv)) +
306
307 cn1 * ((dot_tau) - (1. / cn1) * (f - sigma_y) / sigma_Y - abs_w))
308
309 );
310};
311
312inline double diff_constrain_ddot_tau(double sign, double eqiv, double dot_tau,
313 double vis_H, double sigma_Y) {
314 return vis_H + (sigma_Y / 2) * (cn0 * cn1 + cn1 * (1 - sign));
315};
316
317inline double diff_constrain_deqiv(double sign, double eqiv, double dot_tau,
318 double sigma_Y) {
319 return (sigma_Y / 2) * (-cn0 * cn1);
320};
321
322inline auto diff_constrain_df(double sign) { return (-1 - sign) / 2; };
323
324inline auto diff_constrain_dsigma_y(double sign) { return (1 + sign) / 2; }
325
326template <typename T, int DIM>
327inline auto
329 FTensor::Tensor2_symmetric<T, DIM> &t_plastic_flow) {
330 FTensor::Index<'i', DIM> i;
331 FTensor::Index<'j', DIM> j;
332 FTensor::Tensor2_symmetric<double, DIM> t_diff_constrain_dstress;
333 t_diff_constrain_dstress(i, j) = diff_constrain_df * t_plastic_flow(i, j);
334 return t_diff_constrain_dstress;
335};
336
337template <typename T1, typename T2, int DIM>
338inline auto diff_constrain_dstrain(T1 &t_D, T2 &&t_diff_constrain_dstress) {
339 FTensor::Index<'i', DIM> i;
340 FTensor::Index<'j', DIM> j;
341 FTensor::Index<'k', DIM> k;
342 FTensor::Index<'l', DIM> l;
343 FTensor::Tensor2_symmetric<double, DIM> t_diff_constrain_dstrain;
344 t_diff_constrain_dstrain(k, l) =
345 t_diff_constrain_dstress(i, j) * t_D(i, j, k, l);
346 return t_diff_constrain_dstrain;
347};
348
349template <typename T, int DIM>
351 FTensor::Tensor2_symmetric<T, DIM> &t_plastic_strain_dot) {
352 FTensor::Index<'i', DIM> i;
353 FTensor::Index<'j', DIM> j;
354 constexpr double A = 2. / 3;
355 return std::sqrt(A * t_plastic_strain_dot(i, j) *
356 t_plastic_strain_dot(i, j)) +
357 std::numeric_limits<double>::epsilon();
358};
359
360template <typename T1, typename T2, typename T3, int DIM>
361inline auto diff_equivalent_strain_dot(const T1 eqiv, T2 &t_plastic_strain_dot,
362 T3 &t_diff_plastic_strain,
364 FTensor::Index<'i', DIM> i;
365 FTensor::Index<'j', DIM> j;
366 FTensor::Index<'k', DIM> k;
367 FTensor::Index<'l', DIM> l;
368 constexpr double A = 2. / 3;
370 t_diff_eqiv(i, j) = A * (t_plastic_strain_dot(k, l) / eqiv) *
371 t_diff_plastic_strain(k, l, i, j);
372 return t_diff_eqiv;
373};
374
375//! [Lambda functions]
376
377//! [Auxiliary functions functions
378static inline auto get_mat_tensor_sym_dvector(size_t rr, MatrixDouble &mat,
381 &mat(3 * rr + 0, 0), &mat(3 * rr + 0, 1), &mat(3 * rr + 1, 0),
382 &mat(3 * rr + 1, 1), &mat(3 * rr + 2, 0), &mat(3 * rr + 2, 1)};
383}
384
385static inline auto get_mat_tensor_sym_dvector(size_t rr, MatrixDouble &mat,
388 &mat(6 * rr + 0, 0), &mat(6 * rr + 0, 1), &mat(6 * rr + 0, 2),
389 &mat(6 * rr + 1, 0), &mat(6 * rr + 1, 1), &mat(6 * rr + 1, 2),
390 &mat(6 * rr + 2, 0), &mat(6 * rr + 2, 1), &mat(6 * rr + 2, 2),
391 &mat(6 * rr + 3, 0), &mat(6 * rr + 3, 1), &mat(6 * rr + 3, 2),
392 &mat(6 * rr + 4, 0), &mat(6 * rr + 4, 1), &mat(6 * rr + 4, 2),
393 &mat(6 * rr + 5, 0), &mat(6 * rr + 5, 1), &mat(6 * rr + 5, 2)};
394}
395
396//! [Auxiliary functions functions
397
398template <int DIM, typename DomainEleOp>
400 : public DomainEleOp {
402 boost::shared_ptr<CommonData> common_data_ptr);
403 MoFEMErrorCode doWork(int side, EntityType type, EntData &data);
404
405protected:
406 boost::shared_ptr<CommonData> commonDataPtr;
407};
408
409template <int DIM, typename DomainEleOp>
412 boost::shared_ptr<CommonData> common_data_ptr)
414 commonDataPtr(common_data_ptr) {
415 // Operator is only executed for vertices
416 std::fill(&DomainEleOp::doEntities[MBEDGE],
417 &DomainEleOp::doEntities[MBMAXTYPE], false);
418}
419
420template <int DIM, typename DomainEleOp>
422 int side, EntityType type, EntData &data) {
424
425 FTensor::Index<'i', DIM> i;
426 FTensor::Index<'j', DIM> j;
427
428 const size_t nb_gauss_pts = commonDataPtr->mStressPtr->size1();
429 auto t_stress = getFTensor2SymmetricFromMat<DIM>(*(commonDataPtr->mStressPtr));
430 auto t_plastic_strain =
431 getFTensor2SymmetricFromMat<DIM>(commonDataPtr->plasticStrain);
432
433 commonDataPtr->plasticSurface.resize(nb_gauss_pts, false);
434 commonDataPtr->plasticFlow.resize(nb_gauss_pts, size_symm, false);
435 auto t_flow = getFTensor2SymmetricFromMat<DIM>(commonDataPtr->plasticFlow);
436
437 auto &params = commonDataPtr->blockParams;
438
439 for (auto &f : commonDataPtr->plasticSurface) {
440
441 f = platsic_surface(
442
443 deviator(
444 t_stress, trace(t_stress),
445 kinematic_hardening(t_plastic_strain, params[CommonData::C1_k]))
446
447 );
448
449 auto t_flow_tmp =
450 plastic_flow(f,
451
452 deviator(t_stress, trace(t_stress),
453 kinematic_hardening(t_plastic_strain,
454 params[CommonData::C1_k])),
455
457 t_flow(i, j) = t_flow_tmp(i, j);
458
459 ++t_plastic_strain;
460 ++t_flow;
461 ++t_stress;
462 }
463
465}
466
467template <int DIM, typename DomainEleOp>
469 OpCalculatePlasticityImpl(const std::string field_name,
470 boost::shared_ptr<CommonData> common_data_ptr,
471 boost::shared_ptr<MatrixDouble> m_D_ptr);
472 MoFEMErrorCode doWork(int side, EntityType type, EntData &data);
473
474protected:
475 boost::shared_ptr<CommonData> commonDataPtr;
476 boost::shared_ptr<MatrixDouble> mDPtr;
477};
478
479template <int DIM, typename DomainEleOp>
481 const std::string field_name, boost::shared_ptr<CommonData> common_data_ptr,
482 boost::shared_ptr<MatrixDouble> m_D_ptr)
484 commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {
485 // Opetor is only executed for vertices
486 std::fill(&DomainEleOp::doEntities[MBEDGE],
487 &DomainEleOp::doEntities[MBMAXTYPE], false);
488}
489
490template <int DIM, typename DomainEleOp>
492 int side, EntityType type, EntData &data) {
494
495 FTensor::Index<'i', DIM> i;
496 FTensor::Index<'j', DIM> j;
497 FTensor::Index<'k', DIM> k;
498 FTensor::Index<'l', DIM> l;
499 FTensor::Index<'m', DIM> m;
500 FTensor::Index<'n', DIM> n;
501
502 auto &params = commonDataPtr->blockParams; ///< material parameters
503
504 auto nb_gauss_pts = DomainEleOp::getGaussPts().size2();
505 auto t_w = DomainEleOp::getFTensor0IntegrationWeight();
506 auto t_tau = getFTensor0FromVec(commonDataPtr->plasticTau);
507 auto t_tau_dot = getFTensor0FromVec(commonDataPtr->plasticTauDot);
508 auto t_f = getFTensor0FromVec(commonDataPtr->plasticSurface);
509 auto t_flow = getFTensor2SymmetricFromMat<DIM>(commonDataPtr->plasticFlow);
510 auto t_plastic_strain =
511 getFTensor2SymmetricFromMat<DIM>(commonDataPtr->plasticStrain);
512 auto t_plastic_strain_dot =
513 getFTensor2SymmetricFromMat<DIM>(commonDataPtr->plasticStrainDot);
514 auto t_stress = getFTensor2SymmetricFromMat<DIM>(*(commonDataPtr->mStressPtr));
515
516 auto t_D_Op = getFTensor4DdgFromMat<DIM, DIM, 0>(*mDPtr);
517
518 auto t_diff_plastic_strain = diff_tensor(FTensor::Number<DIM>());
519 auto t_diff_deviator = diff_deviator(diff_tensor(FTensor::Number<DIM>()));
520
521 FTensor::Ddg<double, DIM, DIM> t_flow_dir_dstress;
522 FTensor::Ddg<double, DIM, DIM> t_flow_dir_dstrain;
523 t_flow_dir_dstress(i, j, k, l) =
524 1.5 * (t_diff_deviator(M, N, i, j) * t_diff_deviator(M, N, k, l));
525 t_flow_dir_dstrain(i, j, k, l) =
526 t_flow_dir_dstress(i, j, m, n) * t_D_Op(m, n, k, l);
527
528
529 auto t_alpha_dir =
530 kinematic_hardening_dplastic_strain<DIM>(params[CommonData::C1_k]);
531
532 commonDataPtr->resC.resize(nb_gauss_pts, false);
533 commonDataPtr->resCdTau.resize(nb_gauss_pts, false);
534 commonDataPtr->resCdStrain.resize(nb_gauss_pts, size_symm, false);
535 commonDataPtr->resCdPlasticStrain.resize(nb_gauss_pts, size_symm, false);
536 commonDataPtr->resFlow.resize(nb_gauss_pts, size_symm, false);
537 commonDataPtr->resFlowDtau.resize(nb_gauss_pts, size_symm, false);
538 commonDataPtr->resFlowDstrain.resize(nb_gauss_pts, size_symm * size_symm,
539 false);
540 commonDataPtr->resFlowDstrainDot.resize(nb_gauss_pts, size_symm * size_symm,
541 false);
542
543 commonDataPtr->resC.clear();
544 commonDataPtr->resCdTau.clear();
545 commonDataPtr->resCdStrain.clear();
546 commonDataPtr->resCdPlasticStrain.clear();
547 commonDataPtr->resFlow.clear();
548 commonDataPtr->resFlowDtau.clear();
549 commonDataPtr->resFlowDstrain.clear();
550 commonDataPtr->resFlowDstrainDot.clear();
551
552 auto t_res_c = getFTensor0FromVec(commonDataPtr->resC);
553 auto t_res_c_dtau = getFTensor0FromVec(commonDataPtr->resCdTau);
554 auto t_res_c_dstrain =
555 getFTensor2SymmetricFromMat<DIM>(commonDataPtr->resCdStrain);
556 auto t_res_c_plastic_strain =
557 getFTensor2SymmetricFromMat<DIM>(commonDataPtr->resCdPlasticStrain);
558 auto t_res_flow = getFTensor2SymmetricFromMat<DIM>(commonDataPtr->resFlow);
559 auto t_res_flow_dtau =
560 getFTensor2SymmetricFromMat<DIM>(commonDataPtr->resFlowDtau);
561 auto t_res_flow_dstrain =
562 getFTensor4DdgFromMat<DIM, DIM>(commonDataPtr->resFlowDstrain);
563 auto t_res_flow_dplastic_strain =
564 getFTensor4DdgFromMat<DIM, DIM>(commonDataPtr->resFlowDstrainDot);
565
566 auto next = [&]() {
567 ++t_tau;
568 ++t_tau_dot;
569 ++t_f;
570 ++t_flow;
571 ++t_plastic_strain;
572 ++t_plastic_strain_dot;
573 ++t_stress;
574 ++t_res_c;
575 ++t_res_c_dtau;
576 ++t_res_c_dstrain;
577 ++t_res_c_plastic_strain;
578 ++t_res_flow;
579 ++t_res_flow_dtau;
580 ++t_res_flow_dstrain;
581 ++t_res_flow_dplastic_strain;
582 ++t_w;
583 };
584
585 auto get_avtive_pts = [&]() {
586 int nb_points_avtive_on_elem = 0;
587 int nb_points_on_elem = 0;
588
589 auto t_tau = getFTensor0FromVec(commonDataPtr->plasticTau);
590 auto t_tau_dot = getFTensor0FromVec(commonDataPtr->plasticTauDot);
591 auto t_f = getFTensor0FromVec(commonDataPtr->plasticSurface);
592 auto t_plastic_strain_dot =
593 getFTensor2SymmetricFromMat<SPACE_DIM>(commonDataPtr->plasticStrainDot);
594
595 auto dt = this->getTStimeStep();
596
597 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
598 auto eqiv = equivalent_strain_dot(t_plastic_strain_dot);
599 const auto ww = w(
600 eqiv, t_tau_dot, t_f,
601 iso_hardening(t_tau, params[CommonData::H], params[CommonData::QINF],
602 params[CommonData::BISO], params[CommonData::SIGMA_Y]),
603 params[CommonData::SIGMA_Y]);
604 const auto sign_ww = constrian_sign(ww, dt);
605
606 ++nb_points_on_elem;
607 if (sign_ww > 0) {
608 ++nb_points_avtive_on_elem;
609 }
610
611 ++t_tau;
612 ++t_tau_dot;
613 ++t_f;
614 ++t_plastic_strain_dot;
615 }
616
617 int &active_points = PlasticOps::CommonData::activityData[0];
618 int &avtive_full_elems = PlasticOps::CommonData::activityData[1];
619 int &avtive_elems = PlasticOps::CommonData::activityData[2];
620 int &nb_points = PlasticOps::CommonData::activityData[3];
621 int &nb_elements = PlasticOps::CommonData::activityData[4];
622
623 ++nb_elements;
624 nb_points += nb_points_on_elem;
625 if (nb_points_avtive_on_elem > 0) {
626 ++avtive_elems;
627 active_points += nb_points_avtive_on_elem;
628 if (nb_points_avtive_on_elem == nb_points_on_elem) {
629 ++avtive_full_elems;
630 }
631 }
632
633 if (nb_points_avtive_on_elem != nb_points_on_elem)
634 return 1;
635 else
636 return 0;
637 };
638
639 if (DomainEleOp::getTSCtx() == TSMethod::TSContext::CTX_TSSETIJACOBIAN) {
640 get_avtive_pts();
641 }
642
643 auto dt = this->getTStimeStep();
644 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
645
646 auto eqiv = equivalent_strain_dot(t_plastic_strain_dot);
647 auto t_diff_eqiv = diff_equivalent_strain_dot(eqiv, t_plastic_strain_dot,
648 t_diff_plastic_strain,
650
651 const auto sigma_y =
652 iso_hardening(t_tau, params[CommonData::H], params[CommonData::QINF],
653 params[CommonData::BISO], params[CommonData::SIGMA_Y]);
654 const auto d_sigma_y =
655 iso_hardening_dtau(t_tau, params[CommonData::H],
656 params[CommonData::QINF], params[CommonData::BISO]);
657
658 auto ww = w(eqiv, t_tau_dot, t_f, sigma_y, params[CommonData::SIGMA_Y]);
659 auto abs_ww = constrain_abs(ww, dt);
660 auto sign_ww = constrian_sign(ww, dt);
661
662 auto c = constraint(eqiv, t_tau_dot, t_f, sigma_y, abs_ww,
663 params[CommonData::VIS_H], params[CommonData::SIGMA_Y]);
664 auto c_dot_tau = diff_constrain_ddot_tau(sign_ww, eqiv, t_tau_dot,
665 params[CommonData::VIS_H],
666 params[CommonData::SIGMA_Y]);
667 auto c_equiv = diff_constrain_deqiv(sign_ww, eqiv, t_tau_dot,
668 params[CommonData::SIGMA_Y]);
669 auto c_sigma_y = diff_constrain_dsigma_y(sign_ww);
670 auto c_f = diff_constrain_df(sign_ww);
671
672 auto t_dev_stress = deviator(
673
674 t_stress, trace(t_stress),
675
676 kinematic_hardening(t_plastic_strain, params[CommonData::C1_k])
677
678 );
679
681 t_flow_dir(k, l) = 1.5 * (t_dev_stress(I, J) * t_diff_deviator(I, J, k, l));
683 t_flow_dstrain(i, j) = t_flow(k, l) * t_D_Op(k, l, i, j);
684
685 auto get_res_c = [&]() { return c; };
686
687 auto get_res_c_dstrain = [&](auto &t_diff_res) {
688 t_diff_res(i, j) = c_f * t_flow_dstrain(i, j);
689 };
690
691 auto get_res_c_dplastic_strain = [&](auto &t_diff_res) {
692 t_diff_res(i, j) = (this->getTSa() * c_equiv) * t_diff_eqiv(i, j);
693 t_diff_res(k, l) -= c_f * t_flow(i, j) * t_alpha_dir(i, j, k, l);
694 };
695
696 auto get_res_c_dtau = [&]() {
697 return this->getTSa() * c_dot_tau + c_sigma_y * d_sigma_y;
698 };
699
700 [[maybe_unused]] auto get_res_c_plastic_strain = [&](auto &t_diff_res) {
701 t_diff_res(k, l) = -c_f * t_flow(i, j) * t_alpha_dir(i, j, k, l);
702 };
703
704 auto get_res_flow = [&](auto &t_res_flow) {
705 const auto a = sigma_y;
706 const auto b = t_tau_dot;
707 t_res_flow(k, l) = a * t_plastic_strain_dot(k, l) - b * t_flow_dir(k, l);
708 };
709
710 auto get_res_flow_dtau = [&](auto &t_res_flow_dtau) {
711 const auto da = d_sigma_y;
712 const auto db = this->getTSa();
713 t_res_flow_dtau(k, l) =
714 da * t_plastic_strain_dot(k, l) - db * t_flow_dir(k, l);
715 };
716
717 auto get_res_flow_dstrain = [&](auto &t_res_flow_dstrain) {
718 const auto b = t_tau_dot;
719 t_res_flow_dstrain(m, n, k, l) = -t_flow_dir_dstrain(m, n, k, l) * b;
720 };
721
722 auto get_res_flow_dplastic_strain = [&](auto &t_res_flow_dplastic_strain) {
723 const auto a = sigma_y;
724 t_res_flow_dplastic_strain(m, n, k, l) =
725 (a * this->getTSa()) * t_diff_plastic_strain(m, n, k, l);
726 const auto b = t_tau_dot;
727 t_res_flow_dplastic_strain(m, n, i, j) +=
728 (t_flow_dir_dstrain(m, n, k, l) * t_alpha_dir(k, l, i, j)) * b;
729 };
730
731 t_res_c = get_res_c();
732 get_res_flow(t_res_flow);
733
734 if (this->getTSCtx() == TSMethod::TSContext::CTX_TSSETIJACOBIAN) {
735 t_res_c_dtau = get_res_c_dtau();
736 get_res_c_dstrain(t_res_c_dstrain);
737 get_res_c_dplastic_strain(t_res_c_plastic_strain);
738 get_res_flow_dtau(t_res_flow_dtau);
739 get_res_flow_dstrain(t_res_flow_dstrain);
740 get_res_flow_dplastic_strain(t_res_flow_dplastic_strain);
741 }
742
743 next();
744 }
745
747}
748
749template <int DIM, typename DomainEleOp>
750struct OpPlasticStressImpl<DIM, GAUSS, DomainEleOp> : public DomainEleOp {
751
752 /**
753 * @deprecated do not use this constructor
754 */
755 DEPRECATED OpPlasticStressImpl(const std::string field_name,
756 boost::shared_ptr<CommonData> common_data_ptr,
757 boost::shared_ptr<MatrixDouble> mDPtr);
758 OpPlasticStressImpl(boost::shared_ptr<CommonData> common_data_ptr,
759 boost::shared_ptr<MatrixDouble> mDPtr);
760
761 MoFEMErrorCode doWork(int side, EntityType type, EntData &data);
762
763private:
764 boost::shared_ptr<MatrixDouble> mDPtr;
765 boost::shared_ptr<CommonData> commonDataPtr;
766};
767
768template <int DIM, typename DomainEleOp>
770 const std::string field_name, boost::shared_ptr<CommonData> common_data_ptr,
771 boost::shared_ptr<MatrixDouble> m_D_ptr)
773 commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {
774 // Operator is only executed for vertices
775 std::fill(&DomainEleOp::doEntities[MBEDGE],
776 &DomainEleOp::doEntities[MBMAXTYPE], false);
777}
778
779template <int DIM, typename DomainEleOp>
781 boost::shared_ptr<CommonData> common_data_ptr,
782 boost::shared_ptr<MatrixDouble> m_D_ptr)
783 : DomainEleOp(NOSPACE, DomainEleOp::OPSPACE),
784 commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {}
785
786//! [Calculate stress]
787template <int DIM, typename DomainEleOp>
788MoFEMErrorCode
790 EntData &data) {
792
793 FTensor::Index<'i', DIM> i;
794 FTensor::Index<'j', DIM> j;
795 FTensor::Index<'k', DIM> k;
796 FTensor::Index<'l', DIM> l;
797
798 const size_t nb_gauss_pts = commonDataPtr->mStrainPtr->size1();
799 commonDataPtr->mStressPtr->resize(nb_gauss_pts, (DIM * (DIM + 1)) / 2);
800 auto t_D = getFTensor4DdgFromMat<DIM, DIM, 0>(*mDPtr);
801 auto t_strain = getFTensor2SymmetricFromMat<DIM>(*(commonDataPtr->mStrainPtr));
802 auto t_plastic_strain =
803 getFTensor2SymmetricFromMat<DIM>(commonDataPtr->plasticStrain);
804 auto t_stress = getFTensor2SymmetricFromMat<DIM>(*(commonDataPtr->mStressPtr));
805
806 for (size_t gg = 0; gg != nb_gauss_pts; ++gg) {
807 t_stress(i, j) =
808 t_D(i, j, k, l) * (t_strain(k, l) - t_plastic_strain(k, l));
809 ++t_strain;
810 ++t_plastic_strain;
811 ++t_stress;
812 }
813
815}
816//! [Calculate stress]
817
818template <int DIM, typename AssemblyDomainEleOp>
820 : public AssemblyDomainEleOp {
822 boost::shared_ptr<CommonData> common_data_ptr,
823 boost::shared_ptr<MatrixDouble> m_D_ptr);
824 MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &data);
825
826private:
827 boost::shared_ptr<CommonData> commonDataPtr;
828 boost::shared_ptr<MatrixDouble> mDPtr;
829};
830
831template <int DIM, typename AssemblyDomainEleOp>
834 boost::shared_ptr<CommonData> common_data_ptr,
835 boost::shared_ptr<MatrixDouble> m_D_ptr)
837 commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {}
838
839template <int DIM, typename AssemblyDomainEleOp>
840MoFEMErrorCode
842 EntitiesFieldData::EntData &data) {
844
845 FTensor::Index<'i', DIM> i;
846 FTensor::Index<'j', DIM> j;
847 FTensor::Index<'k', DIM> k;
848 FTensor::Index<'l', DIM> l;
849 constexpr auto size_symm = (DIM * (DIM + 1)) / 2;
851
852 const auto nb_integration_pts = AssemblyDomainEleOp::getGaussPts().size2();
853 const auto nb_base_functions = data.getN().size2();
854
855 auto t_res_flow = getFTensor2SymmetricFromMat<DIM>(commonDataPtr->resFlow);
856
858
859 auto next = [&]() { ++t_res_flow; };
860
861 auto t_w = AssemblyDomainEleOp::getFTensor0IntegrationWeight();
862 auto t_base = data.getFTensor0N();
863 auto &nf = AssemblyDomainEleOp::locF;
864 for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
865 double alpha = AssemblyDomainEleOp::getMeasure() * t_w;
866 ++t_w;
867
869 t_rhs(L) = alpha * (t_res_flow(i, j) * t_L(i, j, L));
870 next();
871
872 auto t_nf = getFTensor1FromArray<size_symm, size_symm>(nf);
873 size_t bb = 0;
874 for (; bb != AssemblyDomainEleOp::nbRows / size_symm; ++bb) {
875 t_nf(L) += t_base * t_rhs(L);
876 ++t_base;
877 ++t_nf;
878 }
879 for (; bb < nb_base_functions; ++bb)
880 ++t_base;
881 }
882
884}
885
886template <typename AssemblyDomainEleOp>
888 : public AssemblyDomainEleOp {
890 boost::shared_ptr<CommonData> common_data_ptr,
891 boost::shared_ptr<MatrixDouble> m_D_ptr);
892 MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &data);
893
894private:
895 boost::shared_ptr<CommonData> commonDataPtr;
896 boost::shared_ptr<MatrixDouble> mDPtr;
897};
898
899template <typename AssemblyDomainEleOp>
902 boost::shared_ptr<CommonData> common_data_ptr,
903 boost::shared_ptr<MatrixDouble> m_D_ptr)
905 commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {}
906
907template <typename AssemblyDomainEleOp>
908MoFEMErrorCode
910 EntitiesFieldData::EntData &data) {
912
913 const size_t nb_integration_pts = AssemblyDomainEleOp::getGaussPts().size2();
914 const size_t nb_base_functions = data.getN().size2();
915
916 auto t_res_c = getFTensor0FromVec(commonDataPtr->resC);
917
918 auto next = [&]() { ++t_res_c; };
919
920 auto t_w = AssemblyDomainEleOp::getFTensor0IntegrationWeight();
921 auto &nf = AssemblyDomainEleOp::locF;
922 auto t_base = data.getFTensor0N();
923 for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
924 const double alpha = AssemblyDomainEleOp::getMeasure() * t_w;
925 ++t_w;
926 const auto res = alpha * t_res_c;
927 next();
928
929 size_t bb = 0;
930 for (; bb != AssemblyDomainEleOp::nbRows; ++bb) {
931 nf[bb] += t_base * res;
932 ++t_base;
933 }
934 for (; bb < nb_base_functions; ++bb)
935 ++t_base;
936 }
937
939}
940
941template <int DIM, typename AssemblyDomainEleOp>
943 : public AssemblyDomainEleOp {
945 const std::string row_field_name, const std::string col_field_name,
946 boost::shared_ptr<CommonData> common_data_ptr,
947 boost::shared_ptr<MatrixDouble> m_D_ptr);
948 MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data,
949 EntitiesFieldData::EntData &col_data);
950
951private:
952 boost::shared_ptr<CommonData> commonDataPtr;
953 boost::shared_ptr<MatrixDouble> mDPtr;
954};
955
956template <int DIM, typename AssemblyDomainEleOp>
959 const std::string row_field_name, const std::string col_field_name,
960 boost::shared_ptr<CommonData> common_data_ptr,
961 boost::shared_ptr<MatrixDouble> m_D_ptr)
962 : AssemblyDomainEleOp(row_field_name, col_field_name,
963 AssemblyDomainEleOp::OPROWCOL),
964 commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {
965 AssemblyDomainEleOp::sYmm = false;
966}
967
968static inline auto get_mat_tensor_sym_dtensor_sym(size_t rr, MatrixDouble &mat,
971 &mat(3 * rr + 0, 0), &mat(3 * rr + 0, 1), &mat(3 * rr + 0, 2),
972 &mat(3 * rr + 1, 0), &mat(3 * rr + 1, 1), &mat(3 * rr + 1, 2),
973 &mat(3 * rr + 2, 0), &mat(3 * rr + 2, 1), &mat(3 * rr + 2, 2)};
974}
975
976static inline auto get_mat_tensor_sym_dtensor_sym(size_t rr, MatrixDouble &mat,
979 &mat(6 * rr + 0, 0), &mat(6 * rr + 0, 1), &mat(6 * rr + 0, 2),
980 &mat(6 * rr + 0, 3), &mat(6 * rr + 0, 4), &mat(6 * rr + 0, 5),
981 &mat(6 * rr + 1, 0), &mat(6 * rr + 1, 1), &mat(6 * rr + 1, 2),
982 &mat(6 * rr + 1, 3), &mat(6 * rr + 1, 4), &mat(6 * rr + 1, 5),
983 &mat(6 * rr + 2, 0), &mat(6 * rr + 2, 1), &mat(6 * rr + 2, 2),
984 &mat(6 * rr + 2, 3), &mat(6 * rr + 2, 4), &mat(6 * rr + 2, 5),
985 &mat(6 * rr + 3, 0), &mat(6 * rr + 3, 1), &mat(6 * rr + 3, 2),
986 &mat(6 * rr + 3, 3), &mat(6 * rr + 3, 4), &mat(6 * rr + 3, 5),
987 &mat(6 * rr + 4, 0), &mat(6 * rr + 4, 1), &mat(6 * rr + 4, 2),
988 &mat(6 * rr + 4, 3), &mat(6 * rr + 4, 4), &mat(6 * rr + 4, 5),
989 &mat(6 * rr + 5, 0), &mat(6 * rr + 5, 1), &mat(6 * rr + 5, 2),
990 &mat(6 * rr + 5, 3), &mat(6 * rr + 5, 4), &mat(6 * rr + 5, 5)};
991}
992
993template <int DIM, typename AssemblyDomainEleOp>
994MoFEMErrorCode
996 EntitiesFieldData::EntData &row_data,
997 EntitiesFieldData::EntData &col_data) {
999
1000 FTensor::Index<'i', DIM> i;
1001 FTensor::Index<'j', DIM> j;
1002 FTensor::Index<'k', DIM> k;
1003 FTensor::Index<'l', DIM> l;
1004 constexpr auto size_symm = (DIM * (DIM + 1)) / 2;
1005 FTensor::Index<'L', size_symm> L;
1006 FTensor::Index<'O', size_symm> O;
1007
1008 auto &locMat = AssemblyDomainEleOp::locMat;
1009
1010 const auto nb_integration_pts = AssemblyDomainEleOp::getGaussPts().size2();
1011 const auto nb_row_base_functions = row_data.getN().size2();
1012
1013 auto t_res_flow_dstrain =
1014 getFTensor4DdgFromMat<DIM, DIM>(commonDataPtr->resFlowDstrain);
1015 auto t_res_flow_dplastic_strain =
1016 getFTensor4DdgFromMat<DIM, DIM>(commonDataPtr->resFlowDstrainDot);
1017 auto t_L = symm_L_tensor(FTensor::Number<DIM>());
1018
1019 auto next = [&]() {
1020 ++t_res_flow_dstrain;
1021 ++t_res_flow_dplastic_strain;
1022 };
1023
1024 auto t_w = AssemblyDomainEleOp::getFTensor0IntegrationWeight();
1025 auto t_row_base = row_data.getFTensor0N();
1026 for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
1027 double alpha = AssemblyDomainEleOp::getMeasure() * t_w;
1028 ++t_w;
1029
1031 t_res_mat(O, L) =
1032 alpha * (t_L(i, j, O) * ((t_res_flow_dplastic_strain(i, j, k, l) -
1033 t_res_flow_dstrain(i, j, k, l)) *
1034 t_L(k, l, L)));
1035 next();
1036
1037 size_t rr = 0;
1038 for (; rr != AssemblyDomainEleOp::nbRows / size_symm; ++rr) {
1039 auto t_mat = get_mat_tensor_sym_dtensor_sym(rr, locMat,
1041 auto t_col_base = col_data.getFTensor0N(gg, 0);
1042 for (size_t cc = 0; cc != AssemblyDomainEleOp::nbCols / size_symm; ++cc) {
1043 t_mat(O, L) += ((t_row_base * t_col_base) * t_res_mat(O, L));
1044 ++t_mat;
1045 ++t_col_base;
1046 }
1047
1048 ++t_row_base;
1049 }
1050
1051 for (; rr < nb_row_base_functions; ++rr)
1052 ++t_row_base;
1053 }
1054
1056}
1057
1058template <int DIM, typename AssemblyDomainEleOp>
1060 : public AssemblyDomainEleOp {
1062 const std::string row_field_name, const std::string col_field_name,
1063 boost::shared_ptr<CommonData> common_data_ptr,
1064 boost::shared_ptr<MatrixDouble> m_D_ptr);
1065 MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data,
1066 EntitiesFieldData::EntData &col_data);
1067
1068private:
1069 boost::shared_ptr<CommonData> commonDataPtr;
1070 boost::shared_ptr<MatrixDouble> mDPtr;
1071};
1072
1073template <int DIM, typename AssemblyDomainEleOp>
1075 : public AssemblyDomainEleOp {
1077 const std::string row_field_name, const std::string col_field_name,
1078 boost::shared_ptr<CommonData> common_data_ptr,
1079 boost::shared_ptr<MatrixDouble> m_D_ptr);
1080 MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data,
1081 EntitiesFieldData::EntData &col_data);
1082
1083private:
1084 boost::shared_ptr<CommonData> commonDataPtr;
1085 boost::shared_ptr<MatrixDouble> mDPtr;
1086};
1087
1088template <int DIM, typename AssemblyDomainEleOp>
1091 const std::string row_field_name, const std::string col_field_name,
1092 boost::shared_ptr<CommonData> common_data_ptr,
1093 boost::shared_ptr<MatrixDouble> m_D_ptr)
1094 : AssemblyDomainEleOp(row_field_name, col_field_name,
1095 DomainEleOp::OPROWCOL),
1096 commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {
1097 AssemblyDomainEleOp::sYmm = false;
1098}
1099
1100static inline auto get_mat_tensor_sym_dscalar(size_t rr, MatrixDouble &mat,
1103 &mat(3 * rr + 0, 0), &mat(3 * rr + 1, 0), &mat(3 * rr + 2, 0)};
1104}
1105
1106static inline auto get_mat_tensor_sym_dscalar(size_t rr, MatrixDouble &mat,
1109 &mat(6 * rr + 0, 0), &mat(6 * rr + 1, 0), &mat(6 * rr + 2, 0),
1110 &mat(6 * rr + 3, 0), &mat(6 * rr + 4, 0), &mat(6 * rr + 5, 0)};
1111}
1112
1113template <int DIM, typename AssemblyDomainEleOp>
1114MoFEMErrorCode
1116 EntitiesFieldData::EntData &row_data,
1117 EntitiesFieldData::EntData &col_data) {
1119
1120 FTensor::Index<'i', DIM> i;
1121 FTensor::Index<'j', DIM> j;
1122 constexpr auto size_symm = (DIM * (DIM + 1)) / 2;
1123 FTensor::Index<'L', size_symm> L;
1124
1125 const auto nb_integration_pts = AssemblyDomainEleOp::getGaussPts().size2();
1126 const size_t nb_row_base_functions = row_data.getN().size2();
1127 auto &locMat = AssemblyDomainEleOp::locMat;
1128
1129 auto t_res_flow_dtau =
1130 getFTensor2SymmetricFromMat<DIM>(commonDataPtr->resFlowDtau);
1131
1132 auto t_L = symm_L_tensor(FTensor::Number<DIM>());
1133
1134 auto next = [&]() { ++t_res_flow_dtau; };
1135
1136 auto t_w = AssemblyDomainEleOp::getFTensor0IntegrationWeight();
1137 auto t_row_base = row_data.getFTensor0N();
1138 for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
1139 double alpha = AssemblyDomainEleOp::getMeasure() * t_w;
1140 ++t_w;
1142 t_res_vec(L) = alpha * (t_res_flow_dtau(i, j) * t_L(i, j, L));
1143 next();
1144
1145 size_t rr = 0;
1146 for (; rr != AssemblyDomainEleOp::nbRows / size_symm; ++rr) {
1147 auto t_mat =
1149 auto t_col_base = col_data.getFTensor0N(gg, 0);
1150 for (size_t cc = 0; cc != AssemblyDomainEleOp::nbCols; cc++) {
1151 t_mat(L) += t_row_base * t_col_base * t_res_vec(L);
1152 ++t_mat;
1153 ++t_col_base;
1154 }
1155 ++t_row_base;
1156 }
1157 for (; rr != nb_row_base_functions; ++rr)
1158 ++t_row_base;
1159 }
1160
1162}
1163
1164template <int DIM, typename AssemblyDomainEleOp>
1166 : public AssemblyDomainEleOp {
1168 const std::string row_field_name, const std::string col_field_name,
1169 boost::shared_ptr<CommonData> common_data_ptr,
1170 boost::shared_ptr<MatrixDouble> mat_D_ptr);
1171 MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data,
1172 EntitiesFieldData::EntData &col_data);
1173
1174private:
1175 boost::shared_ptr<CommonData> commonDataPtr;
1176 boost::shared_ptr<MatrixDouble> mDPtr;
1177};
1178
1179template <int DIM, typename AssemblyDomainEleOp>
1182 const std::string row_field_name, const std::string col_field_name,
1183 boost::shared_ptr<CommonData> common_data_ptr,
1184 boost::shared_ptr<MatrixDouble> m_D_ptr)
1185 : AssemblyDomainEleOp(row_field_name, col_field_name,
1186 DomainEleOp::OPROWCOL),
1187 commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {
1188 AssemblyDomainEleOp::sYmm = false;
1189}
1190
1193 &mat(0, 0), &mat(0, 1), &mat(0, 2)};
1194}
1195
1198 &mat(0, 0), &mat(0, 1), &mat(0, 2), &mat(0, 3), &mat(0, 4), &mat(0, 5)};
1199}
1200
1201template <int DIM, typename AssemblyDomainEleOp>
1202MoFEMErrorCode
1204 EntitiesFieldData::EntData &row_data,
1205 EntitiesFieldData::EntData &col_data) {
1207
1208 FTensor::Index<'i', DIM> i;
1209 FTensor::Index<'j', DIM> j;
1210 constexpr auto size_symm = (DIM * (DIM + 1)) / 2;
1211 FTensor::Index<'L', size_symm> L;
1212
1213 const auto nb_integration_pts = AssemblyDomainEleOp::getGaussPts().size2();
1214 const auto nb_row_base_functions = row_data.getN().size2();
1215
1216 auto t_c_dstrain =
1217 getFTensor2SymmetricFromMat<SPACE_DIM>(commonDataPtr->resCdStrain);
1218 auto t_c_dplastic_strain =
1219 getFTensor2SymmetricFromMat<SPACE_DIM>(commonDataPtr->resCdPlasticStrain);
1220
1221 auto next = [&]() {
1222 ++t_c_dstrain;
1223 ++t_c_dplastic_strain;
1224 };
1225
1227
1228 auto t_w = AssemblyDomainEleOp::getFTensor0IntegrationWeight();
1229 auto t_row_base = row_data.getFTensor0N();
1230 for (auto gg = 0; gg != nb_integration_pts; ++gg) {
1231 const double alpha = AssemblyDomainEleOp::getMeasure() * t_w;
1232 ++t_w;
1233
1235 t_res_vec(L) =
1236 t_L(i, j, L) * (t_c_dplastic_strain(i, j) - t_c_dstrain(i, j));
1237 next();
1238
1239 auto t_mat = get_mat_scalar_dtensor_sym(AssemblyDomainEleOp::locMat,
1241 size_t rr = 0;
1242 for (; rr != AssemblyDomainEleOp::nbRows; ++rr) {
1243 const auto row_base = alpha * t_row_base;
1244 auto t_col_base = col_data.getFTensor0N(gg, 0);
1245 for (size_t cc = 0; cc != AssemblyDomainEleOp::nbCols / size_symm; cc++) {
1246 t_mat(L) += (row_base * t_col_base) * t_res_vec(L);
1247 ++t_mat;
1248 ++t_col_base;
1249 }
1250 ++t_row_base;
1251 }
1252 for (; rr != nb_row_base_functions; ++rr)
1253 ++t_row_base;
1254 }
1255
1257}
1258
1259template <typename AssemblyDomainEleOp>
1261 : public AssemblyDomainEleOp {
1263 const std::string row_field_name, const std::string col_field_name,
1264 boost::shared_ptr<CommonData> common_data_ptr);
1265 MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data,
1266 EntitiesFieldData::EntData &col_data);
1267
1268private:
1269 boost::shared_ptr<CommonData> commonDataPtr;
1270};
1271
1272template <typename AssemblyDomainEleOp>
1275 const std::string row_field_name, const std::string col_field_name,
1276 boost::shared_ptr<CommonData> common_data_ptr)
1277 : AssemblyDomainEleOp(row_field_name, col_field_name,
1278 DomainEleOp::OPROWCOL),
1279 commonDataPtr(common_data_ptr) {
1280 AssemblyDomainEleOp::sYmm = false;
1281}
1282
1283template <typename AssemblyDomainEleOp>
1284MoFEMErrorCode
1286 EntitiesFieldData::EntData &row_data,
1287 EntitiesFieldData::EntData &col_data) {
1289
1290 const auto nb_integration_pts = AssemblyDomainEleOp::getGaussPts().size2();
1291 const auto nb_row_base_functions = row_data.getN().size2();
1292
1293 auto t_res_c_dtau = getFTensor0FromVec(commonDataPtr->resCdTau);
1294 auto next = [&]() { ++t_res_c_dtau; };
1295
1296 auto t_w = AssemblyDomainEleOp::getFTensor0IntegrationWeight();
1297 auto t_row_base = row_data.getFTensor0N();
1298 for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
1299 const double alpha = AssemblyDomainEleOp::getMeasure() * t_w;
1300 ++t_w;
1301
1302 const auto res = alpha * (t_res_c_dtau);
1303 next();
1304
1305 auto mat_ptr = AssemblyDomainEleOp::locMat.data().begin();
1306 size_t rr = 0;
1307 for (; rr != AssemblyDomainEleOp::nbRows; ++rr) {
1308 auto t_col_base = col_data.getFTensor0N(gg, 0);
1309 for (size_t cc = 0; cc != AssemblyDomainEleOp::nbCols; ++cc) {
1310 *mat_ptr += t_row_base * t_col_base * res;
1311 ++t_col_base;
1312 ++mat_ptr;
1313 }
1314 ++t_row_base;
1315 }
1316 for (; rr < nb_row_base_functions; ++rr)
1317 ++t_row_base;
1318 }
1319
1321}
1322}; // namespace PlasticOps
constexpr double third
std::string type
constexpr double a
Kronecker Delta class symmetric.
@ NOSPACE
Definition definitions.h:83
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define DEPRECATED
Definition definitions.h:17
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
constexpr auto t_kd
FTensor::Index< 'i', SPACE_DIM > i
double dt
const double c
speed of light (cm/ns)
const double n
refractive index of diffusive medium
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
static auto get_mat_tensor_sym_dtensor_sym(size_t rr, MatrixDouble &mat, FTensor::Number< 2 >)
FTensor::Index< 'N', 3 > N
auto diff_plastic_flow_dstress(long double f, FTensor::Tensor2_symmetric< T, DIM > &t_flow, FTensor::Ddg< double, 3, DIM > &&t_diff_deviator)
static auto get_mat_tensor_sym_dscalar(size_t rr, MatrixDouble &mat, FTensor::Number< 2 >)
double platsic_surface(FTensor::Tensor2_symmetric< double, 3 > &&t_stress_deviator)
auto get_mat_scalar_dtensor_sym(MatrixDouble &mat, FTensor::Number< 2 >)
auto symm_L_tensor(FTensor::Number< DIM >)
double diff_constrain_ddot_tau(double sign, double eqiv, double dot_tau, double vis_H, double sigma_Y)
auto diff_constrain_dstress(double diff_constrain_df, FTensor::Tensor2_symmetric< T, DIM > &t_plastic_flow)
double constrian_sign(double x, double dt)
FTensor::Index< 'J', 3 > J
double diff_constrain_deqiv(double sign, double eqiv, double dot_tau, double sigma_Y)
auto diff_equivalent_strain_dot(const T1 eqiv, T2 &t_plastic_strain_dot, T3 &t_diff_plastic_strain, FTensor::Number< DIM >)
double constraint(double eqiv, double dot_tau, double f, double sigma_y, double abs_w, double vis_H, double sigma_Y)
auto diff_constrain_df(double sign)
auto diff_constrain_dsigma_y(double sign)
auto diff_symmetrize(FTensor::Number< DIM >)
auto diff_tensor(FTensor::Number< DIM >)
[Lambda functions]
FTensor::Index< 'I', 3 > I
[Common data]
auto diff_deviator(FTensor::Ddg< double, DIM, DIM > &&t_diff_stress, FTensor::Number< DIM >)
double trace(FTensor::Tensor2_symmetric< T, 2 > &t_stress)
auto diff_plastic_flow_dstrain(FTensor::Ddg< T, DIM, DIM > &t_D, FTensor::Ddg< double, DIM, DIM > &&t_diff_plastic_flow_dstress)
auto plastic_flow(long double f, FTensor::Tensor2_symmetric< double, 3 > &&t_dev_stress, FTensor::Ddg< double, 3, DIM > &&t_diff_deviator)
auto deviator(FTensor::Tensor2_symmetric< T, DIM > &t_stress, double trace, FTensor::Tensor2_symmetric< double, DIM > &t_alpha, FTensor::Number< DIM >)
double w(double eqiv, double dot_tau, double f, double sigma_y, double sigma_Y)
auto diff_constrain_dstrain(T1 &t_D, T2 &&t_diff_constrain_dstress)
static auto get_mat_tensor_sym_dvector(size_t rr, MatrixDouble &mat, FTensor::Number< 2 >)
[Lambda functions]
auto equivalent_strain_dot(FTensor::Tensor2_symmetric< T, DIM > &t_plastic_strain_dot)
double constrain_abs(double x, double dt)
constexpr AssemblyType A
constexpr auto field_name
FTensor::Index< 'm', 3 > m
Data on single entity (This is passed as argument to DataOperator::doWork)
static std::array< int, 5 > activityData
auto kinematic_hardening(FTensor::Tensor2_symmetric< T, DIM > &t_plastic_strain, double C1_k)
Definition plastic.cpp:93
double iso_hardening_dtau(double tau, double H, double Qinf, double b_iso)
Definition plastic.cpp:79
constexpr auto size_symm
Definition plastic.cpp:42
double zeta
Viscous hardening.
Definition plastic.cpp:131
double cn0
Definition plastic.cpp:136
double iso_hardening(double tau, double H, double Qinf, double b_iso, double sigmaY)
Definition plastic.cpp:74
double cn1
Definition plastic.cpp:137