3706 {
3707
3708#ifdef ENABLE_PYTHON_BINDING
3710#endif
3711
3712 auto setup_ts_monitor = [&]() {
3713 boost::shared_ptr<TsCtx>
ts_ctx;
3715 "get TS ctx");
3716 if (set_ts_monitor) {
3719 "TS monitor set");
3720 auto monitor_ptr = boost::make_shared<EshelbianMonitor>(*ep_ptr);
3723 }
3724 MOFEM_LOG(
"EP", Sev::inform) <<
"TS monitor setup";
3725 return std::make_tuple(
ts_ctx);
3726 };
3727
3728 auto setup_snes_monitor = [&]() {
3730 SNES snes;
3731 CHKERR TSGetSNES(ts, &snes);
3733 CHKERR SNESMonitorSet(snes,
3736 (void *)(snes_ctx.get()), PETSC_NULLPTR);
3737 MOFEM_LOG(
"EP", Sev::inform) <<
"SNES monitor setup";
3739 };
3740
3741 auto setup_snes_conergence_test = [&]() {
3743
3744 auto snes_convergence_test = [](SNES snes, PetscInt it, PetscReal xnorm,
3745 PetscReal snorm, PetscReal fnorm,
3746 SNESConvergedReason *reason, void *cctx) {
3748
3749 CHKERR SNESConvergedDefault(snes, it, xnorm, snorm, fnorm, reason,
3750 PETSC_NULLPTR);
3751
3753 CHKERR SNESGetSolutionUpdate(snes, &x_update);
3754 CHKERR SNESGetFunction(snes, &r, PETSC_NULLPTR, PETSC_NULLPTR);
3755
3757 };
3758
3759
3760
3761
3762
3763
3765 };
3766
3767 auto setup_section = [&]() {
3768 PetscSection section_raw;
3770 "get DM section");
3771 int num_fields;
3773 "get num fields");
3774 for (int ff = 0; ff != num_fields; ff++) {
3777 PetscSectionGetFieldName(section_raw, ff, &
field_name),
3778 "get field name");
3780 }
3782 };
3783
3784 auto set_vector_on_mesh = [&]() {
3787 SCATTER_FORWARD);
3788 CHKERR VecGhostUpdateBegin(x, INSERT_VALUES, SCATTER_FORWARD);
3789 CHKERR VecGhostUpdateEnd(x, INSERT_VALUES, SCATTER_FORWARD);
3790 MOFEM_LOG(
"EP", Sev::inform) <<
"Vector set on mesh";
3792 };
3793
3794 auto setup_schur_block_solver = [&]() {
3795 MOFEM_LOG(
"EP", Sev::inform) <<
"Setting up Schur block solver";
3797 "append options prefix");
3800
3801 boost::shared_ptr<EshelbianCore::SetUpSchur> schur_ptr;
3802 if constexpr (
A == AssemblyType::BLOCK_MAT) {
3803 schur_ptr =
3806 }
3807 MOFEM_LOG(
"EP", Sev::inform) <<
"Setting up Schur block solver done";
3808 return schur_ptr;
3809 };
3810
3811
3812
3813
3814#ifdef ENABLE_PYTHON_BINDING
3815 return std::make_tuple(setup_sdf(), setup_ts_monitor(),
3816 setup_snes_monitor(), setup_snes_conergence_test(),
3817 setup_section(), set_vector_on_mesh(),
3818 setup_schur_block_solver());
3819#else
3820 return std::make_tuple(setup_ts_monitor(), setup_snes_monitor(),
3821 setup_snes_conergence_test(), setup_section(),
3822 set_vector_on_mesh(), setup_schur_block_solver());
3823#endif
3824 }
#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 DMMoFEMGetTsCtx(DM dm, MoFEM::TsCtx **ts_ctx)
get MoFEM::TsCtx data structure
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
#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.