621 {
623
626
627 int nb_gauss_pts = this->getGaussPts().size2();
628
629 int nb_internal_variables =
cpPtr->nbInternalVariables;
630 auto tet = this->getNumeredEntFiniteElementPtr()->getEnt();
632
634 nb_gauss_pts, 12 +
cpPtr->nbInternalVariables,
false);
636 12 +
cpPtr->nbInternalVariables,
false);
637 commonDataPtr->materialTangentOperator.resize(nb_gauss_pts, 36,
false);
639
646
647
648 int iter = 1;
650 CHKERR SNESGetLinearSolveIterations(this->getFEMethod()->snes, &iter);
651 }
652
653
657 this->getFTensor0IntegrationWeight());
658
660
661 auto t_grad = getFTensor2FromMat<DIM, DIM>(
commonDataPtr->gradAtGaussPts);
662
663 auto t_Cep = getFTensor4DdgFromMat<3, 3>(
665 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
666
667 auto tmp_active =
669 12 +
cpPtr->nbInternalVariables);
670 cpPtr->activeVariablesW.swap(tmp_active);
672 12 +
cpPtr->nbInternalVariables);
673 cpPtr->gradientW.swap(tmp_gradient);
674
675 auto t_voigt_strain =
677 getFTensor1FromPtr<6>(&(
cpPtr->activeVariablesW[6])));
678 ++t_grad;
679
680
681 auto copy_plastic_strain_and_internal_variables = [&]() {
683
684
689 nb_internal_variables,
690 ublas::shallow_array_adaptor<double>(
691 nb_internal_variables,
693 ->internalVariablesPtr[gg * nb_internal_variables]));
694
695
696 cpPtr->plasticStrain0.resize(6,
false);
697 noalias(
cpPtr->plasticStrain0) = plastic_strain_tags;
698 cpPtr->internalVariables0.resize(nb_internal_variables,
false);
699 noalias(
cpPtr->internalVariables0) = internal_variables_tags;
700
701 auto cp_plastic_strain =
cpPtr->getPlasticStrain();
702 auto cp_internal_variables =
cpPtr->getInternalVariables();
703 noalias(cp_plastic_strain) = plastic_strain_tags;
704 noalias(cp_internal_variables) = internal_variables_tags;
706 };
707
708 CHKERR copy_plastic_strain_and_internal_variables();
709
710 auto closest_point_projection = [&](auto &recalculate_elastic_tangent) {
714 CHKERR cpPtr->setParams(
t, recalculate_elastic_tangent);
715 }
719 cpPtr->deltaGamma = 0;
720 if (iter > 0 && y > std::numeric_limits<double>::epsilon()) {
722 }
725 };
726
727 auto evaluate_consistent_tangent_matrix =
728 [&](auto &recalculate_elastic_tangent) {
730 if (recalculate_elastic_tangent)
732
733 if (iter > 0 &&
734 cpPtr->deltaGamma > std::numeric_limits<double>::epsilon()) {
735
737
739
740
741 auto t_voight_cep =
743 &
m(0, 0), &
m(0, 1), &
m(0, 2), &
m(0, 3), &
m(0, 4),
745
746 &
m(1, 0), &
m(1, 1), &
m(1, 2), &
m(1, 3), &
m(1, 4),
748
749 &
m(2, 0), &
m(2, 1), &
m(2, 2), &
m(2, 3), &
m(2, 4),
751
752 &
m(3, 0), &
m(3, 1), &
m(3, 2), &
m(3, 3), &
m(3, 4),
754
755 &
m(4, 0), &
m(4, 1), &
m(4, 2), &
m(4, 3), &
m(4, 4),
757
758 &
m(5, 0), &
m(5, 1), &
m(5, 2), &
m(5, 3), &
m(5, 4), &
m(5, 5)
759
760 );
761
763 t_voight_stress_op(
i,
j, Z) *
764 (t_voight_cep(Z, Y) * t_voight_stress_op(
k,
l, Y));
765
766 } else {
767
769 auto t_voight_cep =
771 &
m(0, 0), &
m(0, 1), &
m(0, 2), &
m(0, 3), &
m(0, 4),
773
774 &
m(1, 1), &
m(1, 2), &
m(1, 3), &
m(1, 4), &
m(1, 5),
775
776 &
m(2, 2), &
m(2, 3), &
m(2, 4), &
m(2, 5),
777
778 &
m(3, 3), &
m(3, 4), &
m(3, 5),
779
781
783
785 t_voight_stress_op(
i,
j, Z) *
786 (t_voight_cep(Z, Y) * t_voight_stress_op(
k,
l, Y));
787 }
788
789 ++t_Cep;
791 };
792
793
794 bool recalculate_elastic_tangent =
795 (this->getNinTheLoop() == 0) ? true : false;
796 CHKERR closest_point_projection(recalculate_elastic_tangent);
798 CHKERR evaluate_consistent_tangent_matrix(recalculate_elastic_tangent);
799 }
800
801 auto calcs_stress_matrix = [&]() {
805 false);
806 auto t_stess =
808 auto t_voight_stress =
commonDataPtr->getFTensor1StressAtGaussPts();
809 for (
auto gg = 0; gg !=
commonDataPtr->gradientW.size1(); ++gg) {
810 t_stess(
i,
j) = t_voight_stress_op(
i,
j, Z) * t_voight_stress(Z);
811 ++t_voight_stress;
812 ++t_stess;
813 }
815 };
816
817 auto calcs_plastic_strain_matrix = [&]() {
822 auto t_plastic_strain =
823 getFTensor2SymmetricFromMat<3>(
commonDataPtr->plasticStrainMatrix);
824 auto t_voight_plastic_strain =
826 for (
auto gg = 0; gg !=
commonDataPtr->activeVariablesW.size1(); ++gg) {
827 t_plastic_strain(
i,
j) =
828 t_voight_strain_op(
i,
j, Z) * t_voight_plastic_strain(Z);
829 ++t_voight_plastic_strain;
830 ++t_plastic_strain;
831 }
833 };
834
835 CHKERR calcs_stress_matrix();
836 CHKERR calcs_plastic_strain_matrix();
838 };
839
841
843}
Vec t
Removal: the ring edge.
#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.
double calcAveStrain(bool b_bar, const int nb_gauss_pts, FTensor::Tensor2< T1, DIM1, DIM2 > &&t_grad, FTensor::Tensor0< T2 > &&t_w)
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.
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
@ CTX_SNESNONE
No specific SNES context.