v0.16.3
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Contact Struct Reference
Collaboration diagram for Contact:
[legend]

Classes

struct  ScaledTimeScale
 

Public Member Functions

 Contact (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 [Run problem]
 

Private Member Functions

MoFEMErrorCode setupProblem ()
 [Run problem]
 
MoFEMErrorCode createCommonData ()
 [Set up problem]
 
MoFEMErrorCode bC ()
 [Create common data]
 
MoFEMErrorCode OPs ()
 [Boundary condition]
 
MoFEMErrorCode tsSolve ()
 
MoFEMErrorCode checkResults ()
 [Solve]
 

Private Attributes

MoFEM::Interface & mField
 
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uXScatter
 
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uYScatter
 
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uZScatter
 
boost::shared_ptr< MFrontInterface > mfrontInterfacePtr
 
boost::shared_ptr< Monitor > monitorPtr
 

Detailed Description

Definition at line 112 of file contact.cpp.

Constructor & Destructor Documentation

◆ Contact()

Contact::Contact ( MoFEM::Interface &  m_field)
inline

Definition at line 114 of file contact.cpp.

115 : mField(m_field), mfrontInterfacePtr(nullptr) {}
boost::shared_ptr< MFrontInterface > mfrontInterfacePtr
Definition contact.cpp:133
MoFEM::Interface & mField
Definition contact.cpp:120

Member Function Documentation

◆ bC()

MoFEMErrorCode Contact::bC ( )
private

[Create common data]

[Boundary condition]

Definition at line 446 of file contact.cpp.

446 {
448 auto bc_mng = mField.getInterface<BcManager>();
450
451 for (auto f : {"U", "SIGMA"}) {
452 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(),
453 "REMOVE_X", f, 0, 0);
454 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(),
455 "REMOVE_Y", f, 1, 1);
456 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(),
457 "REMOVE_Z", f, 2, 2);
458 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(),
459 "REMOVE_ALL", f, 0, 3);
460 }
461
462 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(), "FIX_X",
463 "SIGMA", 0, 0, false, true);
464 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(), "FIX_Y",
465 "SIGMA", 1, 1, false, true);
466 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(), "FIX_Z",
467 "SIGMA", 2, 2, false, true);
468 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(), "FIX_ALL",
469 "SIGMA", 0, 3, false, true);
470 CHKERR bc_mng->removeBlockDOFsOnEntities(
471 simple->getProblemName(), "NO_CONTACT", "SIGMA", 0, 3, false, true);
472
473 // Note remove has to be always before push. Then node marking will be
474 // corrupted.
475 CHKERR bc_mng->pushMarkDOFsOnEntities<DisplacementCubitBcData>(
476 simple->getProblemName(), "U");
477
479}
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition acoustic.cpp:69
#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.
Boundary condition manager for finite element problem setup.
Definition of the displacement bc data structure.
Definition BCData.hpp:72
Simple interface for fast problem set-up.
Definition Simple.hpp:27
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

◆ checkResults()

MoFEMErrorCode Contact::checkResults ( )
private

[Solve]

[Check]

Definition at line 874 of file contact.cpp.

874 {
877 auto dm = mField.getInterface<Simple>()->getDM();
878
879 // totalTractionAndArea is a ghost vector fully owned by rank 0 (see
880 // ContactOps::CommonData::createTotalTraction); broadcast it so every rank
881 // runs the collective checks below with identical values.
882 double t[LAST_TOTAL_TRACTION_AND_AREA] = {0., 0., 0., 0., 0.};
883 if (!mField.get_comm_rank()) {
884 const double *t_ptr;
886 &t_ptr);
887 for (int i = 0; i != LAST_TOTAL_TRACTION_AND_AREA; ++i)
888 t[i] = t_ptr[i];
890 &t_ptr);
891 }
892 CHKERR MPI_Bcast(t, LAST_TOTAL_TRACTION_AND_AREA, MPI_DOUBLE, 0,
893 mField.get_comm());
894
895 auto add_case = [&](int number, const std::string &name, double hertz_force,
896 double fem_force, double tol_force,
897 double analytical_active_area, double tol_area,
898 TestingInterface::TestHook pressure_check = {}) {
899 return testing->addTestCommandLine(
900 "", number, name,
901 [testing, hertz_force, fem_force, tol_force, analytical_active_area,
902 tol_area, fem_active_area = t[AREA_ACTIVE], pressure_check]() {
904 CHKERR testing->checkValue<TestType::SCALAR>(
905 "Hertz contact force", fem_force, hertz_force, {0., tol_force});
906 CHKERR testing->checkValue<TestType::SCALAR>(
907 "contact active area", fem_active_area, analytical_active_area,
908 {tol_area, 0.});
909 if (pressure_check)
910 CHKERR pressure_check();
912 });
913 };
914
915 CHKERR add_case(1, "hertz plane stress", 3.927, t[TY], 1e-3, 1.0, 3e-2);
916 CHKERR add_case(2, "hertz plane strain", 4.675, t[TY], 1e-3, 1.0, 3e-2,
917 [dm, &m_field = mField]() {
919 m_field, 7.5,
920 "hertz plane strain pressure norm")(dm.get());
921 });
922 CHKERR add_case(3, "hertz 3d", 3.968, t[TZ], 2e-3, M_PI / 4, 0.2);
923 CHKERR add_case(4, "hertz axisymmetric flat", 15.873, t[TY], 5e-3, M_PI, 0.2);
924 CHKERR add_case(5, "hertz axisymmetric sphere", 15.873, t[TY], 5e-3, M_PI,
925 3e-2, [dm, &m_field = mField]() {
927 m_field, 7.5,
928 "hertz axisymmetric pressure norm")(dm.get());
929 });
930 CHKERR add_case(6, "wavy 2d", 0.374, t[TY], 1e-3, 1.0, 3e-2);
931 CHKERR add_case(7, "wavy 3d", 0.5289, t[TZ], 1e-3, 1.0, 3e-2);
932
933 CHKERR testing->runTests();
934
936
938}
Vec t
Removal: the ring edge.
int number
std::string name
FTensor::Index< 'i', SPACE_DIM > i
PetscBool testing
@ LAST_TOTAL_TRACTION_AND_AREA
static SmartPetscObj< Vec > totalTractionAndArea
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
std::function< MoFEMErrorCode()> TestHook

