3615 {
3616
3617#ifdef ENABLE_PYTHON_BINDING
3619#endif
3620
3621 auto setup_ts_monitor = [&]() {
3622 boost::shared_ptr<TsCtx>
ts_ctx;
3624 "get TS ctx");
3625 if (set_ts_monitor) {
3628 "TS monitor set");
3629 auto monitor_ptr = boost::make_shared<EshelbianMonitor>(*ep_ptr);
3632 }
3633 MOFEM_LOG(
"EP", Sev::inform) <<
"TS monitor setup";
3634 return std::make_tuple(
ts_ctx);
3635 };
3636
3637 auto setup_snes_monitor = [&]() {
3639 SNES snes;
3640 CHKERR TSGetSNES(ts, &snes);
3642 CHKERR SNESMonitorSet(snes,
3645 (void *)(snes_ctx.get()), PETSC_NULLPTR);
3646 MOFEM_LOG(
"EP", Sev::inform) <<
"SNES monitor setup";
3648 };
3649
3650 auto setup_snes_conergence_test = [&]() {
3652
3653 auto snes_convergence_test = [](SNES snes, PetscInt it, PetscReal xnorm,
3654 PetscReal snorm, PetscReal fnorm,
3655 SNESConvergedReason *reason, void *cctx) {
3657
3658 CHKERR SNESConvergedDefault(snes, it, xnorm, snorm, fnorm, reason,
3659 PETSC_NULLPTR);
3660
3662 CHKERR SNESGetSolutionUpdate(snes, &x_update);
3663 CHKERR SNESGetFunction(snes, &r, PETSC_NULLPTR, PETSC_NULLPTR);
3664
3666 };
3667
3668
3669
3670
3671
3672
3674 };
3675
3676 auto setup_section = [&]() {
3677 PetscSection section_raw;
3679 "get DM section");
3680 int num_fields;
3682 "get num fields");
3683 for (int ff = 0; ff != num_fields; ff++) {
3686 PetscSectionGetFieldName(section_raw, ff, &
field_name),
3687 "get field name");
3689 }
3691 };
3692
3693 auto set_vector_on_mesh = [&]() {
3696 SCATTER_FORWARD);
3697 CHKERR VecGhostUpdateBegin(x, INSERT_VALUES, SCATTER_FORWARD);
3698 CHKERR VecGhostUpdateEnd(x, INSERT_VALUES, SCATTER_FORWARD);
3699 MOFEM_LOG(
"EP", Sev::inform) <<
"Vector set on mesh";
3701 };
3702
3703 auto setup_schur_block_solver = [&]() {
3704 MOFEM_LOG(
"EP", Sev::inform) <<
"Setting up Schur block solver";
3706 "append options prefix");
3709
3710 boost::shared_ptr<EshelbianCore::SetUpSchur> schur_ptr;
3711 if constexpr (
A == AssemblyType::BLOCK_MAT) {
3712 schur_ptr =
3715 }
3716 MOFEM_LOG(
"EP", Sev::inform) <<
"Setting up Schur block solver done";
3717 return schur_ptr;
3718 };
3719
3720
3721
3722
3723#ifdef ENABLE_PYTHON_BINDING
3724 return std::make_tuple(setup_sdf(), setup_ts_monitor(),
3725 setup_snes_monitor(), setup_snes_conergence_test(),
3726 setup_section(), set_vector_on_mesh(),
3727 setup_schur_block_solver());
3728#else
3729 return std::make_tuple(setup_ts_monitor(), setup_snes_monitor(),
3730 setup_snes_conergence_test(), setup_section(),
3731 set_vector_on_mesh(), setup_schur_block_solver());
3732#endif
3733 }
#define MOFEM_LOG_C(channel, severity, format,...)
#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()
#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 MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
PetscErrorCode DMMoFEMGetTsCtx(DM dm, MoFEM::TsCtx **ts_ctx)
get MoFEM::TsCtx data structure
#define MOFEM_LOG(channel, severity)
Log.
const FTensor::Tensor2< T, Dim, Dim > Vec
boost::shared_ptr< ContactSDFPython > setupContactSdf()
Read SDF file and setup contact SDF.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
PetscErrorCode TsMonitorSet(TS ts, PetscInt step, PetscReal t, Vec u, void *ctx)
Set monitor for TS solver.
MoFEMErrorCode MoFEMSNESMonitorEnergy(SNES snes, PetscInt its, PetscReal fgnorm, SnesCtx *ctx)
Sens monitor printing residual field by field.
auto getDMSnesCtx(DM dm)
Get SNES context data structure used by DM.
constexpr auto field_name
static boost::shared_ptr< SetUpSchur > createSetUpSchur(MoFEM::Interface &m_field, EshelbianCore *ep_core_ptr)
MoFEM::Interface & mField
const std::string elementVolumeName
SmartPetscObj< DM > dmElastic
Elastic problem.
intrusive_ptr for managing petsc objects
FEMethodsSequence & getLoopsMonitor()
Get the loops to do Monitor object.