25#include <ArcLengthTools.hpp>
31using namespace boost::numeric;
34 -my_file mesh file name\n\
35 -my_sr reduction of step size\n\
36 -my_its_d desired number of steps\n\
37 -my_ms maximal number of steps\n\
38 -gamma arc-length step adaptation exponent\n\
39 -min_arc_length_step minimum arc-length step\n\
40 -max_arc_length_step maximum arc-length step\n\
41 -field_eval_coords x,y,z coordinates where displacement and stress are evaluated\n\n";
47 boost::shared_ptr<ArcLengthCtx>
arcPtr;
60 CHKERR VecGhostUpdateBegin(
snes_f, INSERT_VALUES, SCATTER_FORWARD);
61 CHKERR VecGhostUpdateEnd(
snes_f, INSERT_VALUES, SCATTER_FORWARD);
77 CHKERR VecGhostUpdateBegin(
snes_f, ADD_VALUES, SCATTER_REVERSE);
78 CHKERR VecGhostUpdateEnd(
snes_f, ADD_VALUES, SCATTER_REVERSE);
83 MOFEM_LOG_C(
"ARC_LENGTH", Sev::inform,
"\tlambda = %6.4e",
88 MOFEM_LOG_C(
"ARC_LENGTH", Sev::inform,
"\tpre-essential fnorm = %6.4e",
130 boost::ptr_vector<CohesiveInterfaceElement::PhysicalEquation>
141 boost::scoped_ptr<ArcLengthMatShell>
matCtx;
142 boost::scoped_ptr<PCArcLengthCtx>
pcCtx;
187 PetscBool flg = PETSC_TRUE;
188 char mesh_file_name[PETSC_MAX_PATH_LEN] =
"";
190 mesh_file_name,
sizeof(mesh_file_name), &flg);
191 if (flg != PETSC_TRUE) {
193 mesh_file_name,
sizeof(mesh_file_name), &flg);
194 if (flg != PETSC_TRUE)
196 "*** ERROR -my_file or -file_name (MESH FILE NEEDED)");
202 CHKERR mOab.load_file(mesh_file_name, 0, option);
205 Tag th_step_size, th_step;
206 double def_step_size = 1;
207 rval =
mOab.tag_get_handle(
"_STEPSIZE", 1, MB_TYPE_DOUBLE, th_step_size,
208 MB_TAG_CREAT | MB_TAG_MESH, &def_step_size);
209 if (
rval == MB_ALREADY_ALLOCATED)
213 rval =
mOab.tag_get_handle(
"_STEP", 1, MB_TYPE_INTEGER, th_step,
214 MB_TAG_CREAT | MB_TAG_MESH, &def_step);
215 if (
rval == MB_ALREADY_ALLOCATED)
218 const void *tag_data_step_size[1];
219 EntityHandle root = 0;
220 CHKERR mOab.tag_get_by_ptr(th_step_size, &root, 1, tag_data_step_size);
221 double &step_size = *(
double *)tag_data_step_size[0];
222 const void *tag_data_step[1];
223 CHKERR mOab.tag_get_by_ptr(th_step, &root, 1, tag_data_step);
224 int &step = *(
int *)tag_data_step[0];
226 MOFEM_LOG_C(
"ARC_LENGTH", Sev::inform,
"Start step %d and step_size = %6.4e",
230 stepPtr = (
int *)tag_data_step[0];
246 PetscBool flg = PETSC_FALSE;
253 if (flg != PETSC_TRUE) {
259 if (flg != PETSC_TRUE) {
265 if (flg != PETSC_TRUE) {
271 if (flg != PETSC_TRUE) {
284 CHKERR m_field.get_moab().tag_get_handle(
285 "_MY_REFINEMENT_LEVEL",
sizeof(
BitRefLevel), MB_TYPE_OPAQUE,
286 th_my_ref_level, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES,
288 const EntityHandle root_meshset = m_field.get_moab().get_root_set();
290 CHKERR m_field.get_moab().tag_get_by_ptr(th_my_ref_level, &root_meshset, 1,
291 (
const void **)&ptr_bit_level0);
301 std::vector<BitRefLevel> bit_levels;
306 auto split_interface = [&](
const EntityHandle cubit_meshset,
309 MOFEM_LOG_C(
"ARC_LENGTH", Sev::inform,
"Insert Interface %d", meshset_id);
312 EntityHandle ref_level_meshset = 0;
313 CHKERR mOab.create_meshset(MESHSET_SET, ref_level_meshset);
315 ->getEntitiesByTypeAndRefLevel(bit_levels.back(),
319 ->getEntitiesByTypeAndRefLevel(bit_levels.back(),
322 Range ref_level_tets;
323 CHKERR mOab.get_entities_by_handle(ref_level_meshset, ref_level_tets,
326 CHKERR interface_ptr->
getSides(cubit_meshset, bit_levels.back(),
true,
332 cubit_meshset,
true,
true, 0);
334 CHKERR mOab.delete_entities(&ref_level_meshset, 1);
338 EntityHandle cubit_meshset = ciit->meshset;
340 ->updateMeshsetByEntitiesChildren(cubit_meshset, bit_levels.back(),
341 cubit_meshset, MBMAXTYPE,
true);
349 std::set<int> split_interface_ids;
350 bool split_from_sideset =
false;
353 if (split_interface_ids.insert(cit->getMeshsetId()).second) {
354 CHKERR split_interface(cit->getMeshset(), cit->getMeshsetId());
355 split_from_sideset =
true;
358 if (!split_from_sideset) {
359 const std::string block_name =
"MAT_INTERF";
361 std::regex((boost::format(
"%s(.*)") % block_name).str()))) {
362 if (split_interface_ids.insert(
m->getMeshsetId()).second)
363 CHKERR split_interface(
m->getMeshset(),
m->getMeshsetId());
367 bit_level0 = bit_levels.back();
368 problem_bit_level = bit_level0;
385 CHKERR m_field.add_finite_element(
"ELASTIC");
388 CHKERR m_field.modify_finite_element_add_field_row(
"ELASTIC",
390 CHKERR m_field.modify_finite_element_add_field_col(
"ELASTIC",
392 CHKERR m_field.modify_finite_element_add_field_data(
"ELASTIC",
395 m_field.modify_finite_element_add_field_data(
"ELASTIC",
"GEOMETRY");
396 CHKERR m_field.modify_finite_element_add_field_row(
"ELASTIC",
"LAMBDA");
397 CHKERR m_field.modify_finite_element_add_field_col(
"ELASTIC",
"LAMBDA");
399 CHKERR m_field.modify_finite_element_add_field_data(
"ELASTIC",
"LAMBDA");
402 CHKERR m_field.add_finite_element(
"INTERFACE");
403 CHKERR m_field.modify_finite_element_add_field_row(
"INTERFACE",
405 CHKERR m_field.modify_finite_element_add_field_col(
"INTERFACE",
407 CHKERR m_field.modify_finite_element_add_field_data(
"INTERFACE",
410 m_field.modify_finite_element_add_field_data(
"INTERFACE",
"GEOMETRY");
413 CHKERR m_field.add_finite_element(
"ARC_LENGTH");
416 CHKERR m_field.modify_finite_element_add_field_row(
"ARC_LENGTH",
"LAMBDA");
417 CHKERR m_field.modify_finite_element_add_field_col(
"ARC_LENGTH",
"LAMBDA");
421 m_field.modify_finite_element_add_field_data(
"ARC_LENGTH",
"LAMBDA");
424 CHKERR m_field.add_problem(
"ELASTIC_MECHANICS");
427 CHKERR m_field.modify_problem_add_finite_element(
"ELASTIC_MECHANICS",
429 CHKERR m_field.modify_problem_add_finite_element(
"ELASTIC_MECHANICS",
431 CHKERR m_field.modify_problem_add_finite_element(
"ELASTIC_MECHANICS",
434 CHKERR m_field.modify_problem_ref_level_add_bit(
"ELASTIC_MECHANICS",
441 CHKERR m_field.add_ents_to_field_by_type(0, MBTET,
"DISPLACEMENT");
442 CHKERR m_field.add_ents_to_field_by_type(0, MBTET,
"X0_DISPLACEMENT");
443 CHKERR m_field.add_ents_to_field_by_type(0, MBTET,
"GEOMETRY");
446 CHKERR m_field.add_ents_to_finite_element_by_bit_ref(
447 problem_bit_level,
BitRefLevel().set(),
"ELASTIC", MBTET);
448 CHKERR m_field.add_ents_to_finite_element_by_bit_ref(
449 problem_bit_level,
BitRefLevel().set(),
"INTERFACE", MBPRISM);
454 EntityHandle no_field_vertex;
456 const double coords[] = {0, 0, 0};
457 CHKERR m_field.get_moab().create_vertex(coords, no_field_vertex);
458 Range range_no_field_vertex;
459 range_no_field_vertex.insert(no_field_vertex);
463 EntityHandle lambda_meshset = m_field.get_field_meshset(
"LAMBDA");
464 CHKERR m_field.get_moab().add_entities(lambda_meshset,
465 range_no_field_vertex);
468 EntityHandle meshset_fe_arc_length;
470 CHKERR mOab.create_meshset(MESHSET_SET, meshset_fe_arc_length);
471 CHKERR mOab.add_entities(meshset_fe_arc_length, &no_field_vertex, 1);
476 CHKERR m_field.add_ents_to_finite_element_by_MESHSET(
477 meshset_fe_arc_length,
"ARC_LENGTH",
false);
483 CHKERR m_field.set_field_order(0, MBTET,
"DISPLACEMENT",
order);
484 CHKERR m_field.set_field_order(0, MBTRI,
"DISPLACEMENT",
order);
485 CHKERR m_field.set_field_order(0, MBEDGE,
"DISPLACEMENT",
order);
486 CHKERR m_field.set_field_order(0, MBVERTEX,
"DISPLACEMENT", 1);
488 CHKERR m_field.set_field_order(0, MBTET,
"X0_DISPLACEMENT",
order);
489 CHKERR m_field.set_field_order(0, MBTRI,
"X0_DISPLACEMENT",
order);
490 CHKERR m_field.set_field_order(0, MBEDGE,
"X0_DISPLACEMENT",
order);
491 CHKERR m_field.set_field_order(0, MBVERTEX,
"X0_DISPLACEMENT", 1);
493 CHKERR m_field.set_field_order(0, MBTET,
"GEOMETRY", 2);
494 CHKERR m_field.set_field_order(0, MBTRI,
"GEOMETRY", 2);
495 CHKERR m_field.set_field_order(0, MBEDGE,
"GEOMETRY", 2);
496 CHKERR m_field.set_field_order(0, MBVERTEX,
"GEOMETRY", 1);
509 CHKERR m_field.modify_problem_add_finite_element(
"ELASTIC_MECHANICS",
512 Range natural_bc_faces;
515 CHKERR mOab.get_entities_by_type(
m->getMeshset(), MBTRI, natural_bc_faces,
519 CHKERR mOab.get_entities_by_type(
m->getMeshset(), MBTRI, natural_bc_faces,
522 for (
auto m : meshsets_manager->getCubitMeshsetPtr(
523 std::regex(
"(FORCE|PRESSURE)(.*)"))) {
524 CHKERR mOab.get_entities_by_type(
m->getMeshset(), MBTRI, natural_bc_faces,
527 CHKERR m_field.add_ents_to_finite_element_by_type(natural_bc_faces, MBTRI,
535 CHKERR m_field.build_fields();
537 CHKERR m_field.loop_dofs(
"GEOMETRY", ent_method_material);
540 CHKERR m_field.build_finite_elements();
543 CHKERR m_field.build_adjacencies(problem_bit_level);
553 m_field.get_comm_size());
568 "ELASTIC_MECHANICS",
"DISPLACEMENT");
573 CHKERR mmanager_ptr->printDisplacementSet();
574 CHKERR mmanager_ptr->printForceSet();
576 CHKERR mmanager_ptr->printMaterialsSet();
590 CHKERR m_field.getInterface<
VecManager>()->vecCreateGhost(
"ELASTIC_MECHANICS",
595 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(
"ELASTIC_MECHANICS",
aij);
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;
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);
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);
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>();
637 boost::shared_ptr<ArcLengthCtx> arcCtx;
639 ArcScale(boost::shared_ptr<ArcLengthCtx> arc_ctx) : arcCtx(arc_ctx) {}
641 double getScale(
const double time)
override {
642 return arcCtx->getFieldData();
645 auto arc_scale = boost::make_shared<ArcScale>(
arcCtx);
648 double getScale(
const double time)
override {
652 auto arc_zero = boost::make_shared<ArcZero>();
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});
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});
666 essential_pre_proc_lhs->preProcessHook = get_essential_pre_proc_lhs();
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.)();
680 essential_post_proc_lhs->postProcessHook =
682 m_field, essential_post_proc_lhs, 1.);
686 auto elastic_integration_rule = [](int, int,
int approx_order) {
696 CHKERR HookeOps::opFactoryDomainRhs<SPACE_DIM, PETSC, GAUSS, DomainEleOp>(
697 m_field,
elasticRhsFe->getOpPtrVector(),
"DISPLACEMENT",
"MAT_ELASTIC",
699 CHKERR HookeOps::opFactoryDomainLhs<SPACE_DIM, PETSC, GAUSS, DomainEleOp>(
700 m_field,
elasticLhsFe->getOpPtrVector(),
"DISPLACEMENT",
"MAT_ELASTIC",
723 naturalBcFe = boost::make_shared<BoundaryEle>(m_field);
730 naturalBcFe->getOpPtrVector(), m_field,
"DISPLACEMENT", Sev::inform);
733 CHKERR SNESSetApplicationContext(
snes, &snes_ctx);
743 CHKERR PCSetType(pc, PCSHELL);
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(
760 snes_ctx.getPostProcComputeRhs().push_back(&pre_post_proc_fe);
761 snes_ctx.getPostProcComputeRhs().push_back(essential_post_proc_rhs);
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);
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);
788 f_lambda_on_essential_bc->postProcessHook =
790 m_field, f_lambda_on_essential_bc, -1.,
arcCtx->F_lambda);
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);
812 MOFEM_LOG_C(
"ARC_LENGTH", Sev::inform,
"\tFlambda2 = %6.4e",
817 "ELASTIC_MECHANICS",
COL,
d, INSERT_VALUES, SCATTER_FORWARD);
819 "ELASTIC_MECHANICS",
"DISPLACEMENT",
"X0_DISPLACEMENT",
COL,
arcCtx->x0,
820 INSERT_VALUES, SCATTER_FORWARD);
824 "\tRead x0_nrm = %6.4e dlambda = %6.4e", x0_nrm,
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",
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()}}));
854 "-field_eval_coords", fieldEvalCoords.data(),
858 "-field_eval_coords requires exactly three coordinates");
864 ->buildTree<SPACE_DIM>(fieldEvalData,
"ELASTIC");
865 fieldEvalData->setEvalPoints(fieldEvalCoords.data(), 1);
867 auto field_eval_fe = fieldEvalData->feMethodPtr;
868 field_eval_fe->getRuleHook = [](
int,
int,
int) {
return -1; };
870 field_eval_fe->getOpPtrVector(), {H1},
"GEOMETRY");
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);
876 fieldEvalStressPtr = field_eval_hooke_common_ptr->getMatCauchyStress();
877 fieldEvalDispPtr = boost::make_shared<MatrixDouble>();
878 field_eval_fe->getOpPtrVector().push_back(
896 ->evalFEAtThePoint<SPACE_DIM>(
898 fieldEvalData, m_field.get_comm_rank(), m_field.get_comm_rank(),
902 int global_point_found = 0;
903 MPI_Allreduce(&point_found, &global_point_found, 1, MPI_INT, MPI_SUM,
910 "FieldEvaluator step %d lambda %6.4e point [%6.4e, %6.4e, "
915 "FieldEvaluator displacement [Ux, Uy, Uz] = [%6.4e, "
917 t_disp(0), t_disp(1), t_disp(2));
919 "FieldEvaluator Cauchy stress [Sxx, Syy, Szz, Sxy, Syz, Sxz] "
920 "= [%6.4e, %6.4e, %6.4e, %6.4e, %6.4e, %6.4e]",
921 t_stress(0, 0), t_stress(1, 1), t_stress(2, 2), t_stress(0, 1),
922 t_stress(1, 2), t_stress(0, 2));
923 }
else if (!global_point_found && !m_field.get_comm_rank()) {
925 "FieldEvaluator did not find point [%6.4e, %6.4e, %6.4e] in "
926 "the ELASTIC domain",
939 auto domain_reaction_fe = boost::make_shared<DomainEle>(m_field);
940 domain_reaction_fe->getRuleHook = [](int, int,
int approx_order) {
945 domain_reaction_fe->getOpPtrVector(), {H1},
"GEOMETRY");
946 CHKERR HookeOps::opFactoryDomainRhs<SPACE_DIM, PETSC, GAUSS, DomainEleOp>(
947 m_field, domain_reaction_fe->getOpPtrVector(),
"DISPLACEMENT",
948 "MAT_ELASTIC", Sev::verbose,
true);
951 CHKERR VecZeroEntries(reactions);
952 domain_reaction_fe->f = reactions;
953 domain_reaction_fe->vecAssembleSwitch =
954 boost::movelib::make_unique<bool>(
true);
955 domain_reaction_fe->postProcessHook =
960 "Reactions step %d lambda %6.4e", load_step,
962 CHKERR m_field.loop_finite_elements(
"ELASTIC_MECHANICS",
"ELASTIC",
963 *domain_reaction_fe);
972 double min_arc_length_step = std::numeric_limits<double>::epsilon();
973 double max_arc_length_step = std::numeric_limits<double>::max();
977 "-min_arc_length_step", &min_arc_length_step,
980 "-max_arc_length_step", &max_arc_length_step,
983 if (min_arc_length_step <= 0.)
985 "-min_arc_length_step must be positive");
986 if (max_arc_length_step <= 0.)
988 "-max_arc_length_step must be positive");
989 if (min_arc_length_step > max_arc_length_step)
991 "-min_arc_length_step must not exceed -max_arc_length_step");
1000 bool converged_state =
false;
1004 MOFEM_LOG_C(
"ARC_LENGTH", Sev::inform,
"Load Step %d step_size = %6.4e",
1012 }
else if (step == 2) {
1017 double dlambda =
arcCtx->dLambda;
1021 "Load Step %d step_size = %6.4e dlambda0 = %6.4e "
1022 "dx_nrm = %6.4e dx2 = %6.4e",
1023 step, step_size, dlambda, dx_nrm,
arcCtx->dx2);
1039 "Load Step %d step_size = %6.4e dlambda0 = %6.4e "
1040 "dx_nrm = %6.4e dx2 = %6.4e",
1041 step, step_size, dlambda, dx_nrm,
arcCtx->dx2);
1051 MOFEM_LOG_C(
"ARC_LENGTH", Sev::inform,
"number of Newton iterations = %d",
1054 SNESConvergedReason reason;
1055 CHKERR SNESGetConvergedReason(
snes, &reason);
1060 converged_state =
false;
1063 if (step > 1 && converged_state) {
1066 std::clamp(
reduction, min_arc_length_step / std::abs(step_size),
1067 max_arc_length_step / std::abs(step_size));
1068 MOFEM_LOG_C(
"ARC_LENGTH", Sev::inform,
"reduction step_size = %6.4e",
1074 "ELASTIC_MECHANICS",
COL,
d, INSERT_VALUES, SCATTER_REVERSE);
1076 CHKERR m_field.loop_finite_elements(
"ELASTIC_MECHANICS",
"INTERFACE",
1077 cohesive_elements.getFeHistory(), 0,
1078 m_field.get_comm_size());
1081 "ELASTIC_MECHANICS",
"DISPLACEMENT",
"X0_DISPLACEMENT",
COL,
1082 arcCtx->x0, INSERT_VALUES, SCATTER_REVERSE);
1083 converged_state =
true;
1091 if (step % 1 == 0) {
1093 CHKERR m_field.loop_finite_elements(
"ELASTIC_MECHANICS",
"ELASTIC",
1095 std::ostringstream ss;
1096 ss <<
"out_values_" << step <<
".h5m";
1097 CHKERR post_proc.writeFile(ss.str().c_str());
1121 const string default_options =
"-ksp_type fgmres \n"
1123 "-pc_factor_mat_solver_type mumps\n"
1124 "-mat_mumps_icntl_20 0\n"
1126 "-ksp_atol 1e-10 \n"
1127 "-ksp_rtol 1e-10 \n"
1129 "-snes_type newtonls \n"
1130 "-snes_linesearch_type l2 \n"
1131 "-snes_linesearch_monitor \n"
1132 "-snes_max_it 16 \n"
1133 "-snes_atol 1e-8 \n"
1134 "-snes_rtol 1e-8 \n"
1135 "-snes_converged_reason \n";
1137 string param_file =
"param_file.petsc";
1138 if (!
static_cast<bool>(ifstream(param_file))) {
1139 std::ofstream file(param_file.c_str(), std::ios::ate);
1140 if (file.is_open()) {
1141 file << default_options;
1147 auto core_log = logging::core::get();
1154 moab::Core mb_instance;
1155 moab::Interface &moab = mb_instance;
Implementation of linear interface element.
Natural force and pressure boundary conditions.
Implementation of Hookes operator Hookes for linear elastic problems in MoFEM.
Implementation of arc-length control for cohesive elements.
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
#define MOFEM_LOG_C(channel, severity, format,...)
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
ElementsAndOps< SPACE_DIM >::BoundaryEle BoundaryEle
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ NOFIELD
scalar or vector of scalars describe (no true field)
#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.
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
#define _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet in a moFEM field.
#define _IT_CUBITMESHSETS_FOR_LOOP_(MESHSET_MANAGER, IT)
Iterator that loops over all the Cubit MeshSets in a moFEM field.
MoFEMErrorCode partitionGhostDofs(const std::string name, int verb=VERBOSE)
determine ghost nodes
MoFEMErrorCode buildProblem(const std::string name, const bool square_matrix, int verb=VERBOSE)
build problem data structures
MoFEMErrorCode partitionProblem(const std::string name, int verb=VERBOSE)
partition problem dofs (collective)
MoFEMErrorCode partitionFiniteElements(const std::string name, bool part_from_moab=false, int low_proc=-1, int hi_proc=-1, int verb=VERBOSE)
partition finite elements
MoFEMErrorCode pushMarkDOFsOnEntities(const std::string problem_name, const std::string block_name, const std::string field_name, int lo, int hi, bool get_low_dim_ents=true)
Mark DOFs on block entities for boundary conditions.
const double n
refractive index of diffusive medium
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
implementation of Data Operators for Forces and Sources
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 PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetReal(PetscOptions *, const char pre[], const char name[], PetscReal *dval, PetscBool *set)
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)
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
static constexpr int approx_order
FTensor::Index< 'm', 3 > m
MoFEMErrorCode boundaryCondition()
[Set up problem]
boost::shared_ptr< ArcLengthIntElemFEMethod > arcMethodPtr
MoFEM::Interface * mField
MoFEMErrorCode checkResults()
[Postprocess results]
MoFEMErrorCode readMesh()
[Run problem]
boost::shared_ptr< MatrixDouble > fieldEvalStressPtr
boost::ptr_vector< CohesiveInterfaceElement::PhysicalEquation > interfaceMaterials
boost::scoped_ptr< PCArcLengthCtx > pcCtx
SmartPetscObj< Mat > shellAij
boost::shared_ptr< MoFEM::Core > corePtr
boost::shared_ptr< PostProcEle > postProcPtr
PetscScalar stepSizeReduction
MoFEMErrorCode evaluateReactions(const int load_step)
boost::shared_ptr< CohesiveInterfaceElement > cohesiveElementsPtr
const std::string naturalBcFeName
SmartPetscObj< SNES > snes
MoFEMErrorCode setupProblem()
[Read mesh]
MoFEMErrorCode assembleSystem()
[Boundary condition]
MoFEMErrorCode solveSystem()
[Solve]
MoFEMErrorCode outputResults()
[Solve]
boost::shared_ptr< AssembleRhsVectors > prePostProcFePtr
MoFEMErrorCode runProblem()
[Run problem]
boost::shared_ptr< ArcLengthCtx > arcCtx
boost::shared_ptr< MatrixDouble > fieldEvalDispPtr
MoFEMErrorCode evaluateFieldAtPoint(const int load_step)
[Assemble system]
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
ArcLengthInterfaceExample(moab::Interface &moab)
boost::shared_ptr< BoundaryEle > naturalBcFe
boost::shared_ptr< DomainEle > elasticRhsFe
shell matrix for arc-length method
Boundary conditions marker.
MoFEMErrorCode postProcess()
Post-processing function executed at loop completion.
AssembleRhsVectors(boost::shared_ptr< ArcLengthCtx > &arc_ptr)
boost::shared_ptr< ArcLengthCtx > arcPtr
MoFEMErrorCode preProcess()
Pre-processing function executed at loop initialization.
Constitutive (physical) equation for interface.
Add operators pushing bases from local to physical configuration.
Boundary condition manager for finite element problem setup.
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Deprecated interface functions.
Definition of the displacement bc data structure.
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 calculate residual side diagonal.
Class (Function) to enforce essential constrains.
Structure for user loop methods on finite elements.
Field evaluator interface.
static MoFEMErrorCode setMeshFileFromJson()
Set -file_name from JSON before Core is available.
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
Linear interface data structure.
Matrix manager is used to build and partition problems.
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode setMeshsetFromFile(const string file_name, const bool clean_file_options=true)
add blocksets reading config file
Specialization for MatrixDouble vector field values calculation.
Post post-proc data at points from hash maps.
Template struct for dimension-specific finite element types.
Create interface from given surface and insert flat prisms in-between.
MoFEMErrorCode getSides(const int msId, const CubitBCType cubit_bc_type, const BitRefLevel mesh_bit_level, const bool recursive, int verb=QUIET)
Store tetrahedra from each side of the interface separately in two child meshsets of the parent meshs...
MoFEMErrorCode splitSides(const EntityHandle meshset, const BitRefLevel &bit, const int msId, const CubitBCType cubit_bc_type, const bool add_interface_entities, const bool recursive=false, int verb=QUIET)
Split nodes and other entities of tetrahedra on both sides of the interface and insert flat prisms in...
Problem manager is used to build and partition problems.
Projection of edge entities with one mid-node on hierarchical basis.
intrusive_ptr for managing petsc objects
MoFEM::FEMethodsSequence FEMethodsSequence
@ CTX_SNESSETFUNCTION
Setting up nonlinear function evaluation.
@ CTX_SNESNONE
No specific SNES context.
Vec & snes_f
Reference to residual vector.
SNESContext snes_ctx
Current SNES computation context.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Vector manager is used to create vectors \mofem_vectors.
structure for Arc Length pre-conditioner