583 {
588
589
590 CHKERR m_field.getInterface<
VecManager>()->vecCreateGhost(
"ELASTIC_MECHANICS",
595 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(
"ELASTIC_MECHANICS",
aij);
596
598 const std::string interface_block_name = "MAT_INTERF";
599 for (
auto m : meshsets_manager->getCubitMeshsetPtr(
std::regex(
600 (boost::format("%s(.*)") % interface_block_name).str()))) {
603 CHKERR m->getAttributeDataStructure(mydata);
604 MOFEM_LOG(
"ARC_LENGTH", Sev::inform) << mydata;
605
613
614 EntityHandle meshset =
m->getMeshset();
616 CHKERR mOab.get_entities_by_type(meshset, MBTRI, tris,
true);
618 CHKERR mOab.get_adjacencies(tris, 3,
false, ents3d, moab::Interface::UNION);
620 }
621
622 arcCtx = boost::make_shared<ArcLengthCtx>(m_field,
"ELASTIC_MECHANICS");
624 boost::make_shared<ArcLengthIntElemFEMethod>(m_field.get_moab(),
arcCtx);
625 snesCtxPtr = boost::make_shared<ArcLengthSnesCtx>(
626 m_field,
"ELASTIC_MECHANICS",
arcCtx);
630
631 auto essential_pre_proc_zero_rhs = boost::make_shared<FEMethod>();
632 auto essential_pre_proc_lhs = boost::make_shared<FEMethod>();
633 auto essential_post_proc_rhs = boost::make_shared<FEMethod>();
634 auto essential_post_proc_lhs = boost::make_shared<FEMethod>();
635
637 boost::shared_ptr<ArcLengthCtx> arcCtx;
638
639 ArcScale(boost::shared_ptr<ArcLengthCtx> arc_ctx) : arcCtx(arc_ctx) {}
640
641 double getScale(const double time) override {
642 return arcCtx->getFieldData();
643 }
644 };
645 auto arc_scale = boost::make_shared<ArcScale>(
arcCtx);
646
648 double getScale(const double time) override {
649 return 0.0;
650 }
651 };
652 auto arc_zero = boost::make_shared<ArcZero>();
653
654 auto get_essential_pre_proc_zero =
655 [&m_field, essential_pre_proc_zero_rhs, arc_zero]() {
657 m_field, essential_pre_proc_zero_rhs, {arc_zero});
658 };
659 essential_pre_proc_zero_rhs->preProcessHook =
660 get_essential_pre_proc_zero();
661 auto get_essential_pre_proc_lhs =
662 [&m_field, essential_pre_proc_lhs, arc_scale]() {
664 m_field, essential_pre_proc_lhs, {arc_scale});
665 };
666 essential_pre_proc_lhs->preProcessHook = get_essential_pre_proc_lhs();
667
668 essential_post_proc_rhs->postProcessHook =
669 [&m_field, essential_post_proc_rhs, arc_scale]() {
672 m_field, essential_post_proc_rhs, {arc_scale})();
674 m_field, essential_post_proc_rhs, 1.)();
676 };
677
678
679
680 essential_post_proc_lhs->postProcessHook =
682 m_field, essential_post_proc_lhs, 1.);
683
688 };
691
696 CHKERR HookeOps::opFactoryDomainRhs<SPACE_DIM, PETSC, GAUSS, DomainEleOp>(
697 m_field,
elasticRhsFe->getOpPtrVector(),
"DISPLACEMENT",
"MAT_ELASTIC",
698 Sev::verbose, true);
699 CHKERR HookeOps::opFactoryDomainLhs<SPACE_DIM, PETSC, GAUSS, DomainEleOp>(
700 m_field,
elasticLhsFe->getOpPtrVector(),
"DISPLACEMENT",
"MAT_ELASTIC",
701 Sev::verbose);
702
706
712 Mat shell_aij;
714 &shell_aij);
718
722
723 naturalBcFe = boost::make_shared<BoundaryEle>(m_field);
726 };
728 "GEOMETRY");
730 naturalBcFe->getOpPtrVector(), m_field,
"DISPLACEMENT", Sev::inform);
731
733 CHKERR SNESSetApplicationContext(
snes, &snes_ctx);
737
740 PC pc;
743 CHKERR PCSetType(pc, PCSHELL);
747
748
750 snes_ctx.getPreProcComputeRhs().push_back(essential_pre_proc_zero_rhs);
751 snes_ctx.getPreProcComputeRhs().push_back(&pre_post_proc_fe);
752 loops_to_do_Rhs.push_back(
754 loops_to_do_Rhs.push_back(
756 loops_to_do_Rhs.push_back(
758
759
760 snes_ctx.getPostProcComputeRhs().push_back(&pre_post_proc_fe);
761 snes_ctx.getPostProcComputeRhs().push_back(essential_post_proc_rhs);
762
763
765 snes_ctx.getPreProcSetOperators().push_back(essential_pre_proc_lhs);
766 loops_to_do_Mat.push_back(
768 loops_to_do_Mat.push_back(
770 loops_to_do_Mat.push_back(
772 snes_ctx.getPostProcSetOperators().push_back(essential_post_proc_lhs);
773
774
775 if (step == 1) {
777 } else {
779 step++;
780 }
781
782 auto f_lambda_on_essential_bc = boost::make_shared<FEMethod>();
783 f_lambda_on_essential_bc->preProcessHook =
785 m_field, f_lambda_on_essential_bc, {}, false);
786
787
788 f_lambda_on_essential_bc->postProcessHook =
790 m_field, f_lambda_on_essential_bc, -1.,
arcCtx->F_lambda);
791
793 CHKERR VecGhostUpdateBegin(
arcCtx->F_lambda, INSERT_VALUES, SCATTER_FORWARD);
794 CHKERR VecGhostUpdateEnd(
arcCtx->F_lambda, INSERT_VALUES, SCATTER_FORWARD);
795 CHKERR m_field.problem_basic_method_preProcess(
"ELASTIC_MECHANICS",
796 *f_lambda_on_essential_bc);
798 CHKERR m_field.loop_finite_elements(
"ELASTIC_MECHANICS",
"ELASTIC",
803 CHKERR m_field.problem_basic_method_postProcess(
"ELASTIC_MECHANICS",
804 *f_lambda_on_essential_bc);
805 CHKERR VecGhostUpdateBegin(
arcCtx->F_lambda, ADD_VALUES, SCATTER_REVERSE);
806 CHKERR VecGhostUpdateEnd(
arcCtx->F_lambda, ADD_VALUES, SCATTER_REVERSE);
809
810
812 MOFEM_LOG_C(
"ARC_LENGTH", Sev::inform,
"\tFlambda2 = %6.4e",
814
815 if (step > 1) {
817 "ELASTIC_MECHANICS",
COL,
d, INSERT_VALUES, SCATTER_FORWARD);
819 "ELASTIC_MECHANICS",
"DISPLACEMENT",
"X0_DISPLACEMENT",
COL,
arcCtx->x0,
820 INSERT_VALUES, SCATTER_FORWARD);
821 double x0_nrm;
824 "\tRead x0_nrm = %6.4e dlambda = %6.4e", x0_nrm,
827 } else {
830 }
832
833 postProcPtr = boost::make_shared<PostProcEle>(m_field);
835 auto disp_ptr = boost::make_shared<MatrixDouble>();
837 post_proc.getOpPtrVector(), {H1}, "GEOMETRY");
838 auto hooke_common_ptr =
839 HookeOps::commonDataFactory<SPACE_DIM, GAUSS, DomainEleOp>(
840 m_field, post_proc.getOpPtrVector(), "DISPLACEMENT", "MAT_ELASTIC",
841 Sev::verbose);
842 post_proc.getOpPtrVector().push_back(
845 post_proc.getOpPtrVector().push_back(
846 new OpPPMap(post_proc.getPostProcMesh(), post_proc.getMapGaussPts(), {},
847 {{"DISPLACEMENT", disp_ptr}},
848 {{"DISPLACEMENT_GRAD", hooke_common_ptr->matGradPtr}},
849 {{"STRAIN", hooke_common_ptr->getMatStrain()},
850 {"STRESS", hooke_common_ptr->getMatCauchyStress()}}));
851
858 "-field_eval_coords requires exactly three coordinates");
859
866
868 field_eval_fe->getRuleHook = [](
int,
int,
int) {
return -1; };
870 field_eval_fe->getOpPtrVector(), {H1}, "GEOMETRY");
871
872 auto field_eval_hooke_common_ptr =
873 HookeOps::commonDataFactory<SPACE_DIM, GAUSS, DomainEleOp>(
874 m_field, field_eval_fe->getOpPtrVector(), "DISPLACEMENT",
875 "MAT_ELASTIC", Sev::verbose);
878 field_eval_fe->getOpPtrVector().push_back(
881 }
882
884}
#define MOFEM_LOG_C(channel, severity, format,...)
#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.
#define MOFEM_LOG(channel, severity)
Log.
const double n
refractive index of diffusive medium
auto createSNES(MPI_Comm comm)
PetscErrorCode SnesMat(SNES snes, Vec x, Mat A, Mat B, void *ctx)
This is MoFEM implementation for the left hand side (tangent matrix) evaluation in SNES solver.
PetscErrorCode SnesRhs(SNES snes, Vec x, Vec f, void *ctx)
This is MoFEM implementation for the right hand side (residual vector) evaluation in SNES solver.
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
PetscErrorCode PetscOptionsGetRealArray(PetscOptions *, const char pre[], const char name[], PetscReal dval[], PetscInt *nmax, PetscBool *set)
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
static constexpr int approx_order
FTensor::Index< 'm', 3 > m
boost::shared_ptr< ArcLengthIntElemFEMethod > arcMethodPtr
MoFEM::Interface * mField
boost::shared_ptr< MatrixDouble > fieldEvalStressPtr
boost::ptr_vector< CohesiveInterfaceElement::PhysicalEquation > interfaceMaterials
boost::scoped_ptr< PCArcLengthCtx > pcCtx
SmartPetscObj< Mat > shellAij
boost::shared_ptr< PostProcEle > postProcPtr
PetscScalar stepSizeReduction
boost::shared_ptr< CohesiveInterfaceElement > cohesiveElementsPtr
const std::string naturalBcFeName
SmartPetscObj< SNES > snes
boost::shared_ptr< AssembleRhsVectors > prePostProcFePtr
boost::shared_ptr< ArcLengthCtx > arcCtx
boost::shared_ptr< MatrixDouble > fieldEvalDispPtr
boost::shared_ptr< FieldEvaluatorInterface::SetPtsData > fieldEvalData
boost::scoped_ptr< ArcLengthMatShell > matCtx
std::array< double, SPACE_DIM > fieldEvalCoords
boost::shared_ptr< ArcLengthSnesCtx > snesCtxPtr
boost::shared_ptr< DomainEle > elasticLhsFe
boost::shared_ptr< BoundaryEle > naturalBcFe
boost::shared_ptr< DomainEle > elasticRhsFe
shell matrix for arc-length method
Constitutive (physical) equation for interface.
Add operators pushing bases from local to physical configuration.
Class (Function) to enforce essential constrains on the left hand side diagonal.
Class (Function) to enforce essential constrains on the right hand side diagonal.
Class (Function) to enforce essential constrains.
Field evaluator interface.
Linear interface data structure.
Matrix manager is used to build and partition problems.
Interface for managing meshsets containing materials and boundary conditions.
Specialization for MatrixDouble vector field values calculation.
Post post-proc data at points from hash maps.
intrusive_ptr for managing petsc objects
MoFEM::FEMethodsSequence FEMethodsSequence
Vector manager is used to create vectors \mofem_vectors.
structure for Arc Length pre-conditioner