582 {
587
588
589 CHKERR m_field.getInterface<
VecManager>()->vecCreateGhost(
"ELASTIC_MECHANICS",
594 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(
"ELASTIC_MECHANICS",
aij);
595
597 const std::string interface_block_name = "MAT_INTERF";
598 for (
auto m : meshsets_manager->getCubitMeshsetPtr(
std::regex(
599 (boost::format("%s(.*)") % interface_block_name).str()))) {
602 CHKERR m->getAttributeDataStructure(mydata);
603 MOFEM_LOG(
"ARC_LENGTH", Sev::inform) << mydata;
604
612
613 EntityHandle meshset =
m->getMeshset();
615 CHKERR mOab.get_entities_by_type(meshset, MBTRI, tris,
true);
617 CHKERR mOab.get_adjacencies(tris, 3,
false, ents3d, moab::Interface::UNION);
619 }
620
621 arcCtx = boost::make_shared<ArcLengthCtx>(m_field,
"ELASTIC_MECHANICS");
623 boost::make_shared<ArcLengthIntElemFEMethod>(m_field.get_moab(),
arcCtx);
624 snesCtxPtr = boost::make_shared<ArcLengthSnesCtx>(
625 m_field,
"ELASTIC_MECHANICS",
arcCtx);
629
630 auto essential_pre_proc_zero_rhs = boost::make_shared<FEMethod>();
631 auto essential_pre_proc_lhs = boost::make_shared<FEMethod>();
632 auto essential_post_proc_rhs = boost::make_shared<FEMethod>();
633 auto essential_post_proc_lhs = boost::make_shared<FEMethod>();
634
636 boost::shared_ptr<ArcLengthCtx> arcCtx;
637
638 ArcScale(boost::shared_ptr<ArcLengthCtx> arc_ctx) : arcCtx(arc_ctx) {}
639
640 double getScale(const double time) override {
641 return arcCtx->getFieldData();
642 }
643 };
644 auto arc_scale = boost::make_shared<ArcScale>(
arcCtx);
645
647 double getScale(const double time) override {
648 return 0.0;
649 }
650 };
651 auto arc_zero = boost::make_shared<ArcZero>();
652
653 auto get_essential_pre_proc_zero =
654 [&m_field, essential_pre_proc_zero_rhs, arc_zero]() {
656 m_field, essential_pre_proc_zero_rhs, {arc_zero});
657 };
658 essential_pre_proc_zero_rhs->preProcessHook =
659 get_essential_pre_proc_zero();
660 auto get_essential_pre_proc_lhs =
661 [&m_field, essential_pre_proc_lhs, arc_scale]() {
663 m_field, essential_pre_proc_lhs, {arc_scale});
664 };
665 essential_pre_proc_lhs->preProcessHook = get_essential_pre_proc_lhs();
666
667 essential_post_proc_rhs->postProcessHook =
668 [&m_field, essential_post_proc_rhs, arc_scale]() {
671 m_field, essential_post_proc_rhs, {arc_scale})();
673 m_field, essential_post_proc_rhs, 1.)();
675 };
676
677
678
679 essential_post_proc_lhs->postProcessHook =
681 m_field, essential_post_proc_lhs, 1.);
682
687 };
690
695 CHKERR HookeOps::opFactoryDomainRhs<SPACE_DIM, PETSC, GAUSS, DomainEleOp>(
696 m_field,
elasticRhsFe->getOpPtrVector(),
"DISPLACEMENT",
"MAT_ELASTIC",
697 Sev::verbose, true);
698 CHKERR HookeOps::opFactoryDomainLhs<SPACE_DIM, PETSC, GAUSS, DomainEleOp>(
699 m_field,
elasticLhsFe->getOpPtrVector(),
"DISPLACEMENT",
"MAT_ELASTIC",
700 Sev::verbose);
701
705
711 Mat shell_aij;
713 &shell_aij);
717
721
722 naturalBcFe = boost::make_shared<BoundaryEle>(m_field);
725 };
727 "GEOMETRY");
729 naturalBcFe->getOpPtrVector(), m_field,
"DISPLACEMENT", Sev::inform);
730
732 CHKERR SNESSetApplicationContext(
snes, &snes_ctx);
736
737 KSP ksp;
739 PC pc;
740 CHKERR KSPGetPC(ksp, &pc);
742 CHKERR PCSetType(pc, PCSHELL);
746
747
749 snes_ctx.getPreProcComputeRhs().push_back(essential_pre_proc_zero_rhs);
750 snes_ctx.getPreProcComputeRhs().push_back(&pre_post_proc_fe);
751 loops_to_do_Rhs.push_back(
753 loops_to_do_Rhs.push_back(
755 loops_to_do_Rhs.push_back(
757
758
759 snes_ctx.getPostProcComputeRhs().push_back(&pre_post_proc_fe);
760 snes_ctx.getPostProcComputeRhs().push_back(essential_post_proc_rhs);
761
762
764 snes_ctx.getPreProcSetOperators().push_back(essential_pre_proc_lhs);
765 loops_to_do_Mat.push_back(
767 loops_to_do_Mat.push_back(
769 loops_to_do_Mat.push_back(
771 snes_ctx.getPostProcSetOperators().push_back(essential_post_proc_lhs);
772
773
774 if (step == 1) {
776 } else {
778 step++;
779 }
780
781 auto f_lambda_on_essential_bc = boost::make_shared<FEMethod>();
782 f_lambda_on_essential_bc->preProcessHook =
784 m_field, f_lambda_on_essential_bc, {}, false);
785
786
787 f_lambda_on_essential_bc->postProcessHook =
789 m_field, f_lambda_on_essential_bc, -1.,
arcCtx->F_lambda);
790
792 CHKERR VecGhostUpdateBegin(
arcCtx->F_lambda, INSERT_VALUES, SCATTER_FORWARD);
793 CHKERR VecGhostUpdateEnd(
arcCtx->F_lambda, INSERT_VALUES, SCATTER_FORWARD);
794 CHKERR m_field.problem_basic_method_preProcess(
"ELASTIC_MECHANICS",
795 *f_lambda_on_essential_bc);
797 CHKERR m_field.loop_finite_elements(
"ELASTIC_MECHANICS",
"ELASTIC",
802 CHKERR m_field.problem_basic_method_postProcess(
"ELASTIC_MECHANICS",
803 *f_lambda_on_essential_bc);
804 CHKERR VecGhostUpdateBegin(
arcCtx->F_lambda, ADD_VALUES, SCATTER_REVERSE);
805 CHKERR VecGhostUpdateEnd(
arcCtx->F_lambda, ADD_VALUES, SCATTER_REVERSE);
808
809
811 MOFEM_LOG_C(
"ARC_LENGTH", Sev::inform,
"\tFlambda2 = %6.4e",
813
814 if (step > 1) {
816 "ELASTIC_MECHANICS",
COL,
d, INSERT_VALUES, SCATTER_FORWARD);
818 "ELASTIC_MECHANICS",
"DISPLACEMENT",
"X0_DISPLACEMENT",
COL,
arcCtx->x0,
819 INSERT_VALUES, SCATTER_FORWARD);
820 double x0_nrm;
823 "\tRead x0_nrm = %6.4e dlambda = %6.4e", x0_nrm,
826 } else {
829 }
831
832 postProcPtr = boost::make_shared<PostProcEle>(m_field);
834 auto disp_ptr = boost::make_shared<MatrixDouble>();
836 post_proc.getOpPtrVector(), {H1}, "GEOMETRY");
837 auto hooke_common_ptr =
838 HookeOps::commonDataFactory<SPACE_DIM, GAUSS, DomainEleOp>(
839 m_field, post_proc.getOpPtrVector(), "DISPLACEMENT", "MAT_ELASTIC",
840 Sev::verbose);
841 post_proc.getOpPtrVector().push_back(
844 post_proc.getOpPtrVector().push_back(
845 new OpPPMap(post_proc.getPostProcMesh(), post_proc.getMapGaussPts(), {},
846 {{"DISPLACEMENT", disp_ptr}},
847 {{"DISPLACEMENT_GRAD", hooke_common_ptr->matGradPtr}},
848 {{"STRAIN", hooke_common_ptr->getMatStrain()},
849 {"STRESS", hooke_common_ptr->getMatCauchyStress()}}));
850
857 "-field_eval_coords requires exactly three coordinates");
858
865
867 field_eval_fe->getRuleHook = [](
int,
int,
int) {
return -1; };
869 field_eval_fe->getOpPtrVector(), {H1}, "GEOMETRY");
870
871 auto field_eval_hooke_common_ptr =
872 HookeOps::commonDataFactory<SPACE_DIM, GAUSS, DomainEleOp>(
873 m_field, field_eval_fe->getOpPtrVector(), "DISPLACEMENT",
874 "MAT_ELASTIC", Sev::verbose);
877 field_eval_fe->getOpPtrVector().push_back(
880 }
881
883}
#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