601 {
603
606
607 int nb_gauss_pts = this->getGaussPts().size2();
608
609 int nb_internal_variables =
cpPtr->nbInternalVariables;
610 auto tet = this->getNumeredEntFiniteElementPtr()->getEnt();
612
614 nb_gauss_pts, 12 +
cpPtr->nbInternalVariables,
false);
616 12 +
cpPtr->nbInternalVariables,
false);
617 commonDataPtr->materialTangentOperator.resize(36, nb_gauss_pts,
false);
619
626
627
628 int iter = 1;
630 CHKERR SNESGetLinearSolveIterations(this->getFEMethod()->snes, &iter);
631 }
632
633
637 this->getFTensor0IntegrationWeight());
638
640
642
645 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
646
647 auto tmp_active =
649 12 +
cpPtr->nbInternalVariables);
650 cpPtr->activeVariablesW.swap(tmp_active);
652 12 +
cpPtr->nbInternalVariables);
653 cpPtr->gradientW.swap(tmp_gradient);
654
655 auto t_voigt_strain =
658 ++t_grad;
659
660
661 auto copy_plastic_strain_and_internal_variables = [&]() {
663
664
669 nb_internal_variables,
670 ublas::shallow_array_adaptor<double>(
671 nb_internal_variables,
673 ->internalVariablesPtr[gg * nb_internal_variables]));
674
675
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;
680
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;
686 };
687
688 CHKERR copy_plastic_strain_and_internal_variables();
689
690 auto closest_point_projection = [&](auto &recalculate_elastic_tangent) {
694 CHKERR cpPtr->setParams(
t, recalculate_elastic_tangent);
695 }
699 cpPtr->deltaGamma = 0;
700 if (iter > 0 && y > std::numeric_limits<double>::epsilon()) {
702 }
705 };
706
707 auto evaluate_consistent_tangent_matrix =
708 [&](auto &recalculate_elastic_tangent) {
710 if (recalculate_elastic_tangent)
712
713 if (iter > 0 &&
714 cpPtr->deltaGamma > std::numeric_limits<double>::epsilon()) {
715
717
719
720
721 auto t_voight_cep =
723 &
m(0, 0), &
m(0, 1), &
m(0, 2), &
m(0, 3), &
m(0, 4),
725
726 &
m(1, 0), &
m(1, 1), &
m(1, 2), &
m(1, 3), &
m(1, 4),
728
729 &
m(2, 0), &
m(2, 1), &
m(2, 2), &
m(2, 3), &
m(2, 4),
731
732 &
m(3, 0), &
m(3, 1), &
m(3, 2), &
m(3, 3), &
m(3, 4),
734
735 &
m(4, 0), &
m(4, 1), &
m(4, 2), &
m(4, 3), &
m(4, 4),
737
738 &
m(5, 0), &
m(5, 1), &
m(5, 2), &
m(5, 3), &
m(5, 4), &
m(5, 5)
739
740 );
741
743 t_voight_stress_op(
i,
j, Z) *
744 (t_voight_cep(Z, Y) * t_voight_stress_op(
k,
l, Y));
745
746 } else {
747
749 auto t_voight_cep =
751 &
m(0, 0), &
m(0, 1), &
m(0, 2), &
m(0, 3), &
m(0, 4),
753
754 &
m(1, 1), &
m(1, 2), &
m(1, 3), &
m(1, 4), &
m(1, 5),
755
756 &
m(2, 2), &
m(2, 3), &
m(2, 4), &
m(2, 5),
757
758 &
m(3, 3), &
m(3, 4), &
m(3, 5),
759
761
763
765 t_voight_stress_op(
i,
j, Z) *
766 (t_voight_cep(Z, Y) * t_voight_stress_op(
k,
l, Y));
767 }
768
769 ++t_Cep;
771 };
772
773
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);
779 }
780
781 auto calcs_stress_matrix = [&]() {
785 false);
786 auto t_stess =
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);
791 ++t_voight_stress;
792 ++t_stess;
793 }
795 };
796
797 auto calcs_plastic_strain_matrix = [&]() {
802 auto t_plastic_strain =
804 auto t_voight_plastic_strain =
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;
810 ++t_plastic_strain;
811 }
813 };
814
815 CHKERR calcs_stress_matrix();
816 CHKERR calcs_plastic_strain_matrix();
818 };
819
821
823}
#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.
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.
FTensor::Tensor2< FTensor::PackPtr< double *, 1 >, Tensor_Dim1, Tensor_Dim2 > getFTensor2FromMat(MatrixDouble &data)
Get tensor rank 2 (matrix) 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