◆ createCommonData()

MoFEMErrorCode Contact::createCommonData ( )
private

[Set up problem]

[Create common data]

Definition at line 302 of file contact.cpp.

302 {
304
305 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "", "-large_strain",
306 &is_large_strain, PETSC_NULLPTR);
307 PetscBool use_mfront = PETSC_FALSE;
308 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "", "-use_mfront", &use_mfront,
309 PETSC_NULLPTR);
310 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "", "-is_axisymmetric",
311 &is_axisymmetric, PETSC_NULLPTR);
312
313 CHKERR PetscOptionsGetScalar(PETSC_NULLPTR, "", "-scale", &scale,
314 PETSC_NULLPTR);
315 CHKERR PetscOptionsGetScalar(PETSC_NULLPTR, "", "-young_modulus",
316 &young_modulus, PETSC_NULLPTR);
317 CHKERR PetscOptionsGetScalar(PETSC_NULLPTR, "", "-poisson_ratio",
318 &poisson_ratio, PETSC_NULLPTR);
319 CHKERR PetscOptionsGetScalar(PETSC_NULLPTR, "", "-rho", &rho, PETSC_NULLPTR);
320 CHKERR PetscOptionsGetScalar(PETSC_NULLPTR, "", "-cn", &cn_contact,
321 PETSC_NULLPTR);
322 CHKERR PetscOptionsGetScalar(PETSC_NULLPTR, "", "-spring_stiffness",
323 &spring_stiffness, PETSC_NULLPTR);
324 CHKERR PetscOptionsGetScalar(PETSC_NULLPTR, "", "-vis_spring_stiffness",
325 &vis_spring_stiffness, PETSC_NULLPTR);
326 CHKERR PetscOptionsGetScalar(PETSC_NULLPTR, "", "-alpha_damping",
327 &alpha_damping, PETSC_NULLPTR);
328
329 if (!use_mfront) {
330 if (!is_large_strain) {
331 MOFEM_LOG("CONTACT", Sev::inform)
332 << "Selected material model: Hooke (small strain)";
333 } else {
334 MOFEM_LOG("CONTACT", Sev::inform)
335 << "Selected material model: Hencky (finite strain)";
336 }
337 MOFEM_LOG("CONTACT", Sev::inform) << "Young modulus " << young_modulus;
338 MOFEM_LOG("CONTACT", Sev::inform) << "Poisson_ratio " << poisson_ratio;
339 } else {
340 MOFEM_LOG("CONTACT", Sev::inform) << "Using MFront for material model";
341 }
342
343 MOFEM_LOG("CONTACT", Sev::inform) << "Density " << rho;
344 MOFEM_LOG("CONTACT", Sev::inform) << "cn_contact " << cn_contact;
345 MOFEM_LOG("CONTACT", Sev::inform) << "Spring stiffness " << spring_stiffness;
346 MOFEM_LOG("CONTACT", Sev::inform)
347 << "Vis spring_stiffness " << vis_spring_stiffness;
348
349 MOFEM_LOG("CONTACT", Sev::inform) << "alpha_damping " << alpha_damping;
350
351 PetscBool use_scale = PETSC_FALSE;
352 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "", "-use_scale", &use_scale,
353 PETSC_NULLPTR);
354 if (use_scale) {
356 }
357
358 MOFEM_LOG("CONTACT", Sev::inform) << "Scale " << scale;
359
360 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "", "-is_quasi_static",
361 &is_quasi_static, PETSC_NULLPTR);
362 MOFEM_LOG("CONTACT", Sev::inform)
363 << "Is quasi-static: " << (is_quasi_static ? "true" : "false");
364
365#ifdef ENABLE_PYTHON_BINDING
366 auto file_exists = [](std::string myfile) {
367 std::ifstream file(myfile.c_str());
368 if (file) {
369 return true;
370 }
371 return false;
372 };
373 char sdf_file_name[255] = "sdf.py";
374 PetscBool has_sdf_file_option = PETSC_FALSE;
375 CHKERR PetscOptionsGetString(PETSC_NULLPTR, PETSC_NULLPTR, "-sdf_file",
376 sdf_file_name, 255, &has_sdf_file_option);
377 if (!has_sdf_file_option) {
378 auto *json_config = mField.getInterface<JsonConfigManager>();
379 const auto contact_surface_script =
380 json_config->getPythonScriptByKey("contact_surface");
381 if (!contact_surface_script.empty()) {
382 std::strcpy(sdf_file_name, contact_surface_script.c_str());
383 MOFEM_LOG("CONTACT", Sev::inform)
384 << "Using Python script 'contact_surface' from JSON config: "
385 << sdf_file_name;
386 }
387 }
388
389 if (file_exists(sdf_file_name)) {
390 MOFEM_LOG("CONTACT", Sev::inform) << sdf_file_name << " file found";
391 sdfPythonPtr = boost::make_shared<SDFPython>();
392 CHKERR sdfPythonPtr->sdfInit(sdf_file_name);
393 CHKERR sdfPythonPtr->requireDerivatives();
394 sdfPythonWeakPtr = sdfPythonPtr;
395 } else {
396 MOFEM_LOG("CONTACT", Sev::warning) << sdf_file_name << " file NOT found";
397 }
398#endif
399
400 if (is_axisymmetric) {
401 if (SPACE_DIM == 3) {
402 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
403 "Use executable contact_2d with axisymmetric model");
404 } else {
405 if (!use_mfront) {
406 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
407 "Axisymmetric model is only available with MFront (set "
408 "use_mfront to 1)");
409 } else {
410 MOFEM_LOG("CONTACT", Sev::inform) << "Using axisymmetric model";
411 }
412 }
413 } else {
414 if (SPACE_DIM == 2) {
415 MOFEM_LOG("CONTACT", Sev::inform) << "Using plane strain model";
416 }
417 }
418
419 if (use_mfront) {
420 if (SPACE_DIM == 3) {
422 } else if (SPACE_DIM == 2) {
423 if (is_axisymmetric) {
425 } else {
427 }
428 }
429 CHKERR mfrontInterfacePtr->getCommandLineParameters();
430 }
431
433 auto dm = simple->getDM();
434 monitorPtr = boost::make_shared<Monitor>(dm, scale, mfrontInterfacePtr,
436
437 if (mfrontInterfacePtr) {
438 mfrontInterfacePtr->setMonitor(monitorPtr);
439 }
440
442}
double young_modulus
Definition contact.cpp:75
constexpr AssemblyType AT
Definition contact.cpp:27
double spring_stiffness
Definition contact.cpp:78
PetscBool is_large_strain
Definition contact.cpp:85
double rho
Definition contact.cpp:77
PetscBool is_quasi_static
[Operators used for contact]
Definition contact.cpp:69
double alpha_damping
Definition contact.cpp:80
constexpr int SPACE_DIM
Definition contact.cpp:46
double poisson_ratio
Definition contact.cpp:76
double vis_spring_stiffness
Definition contact.cpp:79
double scale
Definition contact.cpp:82
PetscBool is_axisymmetric
Definition contact.cpp:84
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
@ MOFEM_NOT_IMPLEMENTED
Definition definitions.h:32
#define MOFEM_LOG(channel, severity)
Log.
double cn_contact
Definition contact.cpp:88
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)
boost::shared_ptr< MFrontInterface > createMFrontInterface(MoFEM::Interface &m_field, ModelHypothesis mh, AssemblyType at)
create mfront interface
@ AXISYMMETRICAL
Axisymmetrical model hypothesis.
@ PLANESTRAIN
Plane strain model hypothesis.
@ TRIDIMENSIONAL
3D model hypothesis.
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
boost::shared_ptr< Monitor > monitorPtr
Definition contact.cpp:134
std::string getPythonScriptByKey(const std::string &key) const
MoFEMErrorCode getDM(DM *dm)
Get DM.
Definition Simple.cpp:802

