115#include <boost/python.hpp>
116#include <boost/python/def.hpp>
117#include <boost/python/numpy.hpp>
118namespace bp = boost::python;
119namespace np = boost::python::numpy;
152 boost::shared_ptr<ClosestPointProjection>
cpPtr;
156 boost::shared_ptr<ContactOps::SDFPython> sdfPythonPtr;
188 Tag th_boundary_conditions;
190 "BOUNDARY_CONDITIONS", 1, MB_TYPE_INTEGER, th_boundary_conditions,
194 if (rval_bc == MB_SUCCESS) {
196 auto yield_strength_compressive = std::numeric_limits<double>::max();
197 auto yield_strength_tension = std::numeric_limits<double>::max();
199 Tag th_compressive_yield_stress;
200 Tag th_tension_yield_stress;
203 "Yield_Strength_C", 1, MB_TYPE_DOUBLE, th_compressive_yield_stress,
207 "Yield_Strength_T", 1, MB_TYPE_DOUBLE, th_tension_yield_stress,
213 for (
auto fe_ent : fe_ents) {
218 std::vector<double> v_bc_val;
219 for (
auto node : nodes) {
222 static_cast<void *
>(&bc_val));
223 v_bc_val.push_back(bc_val);
228 if (std::find_if(v_bc_val.begin(), v_bc_val.end(), [](
int val) {
229 return val == 5 || val == 20;
230 }) != v_bc_val.end()) {
232 if (rval_compressive == MB_SUCCESS) {
236 &yield_strength_compressive);
238 MOFEM_LOG(
"ADOLCPlasticityWold", Sev::warning)
239 <<
"Yield_Strength_C tag does not exist using default value";
241 if (rval_tension == MB_SUCCESS) {
244 th_tension_yield_stress, &fe_ent, 1, &yield_strength_tension);
246 MOFEM_LOG(
"ADOLCPlasticityWold", Sev::warning)
247 <<
"Yield_Strength_T tag does not exist using default value";
262 enum bases { AINSWORTH, DEMKOWICZ, LASBASETOPT };
263 const char *list_bases[LASBASETOPT] = {
"ainsworth",
"demkowicz"};
264 PetscInt choice_base_value = AINSWORTH;
266 LASBASETOPT, &choice_base_value, PETSC_NULL);
273 switch (choice_base_value) {
277 <<
"Set AINSWORTH_LEGENDRE_BASE for displacements";
282 <<
"Set DEMKOWICZ_JACOBI_BASE for displacements";
304 CHKERR skin.find_skin(0, body_ents,
false, skin_ents);
308 auto filter_blocks = [&](
auto skin) {
309 bool is_contact_block =
false;
314 (boost::format(
"%s(.*)") %
"CONTACT").str()
323 <<
"Find contact block set: " <<
m->getName();
324 auto meshset =
m->getMeshset();
325 Range contact_meshset_range;
327 meshset,
SPACE_DIM - 1, contact_meshset_range,
true);
330 contact_meshset_range);
331 contact_range.merge(contact_meshset_range);
333 if (is_contact_block) {
335 <<
"Nb entities in contact surface: " << contact_range.size();
337 skin = intersect(skin, contact_range);
344 ParallelComm *pcomm =
346 CHKERR pcomm->filter_pstatus(skin, PSTATUS_SHARED | PSTATUS_MULTISHARED,
347 PSTATUS_NOT, -1, &boundary_ents);
348 return boundary_ents;
362 sdfPythonPtr = boost::make_shared<ContactOps::SDFPython>();
363 CHKERR sdfPythonPtr->sdfInit(
"sdf.py");
364 ContactOps::sdfPythonWeakPtr = sdfPythonPtr;
372 auto project_ho_geometry = [&]() {
376 PetscBool project_geometry = PETSC_TRUE;
378 &project_geometry, PETSC_NULL);
379 if (project_geometry) {
380 CHKERR project_ho_geometry();
394 VonMissesPlaneStress,
396 HeterogeneousParaboloidal,
399 const char *list_materials[LastModel] = {
"VonMisses",
"VonMissesPlaneStress",
400 "Paraboloidal",
"HeterogeneousParaboloidal"};
401 PetscInt choice_material = VonMisses;
403 LastModel, &choice_material, PETSC_NULL);
405 switch (choice_material) {
409 case VonMissesPlaneStress:
412 "VonMissesPlaneStrain is only for 2D case");
418 case HeterogeneousParaboloidal:
426 cpPtr->integrationRule = [](int, int,
int p) {
return 2 * (p - 2); };
440 auto time_scale = boost::make_shared<TimeScale>();
442 auto rule = [](int, int,
int p) {
return 2 * p; };
443 CHKERR pipeline_mng->setDomainRhsIntegrationRule(
cpPtr->integrationRule);
444 CHKERR pipeline_mng->setDomainLhsIntegrationRule(
cpPtr->integrationRule);
445 CHKERR pipeline_mng->setBoundaryRhsIntegrationRule(rule);
446 CHKERR pipeline_mng->setBoundaryLhsIntegrationRule(rule);
449 pipeline_mng->getOpBoundaryLhsPipeline(), {HDIV},
"GEOMETRY");
450 pipeline_mng->getOpBoundaryLhsPipeline().push_back(
454 pipeline_mng->getOpBoundaryRhsPipeline(), {HDIV},
"GEOMETRY");
455 pipeline_mng->getOpBoundaryRhsPipeline().push_back(
460 pipeline_mng->getOpBoundaryRhsPipeline(),
mField,
"U", {time_scale},
464 pipeline_mng->getOpBoundaryLhsPipeline(),
mField,
"U", Sev::inform);
469 pipeline_mng->getOpBoundaryLhsPipeline(),
"SIGMA",
"U");
472 mField, pipeline_mng->getOpBoundaryLhsPipeline(),
473 simple->getDomainFEName(),
"SIGMA",
"U",
"GEOMETRY",
474 cpPtr->integrationRule);
478 pipeline_mng->getOpBoundaryRhsPipeline(),
"SIGMA",
"U");
483 pipeline_mng->getOpDomainRhsPipeline(),
mField,
"U", {time_scale},
484 "BODY_FORCE", Sev::inform);
487 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"REMOVE_X",
489 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"REMOVE_Y",
491 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"REMOVE_Z",
494 for (
auto b : {
"FIX_X",
"REMOVE_X"})
495 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(), b,
496 "SIGMA", 0, 0,
false,
true);
497 for (
auto b : {
"FIX_Y",
"REMOVE_Y"})
498 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(), b,
499 "SIGMA", 1, 1,
false,
true);
500 for (
auto b : {
"FIX_Z",
"REMOVE_Z"})
501 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(), b,
502 "SIGMA", 2, 2,
false,
true);
503 for (
auto b : {
"FIX_ALL",
"REMOVE_ALL"})
504 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(), b,
505 "SIGMA", 0, 3,
false,
true);
506 CHKERR bc_mng->removeBlockDOFsOnEntities(
507 simple->getProblemName(),
"NO_CONTACT",
"SIGMA", 0, 3,
false,
true);
511 simple->getProblemName(),
"U");
524 auto add_domain_ops_lhs = [&](
auto &pip) {
530 auto common_data_ptr = boost::make_shared<ADOLCPlasticity::CommonData>();
535 mField,
"U", pip,
"ADOLCMAT", common_data_ptr,
cpPtr);
540 typename B::template OpGradTensorGrad<1, SPACE_DIM, SPACE_DIM, 1>;
543 new OpKPiola(
"U",
"U", common_data_ptr->getMatTangentPtr()));
546 "U", common_data_ptr->getGradAtGaussPtsPtr()));
548 mField,
"U", pip,
"ADOLCMAT", common_data_ptr,
cpPtr);
554 auto add_domain_ops_rhs = [&](
auto &pip) {
560 auto common_data_ptr = boost::make_shared<ADOLCPlasticity::CommonData>();
565 mField,
"U", pip,
"ADOLCMAT", common_data_ptr,
cpPtr);
574 "U", common_data_ptr->getGradAtGaussPtsPtr()));
576 mField,
"U", pip,
"ADOLCMAT", common_data_ptr,
cpPtr);
588 CHKERR add_domain_ops_lhs(pipeline_mng->getOpDomainLhsPipeline());
590 CHKERR add_domain_ops_rhs(pipeline_mng->getOpDomainRhsPipeline());
604 std::pair<boost::shared_ptr<PostProcEleDomain>,
605 boost::shared_ptr<PostProcEleBdy>>
607 boost::shared_ptr<DomainEle> reaction_fe,
608 std::vector<boost::shared_ptr<ScalingMethod>> smv)
617 auto get_integrate_traction = [&]() {
618 auto integrate_traction = boost::make_shared<BoundaryEle>(*m_field_ptr);
619 auto common_data_ptr = boost::make_shared<ContactOps::CommonData>();
622 integrate_traction->getOpPtrVector(), {HDIV},
"GEOMETRY")),
626 integrate_traction->getOpPtrVector().push_back(
628 integrate_traction->getRuleHook = [](int, int,
int approx_order) {
635 integrate_traction->getOpPtrVector(),
"SIGMA", 0)),
636 "push operators to calculate traction");
638 return integrate_traction;
650 auto print_traction = [&](
const std::string msg) {
657 MOFEM_LOG_C(
"CONTACT", Sev::inform,
"%s time %3.4e %3.4e %3.4e %3.4e",
658 msg.c_str(),
ts_t, t_ptr[0], t_ptr[1], t_ptr[2]);
666 auto make_vtk = [&]() {
672 "out_plastic_" + boost::lexical_cast<std::string>(
ts_step) +
679 "out_skin_plastic_" + boost::lexical_cast<std::string>(
ts_step) +
694 CHKERR VecGhostUpdateBegin(
fRes, ADD_VALUES, SCATTER_REVERSE);
695 CHKERR VecGhostUpdateEnd(
fRes, ADD_VALUES, SCATTER_REVERSE);
705 <<
"Residual norm " << nrm <<
" at time step " <<
ts_step;
709 auto calculate_traction = [&] {
719 auto get_min_max_displacement = [&]() {
724 std::array<double, 4> a_min = {DBL_MAX, DBL_MAX, DBL_MAX, 0};
725 std::array<double, 4> a_max = {-DBL_MAX, -DBL_MAX, -DBL_MAX, 0};
727 auto get_min_max = [&](boost::shared_ptr<FieldEntity> field_entity_ptr) {
730 for (
auto v : field_entity_ptr->getEntFieldData()) {
731 a_min[d] = std::min(a_min[d],
v);
732 a_max[d] = std::max(a_max[d],
v);
744 get_min_max,
"U", &verts);
746 auto mpi_reduce = [&](
auto &
a,
auto op) {
747 std::array<double, 3> a_mpi = {0, 0, 0};
748 MPI_Allreduce(
a.data(), a_mpi.data(), 3, MPI_DOUBLE, op,
753 auto a_min_mpi = mpi_reduce(a_min, MPI_MIN);
754 auto a_max_mpi = mpi_reduce(a_max, MPI_MAX);
757 <<
"Min displacement " << a_min_mpi[0] <<
" " << a_min_mpi[1] <<
" "
760 <<
"Max displacement " << a_max_mpi[0] <<
" " << a_max_mpi[1] <<
" "
764 CHKERR get_min_max_displacement();
766 CHKERR calculate_traction();
767 CHKERR print_traction(
"Contact force");
775 <<
"Time: " << this->
ts_t <<
" scale: " <<
scale;
800 auto dm =
simple->getDM();
801 auto time_scale = boost::make_shared<TimeScale>();
805 auto create_post_proc_fe = [dm,
this,
simple]() {
809 auto post_proc_ele_domain = [
this](
auto &pip_domain,
auto &fe_name) {
812 pip_domain, {
H1,
HDIV},
"GEOMETRY");
817 auto grad_ptr = boost::make_shared<MatrixDouble>();
818 pip_domain.push_back(
828 pip_domain.push_back(op_this);
832 auto fe_physics = op_this->getThisFEPtr();
834 auto evaluate_stress_on_physical_element = [&]() {
836 fe_physics->getRuleHook =
cpPtr->integrationRule;
838 fe_physics->getOpPtrVector(), {H1});
839 auto common_data_ptr =
840 boost::make_shared<ADOLCPlasticity::CommonData>();
846 mField,
"U", fe_physics->getOpPtrVector(),
"ADOLCMAT", common_data_ptr,
cpPtr);
849 fe_physics->getOpPtrVector().push_back(
851 "U", common_data_ptr->getGradAtGaussPtsPtr()));
852 CHKERR cpPtr->addMatBlockOps(
mField, fe_physics->getOpPtrVector(),
"ADOLCMAT", Sev::inform);
856 return common_data_ptr;
859 auto dg_projection_froward_and_back = [&](
auto &common_data_ptr) {
862 auto entity_data_l2 =
863 boost::make_shared<EntitiesFieldData>(MBENTITYSET);
865 boost::make_shared<MatrixDouble>();
870 auto coeffs_ptr_stress = boost::make_shared<MatrixDouble>();
873 common_data_ptr->getStressMatrixPtr(), coeffs_ptr_stress, mass_ptr,
876 auto coeffs_ptr_plastic_strain = boost::make_shared<MatrixDouble>();
878 common_data_ptr->getPlasticStrainMatrixPtr(),
879 coeffs_ptr_plastic_strain, mass_ptr, entity_data_l2,
approxBase,
885 common_data_ptr->getStressMatrixPtr(), coeffs_ptr_stress,
888 common_data_ptr->getPlasticStrainMatrixPtr(),
889 coeffs_ptr_plastic_strain, entity_data_l2,
approxBase,
L2));
892 auto common_data_ptr = evaluate_stress_on_physical_element();
893 dg_projection_froward_and_back(common_data_ptr);
895 return boost::make_tuple(grad_ptr, common_data_ptr->getStressMatrixPtr(),
896 common_data_ptr->getPlasticStrainMatrixPtr());
902 auto add_post_proc_map = [&](
auto post_proc_fe,
auto u_ptr,
auto grad_ptr,
903 auto stress_ptr,
auto plastic_strain_ptr,
904 auto contact_stress_ptr,
auto X_ptr) {
906 post_proc_fe->getOpPtrVector().push_back(
908 new OpPPMapSPACE_DIM(
910 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
914 {{
"U", u_ptr}, {
"GEOMETRY", X_ptr}},
916 {{
"GRAD", grad_ptr}, {
"SIGMA", contact_stress_ptr}},
926 post_proc_fe->getOpPtrVector().push_back(
930 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
936 {{
"PK1", stress_ptr}},
938 {{
"PLASTIC_STRAIN", plastic_strain_ptr}}
944 post_proc_fe->getOpPtrVector().push_back(
948 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
956 {{
"STRESS", stress_ptr}, {
"PLASTIC_STRAIN", plastic_strain_ptr}}
966 auto vol_post_proc = [
this,
simple, post_proc_ele_domain,
967 add_post_proc_map]() {
968 PetscBool post_proc_vol = PETSC_FALSE;
970 post_proc_vol = PETSC_TRUE;
973 &post_proc_vol, PETSC_NULL);
974 if (post_proc_vol == PETSC_FALSE)
975 return boost::shared_ptr<PostProcEleDomain>();
976 auto post_proc_fe = boost::make_shared<PostProcEleDomain>(mField);
977 auto u_ptr = boost::make_shared<MatrixDouble>();
978 post_proc_fe->getOpPtrVector().push_back(
980 auto X_ptr = boost::make_shared<MatrixDouble>();
981 post_proc_fe->getOpPtrVector().push_back(
983 auto contact_stress_ptr = boost::make_shared<MatrixDouble>();
985 post_proc_fe->getOpPtrVector().push_back(
987 "SIGMA", contact_stress_ptr));
989 contact_stress_ptr =
nullptr;
991 auto [grad_ptr, stress_ptr, plastic_strain_ptr] = post_proc_ele_domain(
992 post_proc_fe->getOpPtrVector(),
simple->getDomainFEName());
994 return add_post_proc_map(post_proc_fe, u_ptr, grad_ptr, stress_ptr,
995 plastic_strain_ptr, contact_stress_ptr, X_ptr);
998 auto skin_post_proc = [
this,
simple, post_proc_ele_domain,
999 add_post_proc_map]() {
1002 PetscBool post_proc_skin = PETSC_TRUE;
1004 post_proc_skin = PETSC_FALSE;
1007 &post_proc_skin, PETSC_NULL);
1009 if (post_proc_skin == PETSC_FALSE)
1010 return boost::shared_ptr<PostProcEleBdy>();
1012 auto post_proc_fe = boost::make_shared<PostProcEleBdy>(mField);
1013 auto u_ptr = boost::make_shared<MatrixDouble>();
1014 post_proc_fe->getOpPtrVector().push_back(
1016 auto X_ptr = boost::make_shared<MatrixDouble>();
1017 post_proc_fe->getOpPtrVector().push_back(
1019 auto contact_stress_ptr = boost::make_shared<MatrixDouble>();
1022 auto [grad_ptr, stress_ptr, plastic_strain_ptr] = post_proc_ele_domain(
1023 op_loop_side->getOpPtrVector(),
simple->getDomainFEName());
1025 op_loop_side->getOpPtrVector().push_back(
1027 "SIGMA", contact_stress_ptr));
1029 contact_stress_ptr =
nullptr;
1031 post_proc_fe->getOpPtrVector().push_back(op_loop_side);
1033 return add_post_proc_map(post_proc_fe, u_ptr, grad_ptr, stress_ptr,
1034 plastic_strain_ptr, contact_stress_ptr, X_ptr);
1037 return std::make_pair(vol_post_proc(), skin_post_proc());
1040 auto create_reaction_fe = [&]() {
1041 auto fe_ptr = boost::make_shared<DomainEle>(mField);
1042 fe_ptr->getRuleHook = cpPtr->integrationRule;
1044 auto &pip = fe_ptr->getOpPtrVector();
1046 auto common_data_ptr = boost::make_shared<ADOLCPlasticity::CommonData>();
1051 mField,
"U", pip,
"ADOLCMAT", common_data_ptr, cpPtr);
1060 "U", common_data_ptr->getGradAtGaussPtsPtr()));
1062 mField,
"U", pip,
"ADOLCMAT", common_data_ptr, cpPtr);
1068 auto add_extra_finite_elements_to_ksp_solver_pipelines = [&]() {
1071 auto pre_proc_ptr = boost::make_shared<FEMethod>();
1072 auto post_proc_rhs_ptr = boost::make_shared<FEMethod>();
1073 auto post_proc_lhs_ptr = boost::make_shared<FEMethod>();
1075 auto get_bc_hook_rhs = [
this, pre_proc_ptr, time_scale]() {
1078 {time_scale},
false)();
1082 pre_proc_ptr->preProcessHook = get_bc_hook_rhs;
1084 auto get_post_proc_hook_rhs = [
this, post_proc_rhs_ptr]() {
1087 mField, post_proc_rhs_ptr,
nullptr, Sev::verbose)();
1089 mField, post_proc_rhs_ptr, 1.)();
1092 auto get_post_proc_hook_lhs = [
this, post_proc_lhs_ptr]() {
1095 mField, post_proc_lhs_ptr, 1.)();
1098 post_proc_rhs_ptr->postProcessHook = get_post_proc_hook_rhs;
1099 post_proc_lhs_ptr->postProcessHook = get_post_proc_hook_lhs;
1103 ts_ctx_ptr->getPreProcessIFunction().push_front(pre_proc_ptr);
1104 ts_ctx_ptr->getPreProcessIJacobian().push_front(pre_proc_ptr);
1105 ts_ctx_ptr->getPostProcessIFunction().push_back(post_proc_rhs_ptr);
1106 ts_ctx_ptr->getPostProcessIJacobian().push_back(post_proc_lhs_ptr);
1112 CHKERR add_extra_finite_elements_to_ksp_solver_pipelines();
1114 auto create_monitor_fe = [dm, time_scale](
auto &&post_proc_fe,
1115 auto &&reaction_fe) {
1116 return boost::make_shared<Monitor>(
1117 dm, post_proc_fe, reaction_fe,
1118 std::vector<boost::shared_ptr<ScalingMethod>>{time_scale});
1122 auto set_up_post_step = [&](
auto ts) {
1127 auto create_update_ptr = [&]() {
1128 auto fe_ptr = boost::make_shared<DomainEle>(mField);
1129 fe_ptr->getRuleHook = cpPtr->integrationRule;
1132 auto common_data_ptr = boost::make_shared<ADOLCPlasticity::CommonData>();
1137 mField,
"U", fe_ptr->getOpPtrVector(),
"ADOLCMAT", common_data_ptr,
1140 fe_ptr->getOpPtrVector().push_back(
1142 "U", common_data_ptr->getGradAtGaussPtsPtr()));
1143 CHKERR cpPtr->addMatBlockOps(mField, fe_ptr->getOpPtrVector(),
1144 "ADOLCMAT", Sev::noisy);
1145 fe_ptr->getOpPtrVector().push_back(
1152 "ADOLCMAT", common_data_ptr, cpPtr),
1163 auto ts_step_post_proc = [](TS ts) {
1172 CHKERR TSSetPostStep(ts, ts_step_post_proc);
1178 auto set_up_monitor = [&](
auto ts) {
1180 boost::shared_ptr<FEMethod> null_fe;
1182 create_monitor_fe(create_post_proc_fe(), create_reaction_fe());
1184 null_fe, monitor_ptr);
1188 auto set_section_monitor = [&](
auto solver) {
1191 CHKERR TSGetSNES(solver, &snes);
1192 CHKERR SNESMonitorSet(snes,
1195 (
void *)(snes_ctx_ptr.get()),
nullptr);
1199 auto set_up_adapt = [&](
auto ts) {
1203 CHKERR TSGetAdapt(ts, &adapt);
1208 auto ts = pipeline_mng->createTSIM();
1212 CHKERR TSSetMaxTime(ts, ftime);
1213 CHKERR TSSetExactFinalTime(ts, TS_EXACTFINALTIME_MATCHSTEP);
1219 CHKERR set_section_monitor(ts);
1222 CHKERR set_up_monitor(ts);
1223 CHKERR set_up_post_step(ts);
1225 CHKERR TSSetFromOptions(ts);
1227 CHKERR TSSolve(ts, NULL);
1230 CHKERR TSGetTime(ts, &ftime);
1232 PetscInt steps, snesfails, rejects, nonlinits, linits;
1233 CHKERR TSGetStepNumber(ts, &steps);
1234 CHKERR TSGetSNESFailures(ts, &snesfails);
1235 CHKERR TSGetStepRejections(ts, &rejects);
1236 CHKERR TSGetSNESIterations(ts, &nonlinits);
1237 CHKERR TSGetKSPIterations(ts, &linits);
1239 "steps %d (%d rejected, %d SNES fails), ftime %g, nonlinits "
1241 steps, rejects, snesfails, ftime, nonlinits, linits);
1252 auto dm =
simple->getDM();
1258 CHKERR VecNorm(T, NORM_2, &nrm2);
1259 MOFEM_LOG(
"PlasticPrb", Sev::inform) <<
"Solution norm " << nrm2;
1261 auto post_proc_norm_fe = boost::make_shared<DomainEle>(
mField);
1263 post_proc_norm_fe->getRuleHook =
cpPtr->integrationRule;
1266 post_proc_norm_fe->getOpPtrVector(), {H1});
1268 enum NORMS { U_NORM_L2 = 0, PIOLA_NORM, LAST_NORM };
1272 CHKERR VecZeroEntries(norms_vec);
1274 auto u_ptr = boost::make_shared<MatrixDouble>();
1275 post_proc_norm_fe->getOpPtrVector().push_back(
1278 post_proc_norm_fe->getOpPtrVector().push_back(
1284 CHKERR VecAssemblyBegin(norms_vec);
1285 CHKERR VecAssemblyEnd(norms_vec);
1289 const double *norms;
1290 CHKERR VecGetArrayRead(norms_vec, &norms);
1292 <<
"norm_u: " << std::scientific << std::sqrt(norms[U_NORM_L2]);
1293 CHKERR VecRestoreArrayRead(norms_vec, &norms);
1303 PetscInt test_nb = 0;
1304 PetscBool test_flg = PETSC_FALSE;
1313 CHKERR VecNorm(T, NORM_2, &nrm2);
1314 MOFEM_LOG(
"PlasticPrb", Sev::verbose) <<
"Regression norm " << nrm2;
1315 double regression_value = 0;
1321 if (fabs(nrm2 - regression_value) > 1e-2)
1323 "Regression test field; wrong norm value. %6.4e != %6.4e", nrm2,
1352 const char param_file[] =
"param_file.petsc";
1356 auto core_log = logging::core::get();
1372 DMType dm_name =
"DMMOFEM";
1377 moab::Core mb_instance;
1378 moab::Interface &moab = mb_instance;
1396 if (Py_FinalizeEx() < 0) {
Matetial models for plasticity.
static auto filter_true_skin(MoFEM::Interface &m_field, Range &&skin)
static auto get_skin(MoFEM::Interface &m_field, Range body_ents)
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
#define MOFEM_LOG_C(channel, severity, format,...)
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
void simple(double P1[], double P2[], double P3[], double c[], const int N)
static char help[]
[Check]
static boost::shared_ptr< TSUpdate > ts_update_ptr
PipelineManager::ElementsAndOpsByDim< SPACE_DIM >::DomainEle DomainEle
constexpr FieldSpace CONTACT_SPACE
ElementsAndOps< SPACE_DIM >::BoundaryEle BoundaryEle
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
[Define dimension]
#define CATCH_ERRORS
Catch errors.
FieldApproximationBase
approximation base
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base nme:nme847.
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
FieldSpace
approximation spaces
@ L2
field with C-1 continuity
@ HCURL
field with continuous tangents
@ HDIV
field with continuous normal traction
#define MYPCOMM_INDEX
default communicator number PCOMM
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
PostProcEleByDim< SPACE_DIM >::PostProcEleDomain PostProcEleDomain
PostProcEleByDim< SPACE_DIM >::PostProcEleBdy PostProcEleBdy
MoFEMErrorCode opFactoryDomainUpdate(MoFEM::Interface &m_field, Pip &pip, std::string block_name, boost::shared_ptr< CommonData > common_data_ptr, boost::shared_ptr< ClosestPointProjection > cp_ptr)
Push operators to update history variables.
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
auto createDMVector(DM dm)
Get smart vector from DM.
PetscErrorCode DMoFEMGetInterfacePtr(DM dm, MoFEM::Interface **m_field_ptr)
Get pointer to MoFEM::Interface.
virtual MoFEMErrorCode get_field_entities_by_type(const std::string name, EntityType type, Range &ents) const =0
get entities in the field by type
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 MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
virtual MoFEMErrorCode loop_dofs(const Problem *problem_ptr, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)=0
Make a loop over dofs.
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
const double v
phase velocity of light in medium (cm/ns)
MoFEMErrorCode opFactoryDomainHenckyStrainLhs(MoFEM::Interface &m_field, std::string field_name, Pip &pip, std::string block_name, boost::shared_ptr< ADOLCPlasticity::CommonData > common_data_ptr, boost::shared_ptr< ClosestPointProjection > cp_ptr)
MoFEMErrorCode opFactoryDomainHenckyStrainRhs(MoFEM::Interface &m_field, std::string field_name, Pip &pip, std::string block_name, boost::shared_ptr< ADOLCPlasticity::CommonData > common_data_ptr, boost::shared_ptr< ClosestPointProjection > cp_ptr)
auto createMaterial(std::array< int, ClosestPointProjection::LAST_TAPE > tapes_tags={0, 1, 2})
ForcesAndSourcesCore::UserDataOperator * getRawPtrOpCalculateStress(MoFEM::Interface &m_field, boost::shared_ptr< CommonData > common_data_ptr, boost::shared_ptr< ClosestPointProjection > cp_ptr, bool calc_lhs)
Get opreator to calulate stress.
boost::shared_ptr< TSUpdate > createTSUpdate(std::string fe_name, boost::shared_ptr< FEMethod > fe_ptr)
MoFEMErrorCode opFactoryDomainLhs(MoFEM::Interface &m_field, boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pip, std::string field_name, boost::shared_ptr< HenckyOps::CommonData > common_ptr, Sev sev)
MoFEMErrorCode opFactoryDomainRhs(MoFEM::Interface &m_field, boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pip, std::string field_name, boost::shared_ptr< HenckyOps::CommonData > common_ptr, Sev sev)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
PetscErrorCode DMMoFEMTSSetMonitor(DM dm, TS ts, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
Set Monitor To TS solver.
auto getDMTsCtx(DM dm)
Get TS context data structure used by DM.
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
MoFEMErrorCode MoFEMSNESMonitorFields(SNES snes, PetscInt its, PetscReal fgnorm, SnesCtx *snes_ctx)
Sens monitor printing residual field by field.
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
PetscErrorCode PetscOptionsGetScalar(PetscOptions *, const char pre[], const char name[], PetscScalar *dval, PetscBool *set)
auto createVectorMPI(MPI_Comm comm, PetscInt n, PetscInt N)
Create MPI Vector.
PetscErrorCode PetscOptionsGetEList(PetscOptions *, const char pre[], const char name[], const char *const *list, PetscInt next, PetscInt *value, PetscBool *set)
std::vector< boost::shared_ptr< ScalingMethod > > VecOfTimeScalingMethods
Vector of time scaling methods.
auto getDMSnesCtx(DM dm)
Get SNES context data structure used by DM.
PetscErrorCode TSAdaptCreateMoFEM(TSAdapt adapt)
Craete MOFEM adapt.
FormsIntegrators< DomainEleOp >::Assembly< A >::LinearForm< I >::OpGradTimesTensor< 1, FIELD_DIM, SPACE_DIM > OpGradTimesTensor
#define EXECUTABLE_DIMENSION
ElementsAndOps< SPACE_DIM >::SideEle SideEle
constexpr FieldSpace CONTACT_SPACE
static constexpr int approx_order
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpGradTensorGrad< 1, SPACE_DIM, SPACE_DIM, 1 > OpKPiola
[Only used for dynamics]
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpGradTimesTensor< 1, SPACE_DIM, SPACE_DIM > OpInternalForcePiola
FTensor::Index< 'm', 3 > m
PipelineManager::ElementsAndOpsByDim< 2 >::FaceSideEle SideEle
PipelineManager::ElementsAndOpsByDim< 3 >::FaceSideEle SideEle
Add operators pushing bases from local to physical configuration.
boost::weak_ptr< CacheTuple > getCacheWeakPtr() const
Get the cache weak ptr object.
Simple interface for fast problem set-up.
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
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.
Data on single entity (This is passed as argument to DataOperator::doWork)
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.
Class (Function) to calculate residual side diagonal.
structure for User Loop Methods on finite elements
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.
Interface for managing meshsets containing materials and boundary conditions.
Get norm of input MatrixDouble for Tensor1.
Calculate tenor field using vectorial base, i.e. Hdiv/Hcurl.
Get field gradients at integration pts for scalar filed rank 0, i.e. vector field.
Get values at integration pts for tensor filed rank 1, i.e. vector field.
Element used to execute operators on side of the element.
Execute "this" element in the operator.
Post post-proc data at points from hash maps.
PipelineManager interface.
Projection of edge entities with one mid-node on hierarchical basis.
Simple interface for fast problem set-up.
intrusive_ptr for managing petsc objects
PetscInt ts_step
time step number
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
[Push operators to pipeline]
boost::shared_ptr< PostProcEleDomain > domainPostProcFe
boost::shared_ptr< BoundaryEle > integrateTraction
boost::shared_ptr< FEMethod > reactionFE
Monitor(SmartPetscObj< DM > dm, std::pair< boost::shared_ptr< PostProcEleDomain >, boost::shared_ptr< PostProcEleBdy > > pair_post_proc_fe, boost::shared_ptr< DomainEle > reaction_fe, std::vector< boost::shared_ptr< ScalingMethod > > smv)
VecOfTimeScalingMethods vecOfTimeScalingMethods
boost::shared_ptr< PostProcEleBdy > skinPostProcFe
SmartPetscObj< Vec > fRes
MoFEMErrorCode postProcess()
function is run at the end of loop
PlasticProblem(MoFEM::Interface &m_field)
MoFEMErrorCode setupProblem()
[Read mesh]
MoFEMErrorCode readMesh()
[Run problem]
FieldApproximationBase approxBase
MoFEMErrorCode outputResults()
[Getting norms]
boost::shared_ptr< ClosestPointProjection > cpPtr
MoFEMErrorCode checkResults()
[Postprocessing results]
MoFEMErrorCode boundaryCondition()
[Set up problem]
MoFEM::Interface & mField
PetscBool largeStrain
Large strain flag.
MoFEMErrorCode assembleSystem()
[Boundary condition]
MoFEMErrorCode gettingNorms()
[Solve]
MoFEMErrorCode runProblem()
[Run problem]
MoFEMErrorCode solveSystem()
[Solve]