698 auto dm =
simple->getDM();
699 auto time_scale = boost::make_shared<TimeScale>();
703 auto create_post_proc_fe = [dm,
this,
simple]() {
707 auto post_proc_ele_domain = [
this](
auto &pip_domain,
auto &fe_name) {
710 pip_domain, {
H1,
HDIV},
"GEOMETRY");
715 auto grad_ptr = boost::make_shared<MatrixDouble>();
716 pip_domain.push_back(
726 pip_domain.push_back(op_this);
730 auto fe_physics = op_this->getThisFEPtr();
732 auto evaluate_stress_on_physical_element = [&]() {
734 fe_physics->getRuleHook =
cpPtr->integrationRule;
736 fe_physics->getOpPtrVector(), {H1});
737 auto common_data_ptr =
738 boost::make_shared<ADOLCPlasticity::CommonData>();
741 fe_physics->getOpPtrVector().push_back(
743 "U", common_data_ptr->getGardAtGaussPtsPtr()));
746 "ADOLCMAT", Sev::noisy);
747 fe_physics->getOpPtrVector().push_back(
748 getRawPtrOpCalculateStress<SPACE_DIM>(
mField, common_data_ptr,
750 return common_data_ptr;
753 auto dg_projection_froward_and_back = [&](
auto &common_data_ptr) {
756 auto entity_data_l2 =
757 boost::make_shared<EntitiesFieldData>(MBENTITYSET);
759 boost::make_shared<MatrixDouble>();
764 auto coeffs_ptr_stress = boost::make_shared<MatrixDouble>();
767 common_data_ptr->getStressMatrixPtr(), coeffs_ptr_stress, mass_ptr,
770 auto coeffs_ptr_plastic_strain = boost::make_shared<MatrixDouble>();
772 common_data_ptr->getPlasticStrainMatrixPtr(),
773 coeffs_ptr_plastic_strain, mass_ptr, entity_data_l2,
approxBase,
779 common_data_ptr->getStressMatrixPtr(), coeffs_ptr_stress,
782 common_data_ptr->getPlasticStrainMatrixPtr(),
783 coeffs_ptr_plastic_strain, entity_data_l2,
approxBase,
L2));
786 auto common_data_ptr = evaluate_stress_on_physical_element();
787 dg_projection_froward_and_back(common_data_ptr);
789 return boost::make_tuple(grad_ptr, common_data_ptr->getStressMatrixPtr(),
790 common_data_ptr->getPlasticStrainMatrixPtr());
796 auto add_post_proc_map = [&](
auto post_proc_fe,
auto u_ptr,
auto grad_ptr,
797 auto stress_ptr,
auto plastic_strain_ptr,
798 auto contact_stress_ptr,
auto X_ptr) {
800 post_proc_fe->getOpPtrVector().push_back(
802 new OpPPMapSPACE_DIM(
804 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
808 {{
"U", u_ptr}, {
"GEOMETRY", X_ptr}},
810 {{
"GRAD", grad_ptr}, {
"SIGMA", contact_stress_ptr}},
819 post_proc_fe->getOpPtrVector().push_back(
823 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
831 {{
"STRESS", stress_ptr}, {
"PLASTIC_STRAIN", plastic_strain_ptr}}
840 auto vol_post_proc = [
this,
simple, post_proc_ele_domain,
841 add_post_proc_map]() {
842 PetscBool post_proc_vol = PETSC_FALSE;
844 post_proc_vol = PETSC_TRUE;
847 &post_proc_vol, PETSC_NULL);
848 if (post_proc_vol == PETSC_FALSE)
849 return boost::shared_ptr<PostProcEleDomain>();
850 auto post_proc_fe = boost::make_shared<PostProcEleDomain>(
mField);
851 auto u_ptr = boost::make_shared<MatrixDouble>();
852 post_proc_fe->getOpPtrVector().push_back(
854 auto X_ptr = boost::make_shared<MatrixDouble>();
855 post_proc_fe->getOpPtrVector().push_back(
857 auto contact_stress_ptr = boost::make_shared<MatrixDouble>();
859 post_proc_fe->getOpPtrVector().push_back(
861 "SIGMA", contact_stress_ptr));
863 contact_stress_ptr =
nullptr;
865 auto [grad_ptr, stress_ptr, plastic_strain_ptr] = post_proc_ele_domain(
866 post_proc_fe->getOpPtrVector(),
simple->getDomainFEName());
868 return add_post_proc_map(post_proc_fe, u_ptr, grad_ptr, stress_ptr,
869 plastic_strain_ptr, contact_stress_ptr, X_ptr);
872 auto skin_post_proc = [
this,
simple, post_proc_ele_domain,
873 add_post_proc_map]() {
876 PetscBool post_proc_skin = PETSC_TRUE;
878 post_proc_skin = PETSC_FALSE;
881 &post_proc_skin, PETSC_NULL);
883 if (post_proc_skin == PETSC_FALSE)
884 return boost::shared_ptr<PostProcEleBdy>();
886 auto post_proc_fe = boost::make_shared<PostProcEleBdy>(
mField);
887 auto u_ptr = boost::make_shared<MatrixDouble>();
888 post_proc_fe->getOpPtrVector().push_back(
890 auto X_ptr = boost::make_shared<MatrixDouble>();
891 post_proc_fe->getOpPtrVector().push_back(
893 auto contact_stress_ptr = boost::make_shared<MatrixDouble>();
896 auto [grad_ptr, stress_ptr, plastic_strain_ptr] = post_proc_ele_domain(
897 op_loop_side->getOpPtrVector(),
simple->getDomainFEName());
899 op_loop_side->getOpPtrVector().push_back(
901 "SIGMA", contact_stress_ptr));
903 contact_stress_ptr =
nullptr;
905 post_proc_fe->getOpPtrVector().push_back(op_loop_side);
907 return add_post_proc_map(post_proc_fe, u_ptr, grad_ptr, stress_ptr,
908 plastic_strain_ptr, contact_stress_ptr, X_ptr);
911 return std::make_pair(vol_post_proc(), skin_post_proc());
914 auto create_reaction_fe = [&]() {
915 auto fe_ptr = boost::make_shared<DomainEle>(
mField);
916 fe_ptr->getRuleHook =
cpPtr->integrationRule;
918 auto &pip = fe_ptr->getOpPtrVector();
920 auto common_data_ptr = boost::make_shared<ADOLCPlasticity::CommonData>();
922 "U", common_data_ptr->getGardAtGaussPtsPtr()));
923 CHKERR opFactoryDomainRhs<SPACE_DIM, PETSC, GAUSS, DomainEleOp>(
924 mField,
"U", pip,
"ADOLCMAT", common_data_ptr,
cpPtr, Sev::noisy);
929 auto add_extra_finite_elements_to_ksp_solver_pipelines = [&]() {
932 auto pre_proc_ptr = boost::make_shared<FEMethod>();
933 auto post_proc_rhs_ptr = boost::make_shared<FEMethod>();
934 auto post_proc_lhs_ptr = boost::make_shared<FEMethod>();
936 auto get_bc_hook_rhs = [
this, pre_proc_ptr, time_scale]() {
939 {time_scale},
false)();
943 pre_proc_ptr->preProcessHook = get_bc_hook_rhs;
945 auto get_post_proc_hook_rhs = [
this, post_proc_rhs_ptr]() {
948 mField, post_proc_rhs_ptr,
nullptr, Sev::verbose)();
950 mField, post_proc_rhs_ptr, 1.)();
953 auto get_post_proc_hook_lhs = [
this, post_proc_lhs_ptr]() {
956 mField, post_proc_lhs_ptr, 1.)();
959 post_proc_rhs_ptr->postProcessHook = get_post_proc_hook_rhs;
960 post_proc_lhs_ptr->postProcessHook = get_post_proc_hook_lhs;
964 ts_ctx_ptr->getPreProcessIFunction().push_front(pre_proc_ptr);
965 ts_ctx_ptr->getPreProcessIJacobian().push_front(pre_proc_ptr);
966 ts_ctx_ptr->getPostProcessIFunction().push_back(post_proc_rhs_ptr);
967 ts_ctx_ptr->getPostProcessIJacobian().push_back(post_proc_lhs_ptr);
973 CHKERR add_extra_finite_elements_to_ksp_solver_pipelines();
975 auto create_monitor_fe = [dm, time_scale](
auto &&post_proc_fe,
976 auto &&reaction_fe) {
977 return boost::make_shared<Monitor>(
978 dm, post_proc_fe, reaction_fe,
979 std::vector<boost::shared_ptr<ScalingMethod>>{time_scale});
983 auto set_up_post_step = [&](
auto ts) {
988 auto create_update_ptr = [&]() {
989 auto fe_ptr = boost::make_shared<DomainEle>(
mField);
990 fe_ptr->getRuleHook =
cpPtr->integrationRule;
993 auto common_data_ptr = boost::make_shared<ADOLCPlasticity::CommonData>();
994 fe_ptr->getOpPtrVector().push_back(
996 "U", common_data_ptr->getGardAtGaussPtsPtr()));
998 opFactoryDomainUpdate<SPACE_DIM>(
mField, fe_ptr->getOpPtrVector(),
999 "ADOLCMAT", common_data_ptr,
cpPtr),
1010 auto ts_step_post_proc = [](TS ts) {
1019 CHKERR TSSetPostStep(ts, ts_step_post_proc);
1025 auto set_up_monitor = [&](
auto ts) {
1027 boost::shared_ptr<FEMethod> null_fe;
1029 create_monitor_fe(create_post_proc_fe(), create_reaction_fe());
1031 null_fe, monitor_ptr);
1035 auto set_section_monitor = [&](
auto solver) {
1038 CHKERR TSGetSNES(solver, &snes);
1039 CHKERR SNESMonitorSet(snes,
1042 (
void *)(snes_ctx_ptr.get()),
nullptr);
1046 auto set_up_adapt = [&](
auto ts) {
1050 CHKERR TSGetAdapt(ts, &adapt);
1055 auto ts = pipeline_mng->createTSIM();
1059 CHKERR TSSetMaxTime(ts, ftime);
1060 CHKERR TSSetExactFinalTime(ts, TS_EXACTFINALTIME_MATCHSTEP);
1066 CHKERR set_section_monitor(ts);
1069 CHKERR set_up_monitor(ts);
1070 CHKERR set_up_post_step(ts);
1072 CHKERR TSSetFromOptions(ts);
1074 CHKERR TSSolve(ts, NULL);
1077 CHKERR TSGetTime(ts, &ftime);
1079 PetscInt steps, snesfails, rejects, nonlinits, linits;
1080 CHKERR TSGetStepNumber(ts, &steps);
1081 CHKERR TSGetSNESFailures(ts, &snesfails);
1082 CHKERR TSGetStepRejections(ts, &rejects);
1083 CHKERR TSGetSNESIterations(ts, &nonlinits);
1084 CHKERR TSGetKSPIterations(ts, &linits);
1086 "steps %d (%d rejected, %d SNES fails), ftime %g, nonlinits "
1088 steps, rejects, snesfails, ftime, nonlinits, linits);