v0.16.3
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ADOLCPlasticity::OpCalculateStress< DIM, SMALL_STRAIN > Struct Template Reference
Inheritance diagram for ADOLCPlasticity::OpCalculateStress< DIM, SMALL_STRAIN >:
[legend]
Collaboration diagram for ADOLCPlasticity::OpCalculateStress< DIM, SMALL_STRAIN >:
[legend]

Public Member Functions

MoFEMErrorCode doWork (int side, EntityType type, DataForcesAndSourcesCore::EntData &data) override
 
- Public Member Functions inherited from ADOLCPlasticity::OpCalculateStressImpl< DIM, SMALL_STRAIN >
 OpCalculateStressImpl (MoFEM::Interface &m_field, boost::shared_ptr< CommonData > common_data_ptr, boost::shared_ptr< ClosestPointProjection > cp_ptr, bool calc_lhs)
 

Additional Inherited Members

- Protected Member Functions inherited from ADOLCPlasticity::OpCalculateStressImpl< DIM, SMALL_STRAIN >
MoFEMErrorCode getTags ()
 
MoFEMErrorCode setTagsData (const EntityHandle tet, const int nb_gauss_pts, const int nb_internal_variables)
 
- Protected Attributes inherited from ADOLCPlasticity::OpCalculateStressImpl< DIM, SMALL_STRAIN >
MoFEM::Interface & mField
 
boost::shared_ptr< CommonData > commonDataPtr
 
boost::shared_ptr< ClosestPointProjection > cpPtr
 
bool calcLhs
 
Tag thPlasticStrain
 
Tag thInternalVariables
 

Detailed Description

template<int DIM>
struct ADOLCPlasticity::OpCalculateStress< DIM, SMALL_STRAIN >

Definition at line 296 of file ADOLCPlasticity.cpp.

Member Function Documentation

◆ doWork()

template<int DIM>
MoFEMErrorCode ADOLCPlasticity::OpCalculateStress< DIM, SMALL_STRAIN >::doWork ( int  side,
EntityType  type,
DataForcesAndSourcesCore::EntData &  data 
)
override

Definition at line 620 of file ADOLCPlasticity.cpp.

