377 {
379
382
383 int nb_gauss_pts = this->getGaussPts().size2();
384
385 int nb_internal_variables =
cpPtr->nbInternalVariables;
386 auto tet = this->getNumeredEntFiniteElementPtr()->getEnt();
388
390 nb_gauss_pts, 12 +
cpPtr->nbInternalVariables,
false);
392 12 +
cpPtr->nbInternalVariables,
false);
393 commonDataPtr->materialTangentOperator.resize(36, nb_gauss_pts,
false);
395
402
403
404 int iter = 1;
406 CHKERR SNESGetLinearSolveIterations(this->getFEMethod()->snes, &iter);
407 }
408
409 double ave_tr_strain = 0;
410
412
413 auto t_grad =
415
416 auto t_Cep =
418 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
419
420 auto tmp_active =
422 12 +
cpPtr->nbInternalVariables);
423 cpPtr->activeVariablesW.swap(tmp_active);
425 12 +
cpPtr->nbInternalVariables);
426 this->
cpPtr->gradientW.swap(tmp_gradient);
427
428 auto t_voigt_strain =
431 ++t_grad;
432
433
434 auto copy_plastic_strain_and_internal_variables = [&]() {
436
437
442 nb_internal_variables,
443 ublas::shallow_array_adaptor<double>(
444 nb_internal_variables,
446 ->internalVariablesPtr[gg * nb_internal_variables]));
447
448
449 cpPtr->plasticStrain0.resize(6,
false);
450 noalias(
cpPtr->plasticStrain0) = plastic_strain_tags;
451 cpPtr->internalVariables0.resize(nb_internal_variables,
false);
452 noalias(
cpPtr->internalVariables0) = internal_variables_tags;
453
454 auto cp_plastic_strain =
cpPtr->getPlasticStrain();
455 auto cp_internal_variables =
cpPtr->getInternalVariables();
456 noalias(cp_plastic_strain) = plastic_strain_tags;
457 noalias(cp_internal_variables) = internal_variables_tags;
459 };
460
461 CHKERR copy_plastic_strain_and_internal_variables();
462
463 auto closest_point_projection = [&](auto &recalculate_elastic_tangent) {
467 CHKERR cpPtr->setParams(
t, recalculate_elastic_tangent);
468 }
472 cpPtr->deltaGamma = 0;
473 if (iter > 0 && y > std::numeric_limits<double>::epsilon()) {
475 }
478 };
479
480 auto evaluate_consistent_tangent_matrix =
481 [&](auto &recalculate_elastic_tangent) {
483 if (recalculate_elastic_tangent)
485
486 if (iter > 0 &&
487 cpPtr->deltaGamma > std::numeric_limits<double>::epsilon()) {
488
490
492
493
494 auto t_voight_cep =
496 &
m(0, 0), &
m(0, 1), &
m(0, 2), &
m(0, 3), &
m(0, 4),
498
499 &
m(1, 0), &
m(1, 1), &
m(1, 2), &
m(1, 3), &
m(1, 4),
501
502 &
m(2, 0), &
m(2, 1), &
m(2, 2), &
m(2, 3), &
m(2, 4),
504
505 &
m(3, 0), &
m(3, 1), &
m(3, 2), &
m(3, 3), &
m(3, 4),
507
508 &
m(4, 0), &
m(4, 1), &
m(4, 2), &
m(4, 3), &
m(4, 4),
510
511 &
m(5, 0), &
m(5, 1), &
m(5, 2), &
m(5, 3), &
m(5, 4), &
m(5, 5)
512
513 );
514
516 t_voight_stress_op(
i,
j, Z) *
517 (t_voight_cep(Z, Y) * t_voight_stress_op(
k,
l, Y));
518
519 } else {
520
522 auto t_voight_cep =
524 &
m(0, 0), &
m(0, 1), &
m(0, 2), &
m(0, 3), &
m(0, 4),
526
527 &
m(1, 1), &
m(1, 2), &
m(1, 3), &
m(1, 4), &
m(1, 5),
528
529 &
m(2, 2), &
m(2, 3), &
m(2, 4), &
m(2, 5),
530
531 &
m(3, 3), &
m(3, 4), &
m(3, 5),
532
534
536
538 t_voight_stress_op(
i,
j, Z) *
539 (t_voight_cep(Z, Y) * t_voight_stress_op(
k,
l, Y));
540 }
541
542 ++t_Cep;
544 };
545
546
547 bool recalculate_elastic_tangent =
548 (this->getNinTheLoop() == 0) ? true : false;
549 CHKERR closest_point_projection(recalculate_elastic_tangent);
550
551 CHKERR evaluate_consistent_tangent_matrix(recalculate_elastic_tangent);
552 }
553
554 auto calcs_stress_matrix = [&]() {
559 auto t_stess =
561 auto t_voight_stress =
commonDataPtr->getFTensor1StressAtGaussPts();
562 for (
auto gg = 0; gg !=
commonDataPtr->gradientW.size1(); ++gg) {
563 t_stess(
i,
j) = t_voight_stress_op(
i,
j, Z) * t_voight_stress(Z);
564 ++t_voight_stress;
565 ++t_stess;
566 }
568 };
569
570 auto calcs_plastic_strain_matrix = [&]() {
575 auto t_plastic_strain =
577 auto t_voight_plastic_strain =
579 for (
auto gg = 0; gg !=
commonDataPtr->activeVariablesW.size1(); ++gg) {
580 t_plastic_strain(
i,
j) =
581 t_voight_strain_op(
i,
j, Z) * t_voight_plastic_strain(Z);
582 ++t_voight_plastic_strain;
583 ++t_plastic_strain;
584 }
586 };
587
588 CHKERR calcs_stress_matrix();
589 CHKERR calcs_plastic_strain_matrix();
591 };
592
594
596}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
FTensor::Dg< double, 3, 6 > voight_to_stress_op()
Op convert Vight stress vector to stress tensor.
FTensor::Tensor1< T2, DIM3 > calcStrain(bool b_bar, double ave_tr_strain, FTensor::Tensor2< T1, DIM1, DIM2 > &t_grad, FTensor::Tensor1< T2, DIM3 > &&t_voight_strain)
VectorShallowArrayAdaptor< double > VectorAdaptor
auto getVectorAdaptor(T1 ptr, const size_t n)
Get Vector adaptor.
static FTensor::Ddg< FTensor::PackPtr< T *, 1 >, Tensor_Dim01, Tensor_Dim23 > getFTensor4DdgFromMat(ublas::matrix< T, L, A > &data)
Get symmetric tensor rank 4 on first two and last indices from form data matrix.
static auto getFTensor2SymmetricFromMat(ublas::matrix< T, L, A > &data)
Get symmetric tensor rank 2 (matrix) form data matrix.
FTensor::Tensor1< FTensor::PackPtr< double *, S >, DIM > getFTensor1FromPtr(double *ptr)
Make Tensor1 from pointer.
constexpr double t
plate stiffness
FTensor::Index< 'm', 3 > m
boost::shared_ptr< CommonData > commonDataPtr
MoFEMErrorCode setTagsData(const EntityHandle tet, const int nb_gauss_pts, const int nb_internal_variables)
boost::shared_ptr< ClosestPointProjection > cpPtr