377 DataForcesAndSourcesCore::EntData &data) {
380 auto do_work_impl = [
this](
auto commonDataPtr,
auto cpPtr) {
383 int nb_gauss_pts = this->getGaussPts().size2();
385 int nb_internal_variables = cpPtr->nbInternalVariables;
386 auto tet = this->getNumeredEntFiniteElementPtr()->getEnt();
387 CHKERR this->setTagsData(tet, nb_gauss_pts, nb_internal_variables);
389 commonDataPtr->activeVariablesW.resize(
390 nb_gauss_pts, 12 + cpPtr->nbInternalVariables,
false);
391 commonDataPtr->gradientW.resize(nb_gauss_pts,
392 12 + cpPtr->nbInternalVariables,
false);
393 commonDataPtr->materialTangentOperator.resize(36, nb_gauss_pts,
false);
394 commonDataPtr->deltaGamma.resize(nb_gauss_pts);
406 CHKERR SNESGetLinearSolveIterations(this->getFEMethod()->snes, &iter);
409 double ave_tr_strain = 0;
414 getFTensor2SymmetricFromMat<DIM>(commonDataPtr->gradAtGaussPts);
417 getFTensor4DdgFromMat<3, 3, 1>(commonDataPtr->materialTangentOperator);
418 for (
auto gg = 0; gg != nb_gauss_pts; ++gg) {
422 12 + cpPtr->nbInternalVariables);
423 cpPtr->activeVariablesW.swap(tmp_active);
425 12 + cpPtr->nbInternalVariables);
426 this->cpPtr->gradientW.swap(tmp_gradient);
428 auto t_voigt_strain =
429 calcStrain(commonDataPtr->bBar, ave_tr_strain, t_grad,
430 getFTensor1FromPtr<6>(&(cpPtr->activeVariablesW[6])));
434 auto copy_plastic_strain_and_internal_variables = [&]() {
440 6, &commonDataPtr->plasticStrainPtr[gg * 6]));
442 nb_internal_variables,
443 ublas::shallow_array_adaptor<double>(
444 nb_internal_variables,
446 ->internalVariablesPtr[gg * nb_internal_variables]));
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;
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;
461 CHKERR copy_plastic_strain_and_internal_variables();
463 auto closest_point_projection = [&](
auto &recalculate_elastic_tangent) {
467 CHKERR cpPtr->setParams(
t, recalculate_elastic_tangent);
469 CHKERR cpPtr->playW_NoHessian();
470 CHKERR cpPtr->playY_NoGradient();
472 cpPtr->deltaGamma = 0;
473 if (iter > 0 && y > std::numeric_limits<double>::epsilon()) {
474 CHKERR cpPtr->solveClosestProjection();
476 commonDataPtr->deltaGamma[gg] = cpPtr->deltaGamma;
480 auto evaluate_consistent_tangent_matrix =
481 [&](
auto &recalculate_elastic_tangent) {
483 if (recalculate_elastic_tangent)
487 cpPtr->deltaGamma > std::numeric_limits<double>::epsilon()) {
489 CHKERR cpPtr->consistentTangent();
491 auto &
m = cpPtr->Cep;
496 &
m(0, 0), &
m(0, 1), &
m(0, 2), &
m(0, 3), &
m(0, 4),
499 &
m(1, 0), &
m(1, 1), &
m(1, 2), &
m(1, 3), &
m(1, 4),
502 &
m(2, 0), &
m(2, 1), &
m(2, 2), &
m(2, 3), &
m(2, 4),
505 &
m(3, 0), &
m(3, 1), &
m(3, 2), &
m(3, 3), &
m(3, 4),
508 &
m(4, 0), &
m(4, 1), &
m(4, 2), &
m(4, 3), &
m(4, 4),
511 &
m(5, 0), &
m(5, 1), &
m(5, 2), &
m(5, 3), &
m(5, 4), &
m(5, 5)
516 t_voight_stress_op(
i,
j, Z) *
517 (t_voight_cep(Z, Y) * t_voight_stress_op(
k,
l, Y));
524 &
m(0, 0), &
m(0, 1), &
m(0, 2), &
m(0, 3), &
m(0, 4),
527 &
m(1, 1), &
m(1, 2), &
m(1, 3), &
m(1, 4), &
m(1, 5),
529 &
m(2, 2), &
m(2, 3), &
m(2, 4), &
m(2, 5),
531 &
m(3, 3), &
m(3, 4), &
m(3, 5),
538 t_voight_stress_op(
i,
j, Z) *
539 (t_voight_cep(Z, Y) * t_voight_stress_op(
k,
l, Y));
547 bool recalculate_elastic_tangent =
548 (this->getNinTheLoop() == 0) ?
true :
false;
549 CHKERR closest_point_projection(recalculate_elastic_tangent);
551 CHKERR evaluate_consistent_tangent_matrix(recalculate_elastic_tangent);
554 auto calcs_stress_matrix = [&]() {
557 commonDataPtr->stressMatrix.resize(
558 6, this->commonDataPtr->gradientW.size1(),
false);
560 getFTensor2SymmetricFromMat<3>(commonDataPtr->stressMatrix);
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);
570 auto calcs_plastic_strain_matrix = [&]() {
573 commonDataPtr->plasticStrainMatrix.resize(
574 6, commonDataPtr->activeVariablesW.size1(),
false);
575 auto t_plastic_strain =
576 getFTensor2SymmetricFromMat<3>(commonDataPtr->plasticStrainMatrix);
577 auto t_voight_plastic_strain =
578 commonDataPtr->getFTensor1PlasticStrainAtGaussPts();
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;
588 CHKERR calcs_stress_matrix();
589 CHKERR calcs_plastic_strain_matrix();
593 CHKERR do_work_impl(this->commonDataPtr, this->cpPtr);
601 DataForcesAndSourcesCore::EntData &data) {
604 auto do_work_impl = [
this](
auto commonDataPtr,
auto cpPtr) {
607 int nb_gauss_pts = this->getGaussPts().size2();
609 int nb_internal_variables = cpPtr->nbInternalVariables;
610 auto tet = this->getNumeredEntFiniteElementPtr()->getEnt();
611 CHKERR this->setTagsData(tet, nb_gauss_pts, nb_internal_variables);
613 commonDataPtr->activeVariablesW.resize(
614 nb_gauss_pts, 12 + cpPtr->nbInternalVariables,
false);
615 commonDataPtr->gradientW.resize(nb_gauss_pts,
616 12 + cpPtr->nbInternalVariables,
false);
617 commonDataPtr->materialTangentOperator.resize(36, nb_gauss_pts,
false);
618 commonDataPtr->deltaGamma.resize(nb_gauss_pts);
630 CHKERR SNESGetLinearSolveIterations(this->getFEMethod()->snes, &iter);
635 this->commonDataPtr->bBar, nb_gauss_pts,
636 getFTensor2FromMat<DIM, DIM>(commonDataPtr->gradAtGaussPts),
637 this->getFTensor0IntegrationWeight());
641 auto t_grad = getFTensor2FromMat<DIM, DIM>(commonDataPtr->gradAtGaussPts);
643 auto t_Cep = getFTensor4DdgFromMat<3, 3, 1>(
644 this->commonDataPtr->materialTangentOperator);
645 for (
auto gg = 0; gg != nb_gauss_pts; ++gg) {
649 12 + cpPtr->nbInternalVariables);
650 cpPtr->activeVariablesW.swap(tmp_active);
652 12 + cpPtr->nbInternalVariables);
653 cpPtr->gradientW.swap(tmp_gradient);
655 auto t_voigt_strain =
656 calcStrain(commonDataPtr->bBar, ave_tr_strain, t_grad,
657 getFTensor1FromPtr<6>(&(cpPtr->activeVariablesW[6])));
661 auto copy_plastic_strain_and_internal_variables = [&]() {
667 6, &commonDataPtr->plasticStrainPtr[gg * 6]));
669 nb_internal_variables,
670 ublas::shallow_array_adaptor<double>(
671 nb_internal_variables,
673 ->internalVariablesPtr[gg * nb_internal_variables]));
676 cpPtr->plasticStrain0.resize(6,
false);
677 noalias(cpPtr->plasticStrain0) = plastic_strain_tags;
678 cpPtr->internalVariables0.resize(nb_internal_variables,
false);
679 noalias(cpPtr->internalVariables0) = internal_variables_tags;
681 auto cp_plastic_strain = cpPtr->getPlasticStrain();
682 auto cp_internal_variables = cpPtr->getInternalVariables();
683 noalias(cp_plastic_strain) = plastic_strain_tags;
684 noalias(cp_internal_variables) = internal_variables_tags;
688 CHKERR copy_plastic_strain_and_internal_variables();
690 auto closest_point_projection = [&](
auto &recalculate_elastic_tangent) {
694 CHKERR cpPtr->setParams(
t, recalculate_elastic_tangent);
696 CHKERR cpPtr->playW_NoHessian();
697 CHKERR cpPtr->playY_NoGradient();
699 cpPtr->deltaGamma = 0;
700 if (iter > 0 && y > std::numeric_limits<double>::epsilon()) {
701 CHKERR cpPtr->solveClosestProjection();
703 commonDataPtr->deltaGamma[gg] = cpPtr->deltaGamma;
707 auto evaluate_consistent_tangent_matrix =
708 [&](
auto &recalculate_elastic_tangent) {
710 if (recalculate_elastic_tangent)
714 cpPtr->deltaGamma > std::numeric_limits<double>::epsilon()) {
716 CHKERR cpPtr->consistentTangent();
718 auto &
m = cpPtr->Cep;
723 &
m(0, 0), &
m(0, 1), &
m(0, 2), &
m(0, 3), &
m(0, 4),
726 &
m(1, 0), &
m(1, 1), &
m(1, 2), &
m(1, 3), &
m(1, 4),
729 &
m(2, 0), &
m(2, 1), &
m(2, 2), &
m(2, 3), &
m(2, 4),
732 &
m(3, 0), &
m(3, 1), &
m(3, 2), &
m(3, 3), &
m(3, 4),
735 &
m(4, 0), &
m(4, 1), &
m(4, 2), &
m(4, 3), &
m(4, 4),
738 &
m(5, 0), &
m(5, 1), &
m(5, 2), &
m(5, 3), &
m(5, 4), &
m(5, 5)
743 t_voight_stress_op(
i,
j, Z) *
744 (t_voight_cep(Z, Y) * t_voight_stress_op(
k,
l, Y));
751 &
m(0, 0), &
m(0, 1), &
m(0, 2), &
m(0, 3), &
m(0, 4),
754 &
m(1, 1), &
m(1, 2), &
m(1, 3), &
m(1, 4), &
m(1, 5),
756 &
m(2, 2), &
m(2, 3), &
m(2, 4), &
m(2, 5),
758 &
m(3, 3), &
m(3, 4), &
m(3, 5),
765 t_voight_stress_op(
i,
j, Z) *
766 (t_voight_cep(Z, Y) * t_voight_stress_op(
k,
l, Y));
774 bool recalculate_elastic_tangent =
775 (this->getNinTheLoop() == 0) ?
true :
false;
776 CHKERR closest_point_projection(recalculate_elastic_tangent);
778 CHKERR evaluate_consistent_tangent_matrix(recalculate_elastic_tangent);
781 auto calcs_stress_matrix = [&]() {
784 commonDataPtr->stressMatrix.resize(6, commonDataPtr->gradientW.size1(),
787 getFTensor2SymmetricFromMat<3>(commonDataPtr->stressMatrix);
788 auto t_voight_stress = commonDataPtr->getFTensor1StressAtGaussPts();
789 for (
auto gg = 0; gg != commonDataPtr->gradientW.size1(); ++gg) {
790 t_stess(
i,
j) = t_voight_stress_op(
i,
j, Z) * t_voight_stress(Z);
797 auto calcs_plastic_strain_matrix = [&]() {
800 commonDataPtr->plasticStrainMatrix.resize(
801 6, commonDataPtr->activeVariablesW.size1(),
false);
802 auto t_plastic_strain =
803 getFTensor2SymmetricFromMat<3>(commonDataPtr->plasticStrainMatrix);
804 auto t_voight_plastic_strain =
805 commonDataPtr->getFTensor1PlasticStrainAtGaussPts();
806 for (
auto gg = 0; gg != commonDataPtr->activeVariablesW.size1(); ++gg) {
807 t_plastic_strain(
i,
j) =
808 t_voight_strain_op(
i,
j, Z) * t_voight_plastic_strain(Z);
809 ++t_voight_plastic_strain;
815 CHKERR calcs_stress_matrix();
816 CHKERR calcs_plastic_strain_matrix();
820 CHKERR do_work_impl(this->commonDataPtr, this->cpPtr);