◆ OPs()

MoFEMErrorCode Contact::OPs ( )
private

[Boundary condition]

[Push operators to pip]

[Only used for dynamics]

[Only used for dynamics]

[Only used for dynamics]

[Only used for dynamics]

[Operators used for contact]

[Operators used for contact]

[Operators used for contact]

[Operators used for contact]

Definition at line 483 of file contact.cpp.

483 {
486 auto *pip_mng = mField.getInterface<PipelineManager>();
487 auto time_scale = boost::make_shared<ScaledTimeScale>();
488 auto body_force_time_scale =
489 boost::make_shared<ScaledTimeScale>("body_force_hist.txt");
490
491 auto integration_rule_vol = [](int, int, int approx_order) {
492 return 2 * approx_order + geom_order - 1;
493 };
494 auto integration_rule_boundary = [](int, int, int approx_order) {
495 return 2 * approx_order + geom_order - 1;
496 };
497
498 auto add_domain_base_ops = [&](auto &pip) {
501 "GEOMETRY");
503 };
504
505 auto add_domain_ops_lhs = [&](auto &pip) {
507
508 //! [Only used for dynamics]
511 //! [Only used for dynamics]
512 if (is_quasi_static == PETSC_FALSE) {
513
514 auto *pip_mng = mField.getInterface<PipelineManager>();
515 auto fe_domain_lhs = pip_mng->getDomainLhsFE();
516
517 auto get_inertia_and_mass_damping =
518 [this, fe_domain_lhs](const double, const double, const double) {
519 return (rho * scale) * fe_domain_lhs->ts_aa +
520 (alpha_damping * scale) * fe_domain_lhs->ts_a;
521 };
522 pip.push_back(new OpMass("U", "U", get_inertia_and_mass_damping));
523 } else {
524
525 auto *pip_mng = mField.getInterface<PipelineManager>();
526 auto fe_domain_lhs = pip_mng->getDomainLhsFE();
527
528 auto get_inertia_and_mass_damping =
529 [this, fe_domain_lhs](const double, const double, const double) {
530 return (alpha_damping * scale) * fe_domain_lhs->ts_a;
531 };
532 pip.push_back(new OpMass("U", "U", get_inertia_and_mass_damping));
533 }
534
535 if (!mfrontInterfacePtr) {
536 if (!is_large_strain) {
537 CHKERR HookeOps::opFactoryDomainLhs<SPACE_DIM, AT, IT, DomainEleOp>(
538 mField, pip, "U", "MAT_ELASTIC", Sev::verbose, scale);
539 } else {
540 CHKERR HenckyOps::opFactoryDomainLhs<SPACE_DIM, AT, IT, DomainEleOp>(
541 mField, pip, "U", "MAT_ELASTIC", Sev::verbose, scale);
542 }
543 } else {
544 CHKERR mfrontInterfacePtr->opFactoryDomainLhs(pip, "U");
545 }
546
548 };
549
550 auto add_domain_ops_rhs = [&](auto &pip) {
552
554 pip, mField, "U", {body_force_time_scale}, Sev::inform);
555
556 //! [Only used for dynamics]
559 //! [Only used for dynamics]
560
561 // only in case of dynamics
562 if (is_quasi_static == PETSC_FALSE) {
563 auto mat_acceleration = boost::make_shared<MatrixDouble>();
565 "U", mat_acceleration));
566 pip.push_back(
567 new OpInertiaForce("U", mat_acceleration, [](double, double, double) {
568 return rho * scale;
569 }));
570 }
571
572 // only in case of viscosity
573 if (alpha_damping > 0) {
574 auto mat_velocity = boost::make_shared<MatrixDouble>();
575 pip.push_back(
576 new OpCalculateVectorFieldValuesDot<SPACE_DIM>("U", mat_velocity));
577 pip.push_back(
578 new OpInertiaForce("U", mat_velocity, [](double, double, double) {
579 return alpha_damping * scale;
580 }));
581 }
582
583 if (!mfrontInterfacePtr) {
584 if (!is_large_strain) {
585 CHKERR HookeOps::opFactoryDomainRhs<SPACE_DIM, AT, IT, DomainEleOp>(
586 mField, pip, "U", "MAT_ELASTIC", Sev::inform, 1, scale);
587 } else {
588 CHKERR HenckyOps::opFactoryDomainRhs<SPACE_DIM, AT, IT, DomainEleOp>(
589 mField, pip, "U", "MAT_ELASTIC", Sev::inform, scale);
590 }
591 } else {
592 CHKERR mfrontInterfacePtr->opFactoryDomainRhs(pip, "U");
593 }
594
595 CHKERR ContactOps::opFactoryDomainRhs<SPACE_DIM, AT, IT, DomainEleOp>(
596 pip, "SIGMA", "U", is_axisymmetric);
597
599 };
600
601 auto add_boundary_base_ops = [&](auto &pip) {
604 "GEOMETRY");
605 // We have to integrate on curved face geometry, thus integration weight
606 // have to adjusted.
607 pip.push_back(new OpSetHOWeightsOnSubDim<SPACE_DIM>());
609 };
610
611 auto add_boundary_ops_lhs = [&](auto &pip) {
613
614 //! [Operators used for contact]
617 //! [Operators used for contact]
618
619 // Add Natural BCs to LHS
621 pip, mField, "U", Sev::inform);
622
623 if (spring_stiffness > 0 || vis_spring_stiffness > 0) {
624
625 auto *pip_mng = mField.getInterface<PipelineManager>();
626 auto fe_boundary_lhs = pip_mng->getBoundaryLhsFE();
627
628 pip.push_back(new OpSpringLhs(
629 "U", "U",
630
631 [this, fe_boundary_lhs](double, double, double) {
632 return spring_stiffness * scale +
633 (vis_spring_stiffness * scale) * fe_boundary_lhs->ts_a;
634 }
635
636 ));
637 }
638
639 CHKERR
640 ContactOps::opFactoryBoundaryLhs<SPACE_DIM, AT, GAUSS, BoundaryEleOp>(
641 pip, "SIGMA", "U", is_axisymmetric);
643 DomainEle>(
644 mField, pip, simple->getDomainFEName(), "SIGMA", "U", "GEOMETRY",
645 integration_rule_vol, is_axisymmetric);
646
648 };
649
650 auto add_boundary_ops_rhs = [&](auto &pip) {
652
653 //! [Operators used for contact]
656 //! [Operators used for contact]
657
658 // Add Natural BCs to RHS
660 pip, mField, "U", {time_scale}, Sev::inform);
661
662 if (spring_stiffness > 0 || vis_spring_stiffness > 0) {
663 auto u_disp = boost::make_shared<MatrixDouble>();
664 auto dot_u_disp = boost::make_shared<MatrixDouble>();
665 pip.push_back(new OpCalculateVectorFieldValues<SPACE_DIM>("U", u_disp));
666 pip.push_back(
667 new OpCalculateVectorFieldValuesDot<SPACE_DIM>("U", dot_u_disp));
668 pip.push_back(
669 new OpSpringRhs("U", u_disp, [this](double, double, double) {
670 return spring_stiffness * scale;
671 }));
672 pip.push_back(
673 new OpSpringRhs("U", dot_u_disp, [this](double, double, double) {
675 }));
676 }
677
678 CHKERR
679 ContactOps::opFactoryBoundaryRhs<SPACE_DIM, AT, GAUSS, BoundaryEleOp>(
680 pip, "SIGMA", "U", is_axisymmetric);
681
683 };
684
685 CHKERR add_domain_base_ops(pip_mng->getOpDomainLhsPipeline());
686 CHKERR add_domain_base_ops(pip_mng->getOpDomainRhsPipeline());
687 CHKERR add_domain_ops_lhs(pip_mng->getOpDomainLhsPipeline());
688 CHKERR add_domain_ops_rhs(pip_mng->getOpDomainRhsPipeline());
689
690 CHKERR add_boundary_base_ops(pip_mng->getOpBoundaryLhsPipeline());
691 CHKERR add_boundary_base_ops(pip_mng->getOpBoundaryRhsPipeline());
692 CHKERR add_boundary_ops_lhs(pip_mng->getOpBoundaryLhsPipeline());
693 CHKERR add_boundary_ops_rhs(pip_mng->getOpBoundaryRhsPipeline());
694
695 if (mfrontInterfacePtr) {
696 CHKERR mfrontInterfacePtr->setUpdateInternalVariablesOperators(
697 integration_rule_vol, "U");
698 CHKERR mfrontInterfacePtr->setPostProcessOperators(
699 integration_rule_vol, simple->getDomainFEName(), "U", order);
700 }
701
702 CHKERR pip_mng->setDomainRhsIntegrationRule(integration_rule_vol);
703 CHKERR pip_mng->setDomainLhsIntegrationRule(integration_rule_vol);
704 CHKERR pip_mng->setBoundaryRhsIntegrationRule(integration_rule_boundary);
705 CHKERR pip_mng->setBoundaryLhsIntegrationRule(integration_rule_boundary);
706
708}
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
FormsIntegrators< BoundaryEleOp >::Assembly< AT >::BiLinearForm< IT >::OpMass< 1, SPACE_DIM > OpSpringLhs
[Operators used for contact]
Definition contact.cpp:64
FormsIntegrators< BoundaryEleOp >::Assembly< AT >::LinearForm< IT >::OpBaseTimesVector< 1, SPACE_DIM, SPACE_DIM > OpSpringRhs
Definition contact.cpp:66
int order
Definition contact.cpp:71
int geom_order
Definition contact.cpp:74
@ H1
continuous field
Definition definitions.h:85
@ HDIV
field with continuous normal traction
Definition definitions.h:87
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesVector< 1, SPACE_DIM, SPACE_DIM > OpInertiaForce
@ GAUSS
Gaussian quadrature integration.
MoFEMErrorCode opFactoryBoundaryToDomainLhs(MoFEM::Interface &m_field, boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pip, std::string fe_domain_name, std::string sigma, std::string u, std::string geom, ForcesAndSourcesCore::RuleHookFun rule, bool is_axisymmetric=false)
static constexpr int approx_order
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, SPACE_DIM > OpMass
[Only used with Hooke equation (linear material model)]
Definition seepage.cpp:56
Add operators pushing bases from local to physical configuration.
Approximate field values for given petsc vector.
Specialization for MatrixDouble vector field values calculation.
PipelineManager interface.