621 {
623
624 auto do_work_impl = [this](auto commonDataPtr, auto cpPtr) {
626
627 int nb_gauss_pts = this->getGaussPts().size2();
628
629 int nb_internal_variables = cpPtr->nbInternalVariables;
630 auto tet = this->getNumeredEntFiniteElementPtr()->getEnt();
631 CHKERR this->setTagsData(tet, nb_gauss_pts, nb_internal_variables);
632
633 commonDataPtr->activeVariablesW.resize(
634 nb_gauss_pts, 12 + cpPtr->nbInternalVariables, false);
635 commonDataPtr->gradientW.resize(nb_gauss_pts,
636 12 + cpPtr->nbInternalVariables, false);
637 commonDataPtr->materialTangentOperator.resize(nb_gauss_pts, 36, false);
638 commonDataPtr->deltaGamma.resize(nb_gauss_pts);
639
640 FTensor::Index<'i', 3> i;
641 FTensor::Index<'j', 3> j;
642 FTensor::Index<'k', 3> k;
643 FTensor::Index<'l', 3> l;
644 FTensor::Index<'Z', 6> Z;
645 FTensor::Index<'Y', 6> Y;
646
647 // Code uses trial stress, until first solve of linear system of equations
648 int iter = 1;
649 if (this->getFEMethod()->snes_ctx != SnesMethod::CTX_SNESNONE) {
650 CHKERR SNESGetLinearSolveIterations(this->getFEMethod()->snes, &iter);
651 }
652
653 // b-bar
654 auto ave_tr_strain = calcAveStrain(
655 this->commonDataPtr->bBar, nb_gauss_pts,
656 getFTensor2FromMat<DIM, DIM>(commonDataPtr->gradAtGaussPts),
657 this->getFTensor0IntegrationWeight());
658
659 auto t_voight_stress_op = voight_to_stress_op();
660
661 auto t_grad = getFTensor2FromMat<DIM, DIM>(commonDataPtr->gradAtGaussPts);
662
663 auto t_Cep = getFTensor4DdgFromMat<3, 3>(
664 this->commonDataPtr->materialTangentOperator);
665 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
666
667 auto tmp_active =
668 getVectorAdaptor(&(commonDataPtr->activeVariablesW(gg, 0)),
669 12 + cpPtr->nbInternalVariables);
670 cpPtr->activeVariablesW.swap(tmp_active);
671 auto tmp_gradient = getVectorAdaptor(&(commonDataPtr->gradientW(gg, 0)),
672 12 + cpPtr->nbInternalVariables);
673 cpPtr->gradientW.swap(tmp_gradient);
674
675 auto t_voigt_strain =
676 calcStrain(commonDataPtr->bBar, ave_tr_strain, t_grad,
677 getFTensor1FromPtr<6>(&(cpPtr->activeVariablesW[6])));
678 ++t_grad;
679
680 // Copy plastic strains and internal variables from tags
681 auto copy_plastic_strain_and_internal_variables = [&]() {
683
684 // Get data stored on Tags
685 VectorAdaptor plastic_strain_tags =
686 VectorAdaptor(6, ublas::shallow_array_adaptor<double>(
687 6, &commonDataPtr->plasticStrainPtr[gg * 6]));
688 VectorAdaptor internal_variables_tags = VectorAdaptor(
689 nb_internal_variables,
690 ublas::shallow_array_adaptor<double>(
691 nb_internal_variables,
693 ->internalVariablesPtr[gg * nb_internal_variables]));
694
695 // Set values to closest point projection
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 }
716 CHKERR cpPtr->playW_NoHessian();
717 CHKERR cpPtr->playY_NoGradient();
718 double y = cpPtr->y;
719 cpPtr->deltaGamma = 0; // zero lagrange multiplier
720 if (iter > 0 && y > std::numeric_limits<double>::epsilon()) {
721 CHKERR cpPtr->solveClosestProjection();
722 }
723 commonDataPtr->deltaGamma[gg] = cpPtr->deltaGamma;
725 };
726
727 auto evaluate_consistent_tangent_matrix =
728 [&](auto &recalculate_elastic_tangent) {
730 if (recalculate_elastic_tangent)
731 CHKERR cpPtr->playW();
732
733 if (iter > 0 &&
734 cpPtr->deltaGamma > std::numeric_limits<double>::epsilon()) {
735
736 CHKERR cpPtr->consistentTangent();
737
738 auto &m = cpPtr->Cep;
739 // for generic case of non-associated plasticity consistent
740 // tangent matrix is non-symmetric
741 auto t_voight_cep =
743 &m(0, 0), &m(0, 1), &m(0, 2), &m(0, 3), &m(0, 4),
744 &m(0, 5),
745
746 &m(1, 0), &m(1, 1), &m(1, 2), &m(1, 3), &m(1, 4),
747 &m(1, 5),
748
749 &m(2, 0), &m(2, 1), &m(2, 2), &m(2, 3), &m(2, 4),
750 &m(2, 5),
751
752 &m(3, 0), &m(3, 1), &m(3, 2), &m(3, 3), &m(3, 4),
753 &m(3, 5),
754
755 &m(4, 0), &m(4, 1), &m(4, 2), &m(4, 3), &m(4, 4),
756 &m(4, 5),
757
758 &m(5, 0), &m(5, 1), &m(5, 2), &m(5, 3), &m(5, 4), &m(5, 5)
759
760 );
761
762 t_Cep(i, j, k, l) =
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
768 auto &m = cpPtr->C;
769 auto t_voight_cep =
771 &m(0, 0), &m(0, 1), &m(0, 2), &m(0, 3), &m(0, 4),
772 &m(0, 5),
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
780 &m(4, 4), &m(4, 5),
781
782 &m(5, 5));
783
784 t_Cep(i, j, k, l) =
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 // Always recalculate elastic tangent if first element
794 bool recalculate_elastic_tangent =
795 (this->getNinTheLoop() == 0) ? true : false;
796 CHKERR closest_point_projection(recalculate_elastic_tangent);
797 if (this->calcLhs)
798 CHKERR evaluate_consistent_tangent_matrix(recalculate_elastic_tangent);
799 }
800
801 auto calcs_stress_matrix = [&]() {
803 auto t_voight_stress_op = voight_to_stress_op();
804 commonDataPtr->stressMatrix.resize(commonDataPtr->gradientW.size1(), 6,
805 false);
806 auto t_stess =
807 getFTensor2SymmetricFromMat<3>(commonDataPtr->stressMatrix);
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 = [&]() {
819 auto t_voight_strain_op = voight_to_stress_op();
820 commonDataPtr->plasticStrainMatrix.resize(
821 commonDataPtr->activeVariablesW.size1(), 6, false);
822 auto t_plastic_strain =
823 getFTensor2SymmetricFromMat<3>(commonDataPtr->plasticStrainMatrix);
824 auto t_voight_plastic_strain =
825 commonDataPtr->getFTensor1PlasticStrainAtGaussPts();
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
840 CHKERR do_work_impl(this->commonDataPtr, this->cpPtr);
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
Definition Types.hpp:115
auto getVectorAdaptor(T1 ptr, const size_t n)
Get Vector adaptor.
Definition Templates.hpp:49
FTensor::Index< 'm', 3 > m
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.

The documentation for this struct was generated from the following file: