v0.16.3
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 = getFTensor4DdgFromMat<DIM, DIM, 0>(*commonDataPtr->mDPtr);
517 auto t_D_Op = getFTensor4DdgFromMat<DIM, DIM, 0>(*mDPtr);
518
519 auto t_diff_plastic_strain = diff_tensor(FTensor::Number<DIM>());
520 auto t_diff_deviator = diff_deviator(diff_tensor(FTensor::Number<DIM>()));
521
522 FTensor::Ddg<double, DIM, DIM> t_flow_dir_dstress;
523 FTensor::Ddg<double, DIM, DIM> t_flow_dir_dstrain;
524 t_flow_dir_dstress(i, j, k, l) =
525 1.5 * (t_diff_deviator(M, N, i, j) * t_diff_deviator(M, N, k, l));
526 t_flow_dir_dstrain(i, j, k, l) =
527 t_flow_dir_dstress(i, j, m, n) * t_D_Op(m, n, k, l);
528
529
530 auto t_alpha_dir =
531 kinematic_hardening_dplastic_strain<DIM>(params[CommonData::C1_k]);
532
533 commonDataPtr->resC.resize(nb_gauss_pts, false);
534 commonDataPtr->resCdTau.resize(nb_gauss_pts, false);
535 commonDataPtr->resCdStrain.resize(nb_gauss_pts, size_symm, false);
536 commonDataPtr->resCdPlasticStrain.resize(nb_gauss_pts, size_symm, false);
537 commonDataPtr->resFlow.resize(nb_gauss_pts, size_symm, false);
538 commonDataPtr->resFlowDtau.resize(nb_gauss_pts, size_symm, false);
539 commonDataPtr->resFlowDstrain.resize(nb_gauss_pts, size_symm * size_symm,
540 false);
541 commonDataPtr->resFlowDstrainDot.resize(nb_gauss_pts, size_symm * size_symm,
542 false);
543
544 commonDataPtr->resC.clear();
545 commonDataPtr->resCdTau.clear();
546 commonDataPtr->resCdStrain.clear();
547 commonDataPtr->resCdPlasticStrain.clear();
548 commonDataPtr->resFlow.clear();
549 commonDataPtr->resFlowDtau.clear();
550 commonDataPtr->resFlowDstrain.clear();
551 commonDataPtr->resFlowDstrainDot.clear();
552
553 auto t_res_c = getFTensor0FromVec(commonDataPtr->resC);
554 auto t_res_c_dtau = getFTensor0FromVec(commonDataPtr->resCdTau);
555 auto t_res_c_dstrain =
556 getFTensor2SymmetricFromMat<DIM>(commonDataPtr->resCdStrain);
557 auto t_res_c_plastic_strain =
558 getFTensor2SymmetricFromMat<DIM>(commonDataPtr->resCdPlasticStrain);
559 auto t_res_flow = getFTensor2SymmetricFromMat<DIM>(commonDataPtr->resFlow);
560 auto t_res_flow_dtau =
561 getFTensor2SymmetricFromMat<DIM>(commonDataPtr->resFlowDtau);
562 auto t_res_flow_dstrain =
563 getFTensor4DdgFromMat<DIM, DIM>(commonDataPtr->resFlowDstrain);
564 auto t_res_flow_dplastic_strain =
565 getFTensor4DdgFromMat<DIM, DIM>(commonDataPtr->resFlowDstrainDot);
566
567 auto next = [&]() {
568 ++t_tau;
569 ++t_tau_dot;
570 ++t_f;
571 ++t_flow;
572 ++t_plastic_strain;
573 ++t_plastic_strain_dot;
574 ++t_stress;
575 ++t_res_c;
576 ++t_res_c_dtau;
577 ++t_res_c_dstrain;
578 ++t_res_c_plastic_strain;
579 ++t_res_flow;
580 ++t_res_flow_dtau;
581 ++t_res_flow_dstrain;
582 ++t_res_flow_dplastic_strain;
583 ++t_w;
584 };
585
586 auto get_avtive_pts = [&]() {
587 int nb_points_avtive_on_elem = 0;
588 int nb_points_on_elem = 0;
589
590 auto t_tau = getFTensor0FromVec(commonDataPtr->plasticTau);
591 auto t_tau_dot = getFTensor0FromVec(commonDataPtr->plasticTauDot);
592 auto t_f = getFTensor0FromVec(commonDataPtr->plasticSurface);
593 auto t_plastic_strain_dot =
594 getFTensor2SymmetricFromMat<SPACE_DIM>(commonDataPtr->plasticStrainDot);
595
596 auto dt = this->getTStimeStep();
597
598 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
599 auto eqiv = equivalent_strain_dot(t_plastic_strain_dot);
600 const auto ww = w(
601 eqiv, t_tau_dot, t_f,
602 iso_hardening(t_tau, params[CommonData::H], params[CommonData::QINF],
603 params[CommonData::BISO], params[CommonData::SIGMA_Y]),
604 params[CommonData::SIGMA_Y]);
605 const auto sign_ww = constrian_sign(ww, dt);
606
607 ++nb_points_on_elem;
608 if (sign_ww > 0) {
609 ++nb_points_avtive_on_elem;
610 }
611
612 ++t_tau;
613 ++t_tau_dot;
614 ++t_f;
615 ++t_plastic_strain_dot;
616 }
617
618 int &active_points = PlasticOps::CommonData::activityData[0];
619 int &avtive_full_elems = PlasticOps::CommonData::activityData[1];
620 int &avtive_elems = PlasticOps::CommonData::activityData[2];
621 int &nb_points = PlasticOps::CommonData::activityData[3];
622 int &nb_elements = PlasticOps::CommonData::activityData[4];
623
624 ++nb_elements;
625 nb_points += nb_points_on_elem;
626 if (nb_points_avtive_on_elem > 0) {
627 ++avtive_elems;
628 active_points += nb_points_avtive_on_elem;
629 if (nb_points_avtive_on_elem == nb_points_on_elem) {
630 ++avtive_full_elems;
631 }
632 }
633
634 if (nb_points_avtive_on_elem != nb_points_on_elem)
635 return 1;
636 else
637 return 0;
638 };
639
640 if (DomainEleOp::getTSCtx() == TSMethod::TSContext::CTX_TSSETIJACOBIAN) {
641 get_avtive_pts();
642 }
643
644 auto dt = this->getTStimeStep();
645 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
646
647 auto eqiv = equivalent_strain_dot(t_plastic_strain_dot);
648 auto t_diff_eqiv = diff_equivalent_strain_dot(eqiv, t_plastic_strain_dot,
649 t_diff_plastic_strain,
651
652 const auto sigma_y =
653 iso_hardening(t_tau, params[CommonData::H], params[CommonData::QINF],
654 params[CommonData::BISO], params[CommonData::SIGMA_Y]);
655 const auto d_sigma_y =
656 iso_hardening_dtau(t_tau, params[CommonData::H],
657 params[CommonData::QINF], params[CommonData::BISO]);
658
659 auto ww = w(eqiv, t_tau_dot, t_f, sigma_y, params[CommonData::SIGMA_Y]);
660 auto abs_ww = constrain_abs(ww, dt);
661 auto sign_ww = constrian_sign(ww, dt);
662
663 auto c = constraint(eqiv, t_tau_dot, t_f, sigma_y, abs_ww,
664 params[CommonData::VIS_H], params[CommonData::SIGMA_Y]);
665 auto c_dot_tau = diff_constrain_ddot_tau(sign_ww, eqiv, t_tau_dot,
666 params[CommonData::VIS_H],
667 params[CommonData::SIGMA_Y]);
668 auto c_equiv = diff_constrain_deqiv(sign_ww, eqiv, t_tau_dot,
669 params[CommonData::SIGMA_Y]);
670 auto c_sigma_y = diff_constrain_dsigma_y(sign_ww);
671 auto c_f = diff_constrain_df(sign_ww);
672
673 auto t_dev_stress = deviator(
674
675 t_stress, trace(t_stress),
676
677 kinematic_hardening(t_plastic_strain, params[CommonData::C1_k])
678
679 );
680
682 t_flow_dir(k, l) = 1.5 * (t_dev_stress(I, J) * t_diff_deviator(I, J, k, l));
684 t_flow_dstrain(i, j) = t_flow(k, l) * t_D_Op(k, l, i, j);
685
686 auto get_res_c = [&]() { return c; };
687
688 auto get_res_c_dstrain = [&](auto &t_diff_res) {
689 t_diff_res(i, j) = c_f * t_flow_dstrain(i, j);
690 };
691
692 auto get_res_c_dplastic_strain = [&](auto &t_diff_res) {
693 t_diff_res(i, j) = (this->getTSa() * c_equiv) * t_diff_eqiv(i, j);
694 t_diff_res(k, l) -= c_f * t_flow(i, j) * t_alpha_dir(i, j, k, l);
695 };
696
697 auto get_res_c_dtau = [&]() {
698 return this->getTSa() * c_dot_tau + c_sigma_y * d_sigma_y;
699 };
700
701 auto get_res_c_plastic_strain = [&](auto &t_diff_res) {
702 t_diff_res(k, l) = -c_f * t_flow(i, j) * t_alpha_dir(i, j, k, l);
703 };
704
705 auto get_res_flow = [&](auto &t_res_flow) {
706 const auto a = sigma_y;
707 const auto b = t_tau_dot;
708 t_res_flow(k, l) = a * t_plastic_strain_dot(k, l) - b * t_flow_dir(k, l);
709 };
710
711 auto get_res_flow_dtau = [&](auto &t_res_flow_dtau) {
712 const auto da = d_sigma_y;
713 const auto db = this->getTSa();
714 t_res_flow_dtau(k, l) =
715 da * t_plastic_strain_dot(k, l) - db * t_flow_dir(k, l);
716 };
717
718 auto get_res_flow_dstrain = [&](auto &t_res_flow_dstrain) {
719 const auto b = t_tau_dot;
720 t_res_flow_dstrain(m, n, k, l) = -t_flow_dir_dstrain(m, n, k, l) * b;
721 };
722
723 auto get_res_flow_dplastic_strain = [&](auto &t_res_flow_dplastic_strain) {
724 const auto a = sigma_y;
725 t_res_flow_dplastic_strain(m, n, k, l) =
726 (a * this->getTSa()) * t_diff_plastic_strain(m, n, k, l);
727 const auto b = t_tau_dot;
728 t_res_flow_dplastic_strain(m, n, i, j) +=
729 (t_flow_dir_dstrain(m, n, k, l) * t_alpha_dir(k, l, i, j)) * b;
730 };
731
732 t_res_c = get_res_c();
733 get_res_flow(t_res_flow);
734
735 if (this->getTSCtx() == TSMethod::TSContext::CTX_TSSETIJACOBIAN) {
736 t_res_c_dtau = get_res_c_dtau();
737 get_res_c_dstrain(t_res_c_dstrain);
738 get_res_c_dplastic_strain(t_res_c_plastic_strain);
739 get_res_flow_dtau(t_res_flow_dtau);
740 get_res_flow_dstrain(t_res_flow_dstrain);
741 get_res_flow_dplastic_strain(t_res_flow_dplastic_strain);
742 }
743
744 next();
745 }
746
748}
749
750template <int DIM, typename DomainEleOp>
751struct OpPlasticStressImpl<DIM, GAUSS, DomainEleOp> : public DomainEleOp {
752
753 /**
754 * @deprecated do not use this constructor
755 */
756 DEPRECATED OpPlasticStressImpl(const std::string field_name,
757 boost::shared_ptr<CommonData> common_data_ptr,
758 boost::shared_ptr<MatrixDouble> mDPtr);
759 OpPlasticStressImpl(boost::shared_ptr<CommonData> common_data_ptr,
760 boost::shared_ptr<MatrixDouble> mDPtr);
761
762 MoFEMErrorCode doWork(int side, EntityType type, EntData &data);
763
764private:
765 boost::shared_ptr<MatrixDouble> mDPtr;
766 boost::shared_ptr<CommonData> commonDataPtr;
767};
768
769template <int DIM, typename DomainEleOp>
771 const std::string field_name, boost::shared_ptr<CommonData> common_data_ptr,
772 boost::shared_ptr<MatrixDouble> m_D_ptr)
774 commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {
775 // Operator is only executed for vertices
776 std::fill(&DomainEleOp::doEntities[MBEDGE],
777 &DomainEleOp::doEntities[MBMAXTYPE], false);
778}
779
780template <int DIM, typename DomainEleOp>
782 boost::shared_ptr<CommonData> common_data_ptr,
783 boost::shared_ptr<MatrixDouble> m_D_ptr)
784 : DomainEleOp(NOSPACE, DomainEleOp::OPSPACE),
785 commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {}
786
787//! [Calculate stress]
788template <int DIM, typename DomainEleOp>
789MoFEMErrorCode
791 EntData &data) {
793
794 FTensor::Index<'i', DIM> i;
795 FTensor::Index<'j', DIM> j;
796 FTensor::Index<'k', DIM> k;
797 FTensor::Index<'l', DIM> l;
798
799 const size_t nb_gauss_pts = commonDataPtr->mStrainPtr->size1();
800 commonDataPtr->mStressPtr->resize(nb_gauss_pts, (DIM * (DIM + 1)) / 2);
801 auto t_D = getFTensor4DdgFromMat<DIM, DIM, 0>(*mDPtr);
802 auto t_strain = getFTensor2SymmetricFromMat<DIM>(*(commonDataPtr->mStrainPtr));
803 auto t_plastic_strain =
804 getFTensor2SymmetricFromMat<DIM>(commonDataPtr->plasticStrain);
805 auto t_stress = getFTensor2SymmetricFromMat<DIM>(*(commonDataPtr->mStressPtr));
806
807 for (size_t gg = 0; gg != nb_gauss_pts; ++gg) {
808 t_stress(i, j) =
809 t_D(i, j, k, l) * (t_strain(k, l) - t_plastic_strain(k, l));
810 ++t_strain;
811 ++t_plastic_strain;
812 ++t_stress;
813 }
814
816}
817//! [Calculate stress]
818
819template <int DIM, typename AssemblyDomainEleOp>
821 : public AssemblyDomainEleOp {
823 boost::shared_ptr<CommonData> common_data_ptr,
824 boost::shared_ptr<MatrixDouble> m_D_ptr);
825 MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &data);
826
827private:
828 boost::shared_ptr<CommonData> commonDataPtr;
829 boost::shared_ptr<MatrixDouble> mDPtr;
830};
831
832template <int DIM, typename AssemblyDomainEleOp>
835 boost::shared_ptr<CommonData> common_data_ptr,
836 boost::shared_ptr<MatrixDouble> m_D_ptr)
838 commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {}
839
840template <int DIM, typename AssemblyDomainEleOp>
841MoFEMErrorCode
843 EntitiesFieldData::EntData &data) {
845
846 FTensor::Index<'i', DIM> i;
847 FTensor::Index<'j', DIM> j;
848 FTensor::Index<'k', DIM> k;
849 FTensor::Index<'l', DIM> l;
850 constexpr auto size_symm = (DIM * (DIM + 1)) / 2;
852
853 const auto nb_integration_pts = AssemblyDomainEleOp::getGaussPts().size2();
854 const auto nb_base_functions = data.getN().size2();
855
856 auto t_res_flow = getFTensor2SymmetricFromMat<DIM>(commonDataPtr->resFlow);
857
859
860 auto next = [&]() { ++t_res_flow; };
861
862 auto t_w = AssemblyDomainEleOp::getFTensor0IntegrationWeight();
863 auto t_base = data.getFTensor0N();
864 auto &nf = AssemblyDomainEleOp::locF;
865 for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
866 double alpha = AssemblyDomainEleOp::getMeasure() * t_w;
867 ++t_w;
868
870 t_rhs(L) = alpha * (t_res_flow(i, j) * t_L(i, j, L));
871 next();
872
873 auto t_nf = getFTensor1FromArray<size_symm, size_symm>(nf);
874 size_t bb = 0;
875 for (; bb != AssemblyDomainEleOp::nbRows / size_symm; ++bb) {
876 t_nf(L) += t_base * t_rhs(L);
877 ++t_base;
878 ++t_nf;
879 }
880 for (; bb < nb_base_functions; ++bb)
881 ++t_base;
882 }
883
885}
886
887template <typename AssemblyDomainEleOp>
889 : public AssemblyDomainEleOp {
891 boost::shared_ptr<CommonData> common_data_ptr,
892 boost::shared_ptr<MatrixDouble> m_D_ptr);
893 MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &data);
894
895private:
896 boost::shared_ptr<CommonData> commonDataPtr;
897 boost::shared_ptr<MatrixDouble> mDPtr;
898};
899
900template <typename AssemblyDomainEleOp>
903 boost::shared_ptr<CommonData> common_data_ptr,
904 boost::shared_ptr<MatrixDouble> m_D_ptr)
906 commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {}
907
908template <typename AssemblyDomainEleOp>
909MoFEMErrorCode
911 EntitiesFieldData::EntData &data) {
913
914 const size_t nb_integration_pts = AssemblyDomainEleOp::getGaussPts().size2();
915 const size_t nb_base_functions = data.getN().size2();
916
917 auto t_res_c = getFTensor0FromVec(commonDataPtr->resC);
918
919 auto next = [&]() { ++t_res_c; };
920
921 auto t_w = AssemblyDomainEleOp::getFTensor0IntegrationWeight();
922 auto &nf = AssemblyDomainEleOp::locF;
923 auto t_base = data.getFTensor0N();
924 for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
925 const double alpha = AssemblyDomainEleOp::getMeasure() * t_w;
926 ++t_w;
927 const auto res = alpha * t_res_c;
928 next();
929
930 size_t bb = 0;
931 for (; bb != AssemblyDomainEleOp::nbRows; ++bb) {
932 nf[bb] += t_base * res;
933 ++t_base;
934 }
935 for (; bb < nb_base_functions; ++bb)
936 ++t_base;
937 }
938
940}
941
942template <int DIM, typename AssemblyDomainEleOp>
944 : public AssemblyDomainEleOp {
946 const std::string row_field_name, const std::string col_field_name,
947 boost::shared_ptr<CommonData> common_data_ptr,
948 boost::shared_ptr<MatrixDouble> m_D_ptr);
949 MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data,
950 EntitiesFieldData::EntData &col_data);
951
952private:
953 boost::shared_ptr<CommonData> commonDataPtr;
954 boost::shared_ptr<MatrixDouble> mDPtr;
955};
956
957template <int DIM, typename AssemblyDomainEleOp>
960 const std::string row_field_name, const std::string col_field_name,
961 boost::shared_ptr<CommonData> common_data_ptr,
962 boost::shared_ptr<MatrixDouble> m_D_ptr)
963 : AssemblyDomainEleOp(row_field_name, col_field_name,
964 AssemblyDomainEleOp::OPROWCOL),
965 commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {
966 AssemblyDomainEleOp::sYmm = false;
967}
968
969static inline auto get_mat_tensor_sym_dtensor_sym(size_t rr, MatrixDouble &mat,
972 &mat(3 * rr + 0, 0), &mat(3 * rr + 0, 1), &mat(3 * rr + 0, 2),
973 &mat(3 * rr + 1, 0), &mat(3 * rr + 1, 1), &mat(3 * rr + 1, 2),
974 &mat(3 * rr + 2, 0), &mat(3 * rr + 2, 1), &mat(3 * rr + 2, 2)};
975}
976
977static inline auto get_mat_tensor_sym_dtensor_sym(size_t rr, MatrixDouble &mat,
980 &mat(6 * rr + 0, 0), &mat(6 * rr + 0, 1), &mat(6 * rr + 0, 2),
981 &mat(6 * rr + 0, 3), &mat(6 * rr + 0, 4), &mat(6 * rr + 0, 5),
982 &mat(6 * rr + 1, 0), &mat(6 * rr + 1, 1), &mat(6 * rr + 1, 2),
983 &mat(6 * rr + 1, 3), &mat(6 * rr + 1, 4), &mat(6 * rr + 1, 5),
984 &mat(6 * rr + 2, 0), &mat(6 * rr + 2, 1), &mat(6 * rr + 2, 2),
985 &mat(6 * rr + 2, 3), &mat(6 * rr + 2, 4), &mat(6 * rr + 2, 5),
986 &mat(6 * rr + 3, 0), &mat(6 * rr + 3, 1), &mat(6 * rr + 3, 2),
987 &mat(6 * rr + 3, 3), &mat(6 * rr + 3, 4), &mat(6 * rr + 3, 5),
988 &mat(6 * rr + 4, 0), &mat(6 * rr + 4, 1), &mat(6 * rr + 4, 2),
989 &mat(6 * rr + 4, 3), &mat(6 * rr + 4, 4), &mat(6 * rr + 4, 5),
990 &mat(6 * rr + 5, 0), &mat(6 * rr + 5, 1), &mat(6 * rr + 5, 2),
991 &mat(6 * rr + 5, 3), &mat(6 * rr + 5, 4), &mat(6 * rr + 5, 5)};
992}
993
994template <int DIM, typename AssemblyDomainEleOp>
995MoFEMErrorCode
997 EntitiesFieldData::EntData &row_data,
998 EntitiesFieldData::EntData &col_data) {
1000
1001 FTensor::Index<'i', DIM> i;
1002 FTensor::Index<'j', DIM> j;
1003 FTensor::Index<'k', DIM> k;
1004 FTensor::Index<'l', DIM> l;
1005 constexpr auto size_symm = (DIM * (DIM + 1)) / 2;
1006 FTensor::Index<'L', size_symm> L;
1007 FTensor::Index<'O', size_symm> O;
1008
1009 auto &locMat = AssemblyDomainEleOp::locMat;
1010
1011 const auto nb_integration_pts = AssemblyDomainEleOp::getGaussPts().size2();
1012 const auto nb_row_base_functions = row_data.getN().size2();
1013
1014 auto t_res_flow_dstrain =
1015 getFTensor4DdgFromMat<DIM, DIM>(commonDataPtr->resFlowDstrain);
1016 auto t_res_flow_dplastic_strain =
1017 getFTensor4DdgFromMat<DIM, DIM>(commonDataPtr->resFlowDstrainDot);
1018 auto t_L = symm_L_tensor(FTensor::Number<DIM>());
1019
1020 auto next = [&]() {
1021 ++t_res_flow_dstrain;
1022 ++t_res_flow_dplastic_strain;
1023 };
1024
1025 auto t_w = AssemblyDomainEleOp::getFTensor0IntegrationWeight();
1026 auto t_row_base = row_data.getFTensor0N();
1027 for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
1028 double alpha = AssemblyDomainEleOp::getMeasure() * t_w;
1029 ++t_w;
1030
1032 t_res_mat(O, L) =
1033 alpha * (t_L(i, j, O) * ((t_res_flow_dplastic_strain(i, j, k, l) -
1034 t_res_flow_dstrain(i, j, k, l)) *
1035 t_L(k, l, L)));
1036 next();
1037
1038 size_t rr = 0;
1039 for (; rr != AssemblyDomainEleOp::nbRows / size_symm; ++rr) {
1040 auto t_mat = get_mat_tensor_sym_dtensor_sym(rr, locMat,
1042 auto t_col_base = col_data.getFTensor0N(gg, 0);
1043 for (size_t cc = 0; cc != AssemblyDomainEleOp::nbCols / size_symm; ++cc) {
1044 t_mat(O, L) += ((t_row_base * t_col_base) * t_res_mat(O, L));
1045 ++t_mat;
1046 ++t_col_base;
1047 }
1048
1049 ++t_row_base;
1050 }
1051
1052 for (; rr < nb_row_base_functions; ++rr)
1053 ++t_row_base;
1054 }
1055
1057}
1058
1059template <int DIM, typename AssemblyDomainEleOp>
1061 : public AssemblyDomainEleOp {
1063 const std::string row_field_name, const std::string col_field_name,
1064 boost::shared_ptr<CommonData> common_data_ptr,
1065 boost::shared_ptr<MatrixDouble> m_D_ptr);
1066 MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data,
1067 EntitiesFieldData::EntData &col_data);
1068
1069private:
1070 boost::shared_ptr<CommonData> commonDataPtr;
1071 boost::shared_ptr<MatrixDouble> mDPtr;
1072};
1073
1074template <int DIM, typename AssemblyDomainEleOp>
1076 : public AssemblyDomainEleOp {
1078 const std::string row_field_name, const std::string col_field_name,
1079 boost::shared_ptr<CommonData> common_data_ptr,
1080 boost::shared_ptr<MatrixDouble> m_D_ptr);
1081 MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data,
1082 EntitiesFieldData::EntData &col_data);
1083
1084private:
1085 boost::shared_ptr<CommonData> commonDataPtr;
1086 boost::shared_ptr<MatrixDouble> mDPtr;
1087};
1088
1089template <int DIM, typename AssemblyDomainEleOp>
1092 const std::string row_field_name, const std::string col_field_name,
1093 boost::shared_ptr<CommonData> common_data_ptr,
1094 boost::shared_ptr<MatrixDouble> m_D_ptr)
1095 : AssemblyDomainEleOp(row_field_name, col_field_name,
1096 DomainEleOp::OPROWCOL),
1097 commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {
1098 AssemblyDomainEleOp::sYmm = false;
1099}
1100
1101static inline auto get_mat_tensor_sym_dscalar(size_t rr, MatrixDouble &mat,
1104 &mat(3 * rr + 0, 0), &mat(3 * rr + 1, 0), &mat(3 * rr + 2, 0)};
1105}
1106
1107static inline auto get_mat_tensor_sym_dscalar(size_t rr, MatrixDouble &mat,
1110 &mat(6 * rr + 0, 0), &mat(6 * rr + 1, 0), &mat(6 * rr + 2, 0),
1111 &mat(6 * rr + 3, 0), &mat(6 * rr + 4, 0), &mat(6 * rr + 5, 0)};
1112}
1113
1114template <int DIM, typename AssemblyDomainEleOp>
1115MoFEMErrorCode
1117 EntitiesFieldData::EntData &row_data,
1118 EntitiesFieldData::EntData &col_data) {
1120
1121 FTensor::Index<'i', DIM> i;
1122 FTensor::Index<'j', DIM> j;
1123 constexpr auto size_symm = (DIM * (DIM + 1)) / 2;
1124 FTensor::Index<'L', size_symm> L;
1125
1126 const auto nb_integration_pts = AssemblyDomainEleOp::getGaussPts().size2();
1127 const size_t nb_row_base_functions = row_data.getN().size2();
1128 auto &locMat = AssemblyDomainEleOp::locMat;
1129
1130 auto t_res_flow_dtau =
1131 getFTensor2SymmetricFromMat<DIM>(commonDataPtr->resFlowDtau);
1132
1133 auto t_L = symm_L_tensor(FTensor::Number<DIM>());
1134
1135 auto next = [&]() { ++t_res_flow_dtau; };
1136
1137 auto t_w = AssemblyDomainEleOp::getFTensor0IntegrationWeight();
1138 auto t_row_base = row_data.getFTensor0N();
1139 for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
1140 double alpha = AssemblyDomainEleOp::getMeasure() * t_w;
1141 ++t_w;
1143 t_res_vec(L) = alpha * (t_res_flow_dtau(i, j) * t_L(i, j, L));
1144 next();
1145
1146 size_t rr = 0;
1147 for (; rr != AssemblyDomainEleOp::nbRows / size_symm; ++rr) {
1148 auto t_mat =
1150 auto t_col_base = col_data.getFTensor0N(gg, 0);
1151 for (size_t cc = 0; cc != AssemblyDomainEleOp::nbCols; cc++) {
1152 t_mat(L) += t_row_base * t_col_base * t_res_vec(L);
1153 ++t_mat;
1154 ++t_col_base;
1155 }
1156 ++t_row_base;
1157 }
1158 for (; rr != nb_row_base_functions; ++rr)
1159 ++t_row_base;
1160 }
1161
1163}
1164
1165template <int DIM, typename AssemblyDomainEleOp>
1167 : public AssemblyDomainEleOp {
1169 const std::string row_field_name, const std::string col_field_name,
1170 boost::shared_ptr<CommonData> common_data_ptr,
1171 boost::shared_ptr<MatrixDouble> mat_D_ptr);
1172 MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data,
1173 EntitiesFieldData::EntData &col_data);
1174
1175private:
1176 boost::shared_ptr<CommonData> commonDataPtr;
1177 boost::shared_ptr<MatrixDouble> mDPtr;
1178};
1179
1180template <int DIM, typename AssemblyDomainEleOp>
1183 const std::string row_field_name, const std::string col_field_name,
1184 boost::shared_ptr<CommonData> common_data_ptr,
1185 boost::shared_ptr<MatrixDouble> m_D_ptr)
1186 : AssemblyDomainEleOp(row_field_name, col_field_name,
1187 DomainEleOp::OPROWCOL),
1188 commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {
1189 AssemblyDomainEleOp::sYmm = false;
1190}
1191
1194 &mat(0, 0), &mat(0, 1), &mat(0, 2)};
1195}
1196
1199 &mat(0, 0), &mat(0, 1), &mat(0, 2), &mat(0, 3), &mat(0, 4), &mat(0, 5)};
1200}
1201
1202template <int DIM, typename AssemblyDomainEleOp>
1203MoFEMErrorCode
1205 EntitiesFieldData::EntData &row_data,
1206 EntitiesFieldData::EntData &col_data) {
1208
1209 FTensor::Index<'i', DIM> i;
1210 FTensor::Index<'j', DIM> j;
1211 constexpr auto size_symm = (DIM * (DIM + 1)) / 2;
1212 FTensor::Index<'L', size_symm> L;
1213
1214 const auto nb_integration_pts = AssemblyDomainEleOp::getGaussPts().size2();
1215 const auto nb_row_base_functions = row_data.getN().size2();
1216
1217 auto t_c_dstrain =
1218 getFTensor2SymmetricFromMat<SPACE_DIM>(commonDataPtr->resCdStrain);
1219 auto t_c_dplastic_strain =
1220 getFTensor2SymmetricFromMat<SPACE_DIM>(commonDataPtr->resCdPlasticStrain);
1221
1222 auto next = [&]() {
1223 ++t_c_dstrain;
1224 ++t_c_dplastic_strain;
1225 };
1226
1228
1229 auto t_w = AssemblyDomainEleOp::getFTensor0IntegrationWeight();
1230 auto t_row_base = row_data.getFTensor0N();
1231 for (auto gg = 0; gg != nb_integration_pts; ++gg) {
1232 const double alpha = AssemblyDomainEleOp::getMeasure() * t_w;
1233 ++t_w;
1234
1236 t_res_vec(L) =
1237 t_L(i, j, L) * (t_c_dplastic_strain(i, j) - t_c_dstrain(i, j));
1238 next();
1239
1240 auto t_mat = get_mat_scalar_dtensor_sym(AssemblyDomainEleOp::locMat,
1242 size_t rr = 0;
1243 for (; rr != AssemblyDomainEleOp::nbRows; ++rr) {
1244 const auto row_base = alpha * t_row_base;
1245 auto t_col_base = col_data.getFTensor0N(gg, 0);
1246 for (size_t cc = 0; cc != AssemblyDomainEleOp::nbCols / size_symm; cc++) {
1247 t_mat(L) += (row_base * t_col_base) * t_res_vec(L);
1248 ++t_mat;
1249 ++t_col_base;
1250 }
1251 ++t_row_base;
1252 }
1253 for (; rr != nb_row_base_functions; ++rr)
1254 ++t_row_base;
1255 }
1256
1258}
1259
1260template <typename AssemblyDomainEleOp>
1262 : public AssemblyDomainEleOp {
1264 const std::string row_field_name, const std::string col_field_name,
1265 boost::shared_ptr<CommonData> common_data_ptr);
1266 MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data,
1267 EntitiesFieldData::EntData &col_data);
1268
1269private:
1270 boost::shared_ptr<CommonData> commonDataPtr;
1271};
1272
1273template <typename AssemblyDomainEleOp>
1276 const std::string row_field_name, const std::string col_field_name,
1277 boost::shared_ptr<CommonData> common_data_ptr)
1278 : AssemblyDomainEleOp(row_field_name, col_field_name,
1279 DomainEleOp::OPROWCOL),
1280 commonDataPtr(common_data_ptr) {
1281 AssemblyDomainEleOp::sYmm = false;
1282}
1283
1284template <typename AssemblyDomainEleOp>
1285MoFEMErrorCode
1287 EntitiesFieldData::EntData &row_data,
1288 EntitiesFieldData::EntData &col_data) {
1290
1291 const auto nb_integration_pts = AssemblyDomainEleOp::getGaussPts().size2();
1292 const auto nb_row_base_functions = row_data.getN().size2();
1293
1294 auto t_res_c_dtau = getFTensor0FromVec(commonDataPtr->resCdTau);
1295 auto next = [&]() { ++t_res_c_dtau; };
1296
1297 auto t_w = AssemblyDomainEleOp::getFTensor0IntegrationWeight();
1298 auto t_row_base = row_data.getFTensor0N();
1299 for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
1300 const double alpha = AssemblyDomainEleOp::getMeasure() * t_w;
1301 ++t_w;
1302
1303 const auto res = alpha * (t_res_c_dtau);
1304 next();
1305
1306 auto mat_ptr = AssemblyDomainEleOp::locMat.data().begin();
1307 size_t rr = 0;
1308 for (; rr != AssemblyDomainEleOp::nbRows; ++rr) {
1309 auto t_col_base = col_data.getFTensor0N(gg, 0);
1310 for (size_t cc = 0; cc != AssemblyDomainEleOp::nbCols; ++cc) {
1311 *mat_ptr += t_row_base * t_col_base * res;
1312 ++t_col_base;
1313 ++mat_ptr;
1314 }
1315 ++t_row_base;
1316 }
1317 for (; rr < nb_row_base_functions; ++rr)
1318 ++t_row_base;
1319 }
1320
1322}
1323}; // namespace PlasticOps
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)
FTensor::Index< 'M', 3 > M
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:92
double iso_hardening_dtau(double tau, double H, double Qinf, double b_iso)
Definition plastic.cpp:78
constexpr auto size_symm
Definition plastic.cpp:42
double zeta
Viscous hardening.
Definition plastic.cpp:130
double cn0
Definition plastic.cpp:135
double iso_hardening(double tau, double H, double Qinf, double b_iso, double sigmaY)
Definition plastic.cpp:73
double cn1
Definition plastic.cpp:136