◆ runProblem()

MoFEMErrorCode Contact::runProblem ( )

[Run problem]

Definition at line 149 of file contact.cpp.

149 {
153 CHKERR bC();
154 CHKERR OPs();
155 CHKERR tsSolve();
158}
MoFEMErrorCode tsSolve()
Definition contact.cpp:721
MoFEMErrorCode setupProblem()
[Run problem]
Definition contact.cpp:162
MoFEMErrorCode OPs()
[Boundary condition]
Definition contact.cpp:483
MoFEMErrorCode createCommonData()
[Set up problem]
Definition contact.cpp:302
MoFEMErrorCode checkResults()
[Solve]
Definition contact.cpp:874
MoFEMErrorCode bC()
[Create common data]
Definition contact.cpp:446

◆ setupProblem()

MoFEMErrorCode Contact::setupProblem ( )
private

[Run problem]

[Set up problem]

< blocs interation is collective, so that is set irrespective if there are entities in given rank or not in the block

Definition at line 162 of file contact.cpp.

162 {
165
166 CHKERR PetscOptionsGetInt(PETSC_NULLPTR, "", "-order", &order, PETSC_NULLPTR);
167 CHKERR PetscOptionsGetInt(PETSC_NULLPTR, "", "-contact_order", &contact_order,
168 PETSC_NULLPTR);
169 sigma_order = std::max(order, contact_order) - 1;
170 CHKERR PetscOptionsGetInt(PETSC_NULLPTR, "", "-sigma_order", &sigma_order,
171 PETSC_NULLPTR);
172 CHKERR PetscOptionsGetInt(PETSC_NULLPTR, "", "-geom_order", &geom_order,
173 PETSC_NULLPTR);
174
175 MOFEM_LOG("CONTACT", Sev::inform) << "Order " << order;
176 MOFEM_LOG("CONTACT", Sev::inform) << "Contact order " << contact_order;
177 MOFEM_LOG("CONTACT", Sev::inform) << "Sigma order " << sigma_order;
178 MOFEM_LOG("CONTACT", Sev::inform) << "Geom order " << geom_order;
179
180 // Select base
181 enum bases { AINSWORTH, DEMKOWICZ, LASBASETOPT };
182 const char *list_bases[LASBASETOPT] = {"ainsworth", "demkowicz"};
183 PetscInt choice_base_value = AINSWORTH;
184 CHKERR PetscOptionsGetEList(PETSC_NULLPTR, NULL, "-base", list_bases,
185 LASBASETOPT, &choice_base_value, PETSC_NULLPTR);
186
188 switch (choice_base_value) {
189 case AINSWORTH:
191 MOFEM_LOG("CONTACT", Sev::inform)
192 << "Set AINSWORTH_LEGENDRE_BASE for displacements";
193 break;
194 case DEMKOWICZ:
196 MOFEM_LOG("CONTACT", Sev::inform)
197 << "Set DEMKOWICZ_JACOBI_BASE for displacements";
198 break;
199 default:
200 base = LASTBASE;
201 break;
202 }
203
204 // Note: For tets we have only H1 Ainsworth base, for Hex we have only H1
205 // Demkowicz base. We need to implement Demkowicz H1 base on tet.
206 CHKERR simple->addDomainField("U", H1, base, SPACE_DIM);
207 CHKERR simple->addBoundaryField("U", H1, base, SPACE_DIM);
208 CHKERR simple->addDomainField("SIGMA", CONTACT_SPACE, DEMKOWICZ_JACOBI_BASE,
209 SPACE_DIM);
210 CHKERR simple->addBoundaryField("SIGMA", CONTACT_SPACE, DEMKOWICZ_JACOBI_BASE,
211 SPACE_DIM);
212 CHKERR simple->addDataField("GEOMETRY", H1, base, SPACE_DIM);
213
214 CHKERR simple->setFieldOrder("U", order);
215 CHKERR simple->setFieldOrder("GEOMETRY", geom_order);
216
217 auto get_skin = [&]() {
218 Range body_ents;
219 CHKERR mField.get_moab().get_entities_by_dimension(0, SPACE_DIM, body_ents);
220 Skinner skin(&mField.get_moab());
221 Range skin_ents;
222 CHKERR skin.find_skin(0, body_ents, false, skin_ents);
223 return skin_ents;
224 };
225
226 auto filter_blocks = [&](auto skin) {
227 bool is_contact_block = false;
228 Range contact_range;
229 for (auto m :
230 mField.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(std::regex(
231
232 (boost::format("%s(.*)") % "CONTACT").str()
233
234 ))
235
236 ) {
237 is_contact_block =
238 true; ///< blocs interation is collective, so that is set irrespective
239 ///< if there are entities in given rank or not in the block
240 MOFEM_LOG("CONTACT", Sev::inform)
241 << "Find contact block set: " << m->getName();
242 auto meshset = m->getMeshset();
243 Range contact_meshset_range;
244 CHKERR mField.get_moab().get_entities_by_dimension(
245 meshset, SPACE_DIM - 1, contact_meshset_range, true);
246
247 CHKERR mField.getInterface<CommInterface>()->synchroniseEntities(
248 contact_meshset_range);
249 contact_range.merge(contact_meshset_range);
250 }
251 if (is_contact_block) {
252 MOFEM_LOG("SYNC", Sev::inform)
253 << "Nb entities in contact surface: " << contact_range.size();
255 skin = intersect(skin, contact_range);
256 }
257 return skin;
258 };
259
260 auto filter_true_skin = [&](auto skin) {
261 Range boundary_ents;
262 ParallelComm *pcomm =
263 ParallelComm::get_pcomm(&mField.get_moab(), MYPCOMM_INDEX);
264 CHKERR pcomm->filter_pstatus(skin, PSTATUS_SHARED | PSTATUS_MULTISHARED,
265 PSTATUS_NOT, -1, &boundary_ents);
266 return boundary_ents;
267 };
268
269 auto boundary_ents = filter_true_skin(filter_blocks(get_skin()));
270 CHKERR simple->setFieldOrder("SIGMA", 0);
271 CHKERR simple->setFieldOrder("SIGMA", sigma_order, &boundary_ents);
272
273 if (contact_order > order) {
274 Range ho_ents;
275
276 CHKERR mField.get_moab().get_adjacencies(boundary_ents, 1, false, ho_ents,
277 moab::Interface::UNION);
278
279 CHKERR mField.getInterface<CommInterface>()->synchroniseEntities(ho_ents);
280 CHKERR simple->setFieldOrder("U", contact_order, &ho_ents);
281 CHKERR mField.getInterface<CommInterface>()->synchroniseFieldEntities("U");
282 }
283
284 CHKERR simple->setUp();
285
286 auto project_ho_geometry = [&]() {
287 Projection10NodeCoordsOnField ent_method(mField, "GEOMETRY");
288 return mField.loop_dofs("GEOMETRY", ent_method);
289 };
290
291 PetscBool project_geometry = PETSC_TRUE;
292 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "", "-project_geometry",
293 &project_geometry, PETSC_NULLPTR);
294 if (project_geometry) {
295 CHKERR project_ho_geometry();
296 }
297
299} //! [Set up problem]
FaceSet skin
WorkMesh base
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
int sigma_order
Definition contact.cpp:73
int contact_order
Definition contact.cpp:72
constexpr FieldSpace CONTACT_SPACE
[Specialisation for assembly]
Definition contact.cpp:60
FieldApproximationBase
approximation base
Definition definitions.h:58
@ LASTBASE
Definition definitions.h:69
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition definitions.h:60
@ DEMKOWICZ_JACOBI_BASE
Definition definitions.h:66
#define MYPCOMM_INDEX
default communicator number PCOMM
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.
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetEList(PetscOptions *, const char pre[], const char name[], const char *const *list, PetscInt next, PetscInt *value, PetscBool *set)
FTensor::Index< 'm', 3 > m
Managing BitRefLevels.
virtual moab::Interface & get_moab()=0
Interface for managing meshsets containing materials and boundary conditions.
Projection of edge entities with one mid-node on hierarchical basis.

◆ tsSolve()

MoFEMErrorCode Contact::tsSolve ( )
private

Definition at line 721 of file contact.cpp.

721 {
723
726 ISManager *is_manager = mField.getInterface<ISManager>();
727
728 auto set_section_monitor = [&](auto solver) {
730 SNES snes;
731 CHKERR TSGetSNES(solver, &snes);
732 PetscViewerAndFormat *vf;
733 CHKERR PetscViewerAndFormatCreate(PETSC_VIEWER_STDOUT_WORLD,
734 PETSC_VIEWER_DEFAULT, &vf);
735 CHKERR SNESMonitorSet(
736 snes,
737 (MoFEMErrorCode (*)(SNES, PetscInt, PetscReal,
738 void *))SNESMonitorFields,
739 vf, (MoFEMErrorCode (*)(void **))PetscViewerAndFormatDestroy);
741 };
742
743 auto scatter_create = [&](auto D, auto coeff) {
745 CHKERR is_manager->isCreateProblemFieldAndRank(simple->getProblemName(),
746 ROW, "U", coeff, coeff, is);
747 int loc_size;
748 CHKERR ISGetLocalSize(is, &loc_size);
749 Vec v;
750 CHKERR VecCreateMPI(mField.get_comm(), loc_size, PETSC_DETERMINE, &v);
751 VecScatter scatter;
752 CHKERR VecScatterCreate(D, is, v, PETSC_NULLPTR, &scatter);
753 return std::make_tuple(SmartPetscObj<Vec>(v),
755 };
756
757 auto set_time_monitor = [&](auto dm, auto solver) {
759 monitorPtr->setScatterVectors(uXScatter, uYScatter, uZScatter);
760 boost::shared_ptr<ForcesAndSourcesCore> null;
761 CHKERR DMMoFEMTSSetMonitor(dm, solver, simple->getDomainFEName(),
762 monitorPtr, null, null);
764 };
765
766 auto set_essential_bc = [&]() {
768 // This is low level pushing finite elements (pipelines) to solver
769 auto ts_ctx_ptr = getDMTsCtx(simple->getDM());
770 auto pre_proc_ptr = boost::make_shared<FEMethod>();
771 auto post_proc_rhs_ptr = boost::make_shared<FEMethod>();
772 auto post_proc_lhs_ptr = boost::make_shared<FEMethod>();
773
774 // Add boundary condition scaling
775 auto time_scale = boost::make_shared<TimeScale>();
776
777 auto get_bc_hook_rhs = [&]() {
779 {time_scale}, false);
780 return hook;
781 };
782 pre_proc_ptr->preProcessHook = get_bc_hook_rhs();
783
784 auto get_post_proc_hook_rhs = [&]() {
786 mField, post_proc_rhs_ptr, 1.);
787 };
788 auto get_post_proc_hook_lhs = [&]() {
790 mField, post_proc_lhs_ptr, 1.);
791 };
792 post_proc_rhs_ptr->postProcessHook = get_post_proc_hook_rhs();
793
794 ts_ctx_ptr->getPreProcessIFunction().push_front(pre_proc_ptr);
795 ts_ctx_ptr->getPreProcessIJacobian().push_front(pre_proc_ptr);
796 ts_ctx_ptr->getPostProcessIFunction().push_back(post_proc_rhs_ptr);
797 post_proc_lhs_ptr->postProcessHook = get_post_proc_hook_lhs();
798 ts_ctx_ptr->getPostProcessIJacobian().push_back(post_proc_lhs_ptr);
800 };
801
802 // Set up Schur preconditioner
803 auto set_schur_pc = [&](auto solver) {
804 boost::shared_ptr<SetUpSchur> schur_ptr;
805 if (AT == AssemblyType::BLOCK_SCHUR) {
806 // Set up Schur preconditioner
808 CHK_MOAB_THROW(schur_ptr->setUp(solver), "SetUpSchur::setUp");
809 }
810 return schur_ptr;
811 };
812
813 auto dm = simple->getDM();
814 auto D = createDMVector(dm);
815
817
818 uXScatter = scatter_create(D, 0);
819 uYScatter = scatter_create(D, 1);
820 if (SPACE_DIM == 3)
821 uZScatter = scatter_create(D, 2);
822
823 // Add extra finite elements to SNES solver pipelines to resolve essential
824 // boundary conditions
825 CHKERR set_essential_bc();
826
828
829 if (is_quasi_static == PETSC_TRUE) {
830 auto solver = pip_mng->createTSIM();
831 CHKERR TSSetFromOptions(solver);
832
833 auto B = createDMMatrix(dm);
834 CHKERR TSSetIJacobian(solver, B, B, PETSC_NULLPTR, PETSC_NULLPTR);
835 auto schur_pc_ptr = set_schur_pc(solver);
836
837 auto D = createDMVector(dm);
838 CHKERR set_section_monitor(solver);
839 CHKERR set_time_monitor(dm, solver);
840 CHKERR TSSetSolution(solver, D);
841 CHKERR TSSetUp(solver);
842 CHKERR TSSolve(solver, NULL);
843 CHKERR testing->checkSolver(solver, "contact");
844 CHKERR VecGhostUpdateBegin(D, INSERT_VALUES, SCATTER_FORWARD);
845 CHKERR VecGhostUpdateEnd(D, INSERT_VALUES, SCATTER_FORWARD);
846 CHKERR DMoFEMMeshToLocalVector(dm, D, INSERT_VALUES, SCATTER_REVERSE);
847 } else {
848 auto solver = pip_mng->createTSIM2();
849 CHKERR TSSetFromOptions(solver);
850
851 auto B = createDMMatrix(dm);
852 CHKERR TSSetI2Jacobian(solver, B, B, PETSC_NULLPTR, PETSC_NULLPTR);
853 auto schur_pc_ptr = set_schur_pc(solver);
854
855 auto D = createDMVector(dm);
856 auto DD = vectorDuplicate(D);
857 CHKERR set_section_monitor(solver);
858 CHKERR set_time_monitor(dm, solver);
859 CHKERR TS2SetSolution(solver, D, DD);
860 CHKERR TSSetUp(solver);
861 CHKERR TSSolve(solver, NULL);
862 CHKERR testing->checkSolver(solver, "contact");
863 CHKERR VecGhostUpdateBegin(D, INSERT_VALUES, SCATTER_FORWARD);
864 CHKERR VecGhostUpdateEnd(D, INSERT_VALUES, SCATTER_FORWARD);
865 CHKERR DMoFEMMeshToLocalVector(dm, D, INSERT_VALUES, SCATTER_REVERSE);
866 }
867
869}
TestHook hook
@ ROW
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode, RowColData rc=RowColData::COL)
set local (or ghosted) vector values on mesh for partition only
Definition DMMoFEM.cpp:600
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
Definition DMMoFEM.hpp:1279
auto createDMMatrix(DM dm)
Get smart matrix from DM.
Definition DMMoFEM.hpp:1236
double D
const double v
phase velocity of light in medium (cm/ns)
const FTensor::Tensor2< T, Dim, Dim > Vec
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
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.
Definition DMMoFEM.cpp:1132
auto getDMTsCtx(DM dm)
Get TS context data structure used by DM.
Definition DMMoFEM.hpp:1321
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
static auto createTotalTraction(MoFEM::Interface &m_field)
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uYScatter
Definition contact.cpp:130
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uXScatter
Definition contact.cpp:129
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uZScatter
Definition contact.cpp:131
Class (Function) to enforce essential constrains on the left hand side diagonal.
Definition Essential.hpp:33
Class (Function) to enforce essential constrains on the right hand side diagonal.
Definition Essential.hpp:41
Class (Function) to enforce essential constrains.
Definition Essential.hpp:25
Section manager is used to create indexes and sections.
Definition ISManager.hpp:23
intrusive_ptr for managing petsc objects
static boost::shared_ptr< SetUpSchur > createSetUpSchur(MoFEM::Interface &m_field)

Member Data Documentation

◆ mField

MoFEM::Interface& Contact::mField
private

Definition at line 120 of file contact.cpp.

◆ mfrontInterfacePtr

boost::shared_ptr<MFrontInterface> Contact::mfrontInterfacePtr
private

Definition at line 133 of file contact.cpp.

◆ monitorPtr

boost::shared_ptr<Monitor> Contact::monitorPtr
private

Definition at line 134 of file contact.cpp.

◆ uXScatter

std::tuple<SmartPetscObj<Vec>, SmartPetscObj<VecScatter> > Contact::uXScatter
private

Definition at line 129 of file contact.cpp.

◆ uYScatter

std::tuple<SmartPetscObj<Vec>, SmartPetscObj<VecScatter> > Contact::uYScatter
private

Definition at line 130 of file contact.cpp.

◆ uZScatter

std::tuple<SmartPetscObj<Vec>, SmartPetscObj<VecScatter> > Contact::uZScatter
private

Definition at line 131 of file contact.cpp.


The documentation for this struct was generated from the following file: