4033 {
4034
4035#ifdef ENABLE_PYTHON_BINDING
4037#endif
4038
4039 auto setup_ts_monitor = [&]() {
4040 boost::shared_ptr<TsCtx>
ts_ctx;
4042 "get TS ctx");
4043 if (set_ts_monitor) {
4046 "TS monitor set");
4047 auto monitor_ptr = boost::make_shared<EshelbianMonitor>(*ep_ptr);
4048 auto testing_monitor_ptr =
4049 boost::make_shared<EshelbianTestingMonitor>(*ep_ptr, monitor_ptr);
4052
4053 PetscBool test_cook_flg = PETSC_FALSE;
4054 PetscBool test_cook_pts_flg = PETSC_FALSE;
4057 &test_cook_flg, PETSC_NULLPTR);
4059 &test_cook_pts_flg, PETSC_NULLPTR);
4061 PETSC_NULLPTR);
4062 if (
atom_test || test_cook_flg || test_cook_pts_flg) {
4065 }
4066 }
4067 MOFEM_LOG(
"EP", Sev::inform) <<
"TS monitor setup";
4068 return std::make_tuple(
ts_ctx);
4069 };
4070
4071 auto setup_snes_monitor = [&]() {
4073 SNES snes;
4074 CHKERR TSGetSNES(ts, &snes);
4076 CHKERR SNESMonitorSet(snes,
4079 (void *)(snes_ctx.get()), PETSC_NULLPTR);
4080 MOFEM_LOG(
"EP", Sev::inform) <<
"SNES monitor setup";
4082 };
4083
4084 auto setup_snes_conergence_test = [&]() {
4086
4087 auto snes_convergence_test = [](SNES snes, PetscInt it, PetscReal xnorm,
4088 PetscReal snorm, PetscReal fnorm,
4089 SNESConvergedReason *reason, void *cctx) {
4091
4092 CHKERR SNESConvergedDefault(snes, it, xnorm, snorm, fnorm, reason,
4093 PETSC_NULLPTR);
4094
4096 CHKERR SNESGetSolutionUpdate(snes, &x_update);
4097 CHKERR SNESGetFunction(snes, &r, PETSC_NULLPTR, PETSC_NULLPTR);
4098
4100 };
4101
4102
4103
4104
4105
4106
4108 };
4109
4110 auto setup_section = [&]() {
4111 PetscSection section_raw;
4113 "get DM section");
4114 int num_fields;
4116 "get num fields");
4117 for (int ff = 0; ff != num_fields; ff++) {
4120 PetscSectionGetFieldName(section_raw, ff, &
field_name),
4121 "get field name");
4123 }
4125 };
4126
4127 auto set_vector_on_mesh = [&]() {
4130 SCATTER_FORWARD);
4131 CHKERR VecGhostUpdateBegin(x, INSERT_VALUES, SCATTER_FORWARD);
4132 CHKERR VecGhostUpdateEnd(x, INSERT_VALUES, SCATTER_FORWARD);
4133 MOFEM_LOG(
"EP", Sev::inform) <<
"Vector set on mesh";
4135 };
4136
4137 auto setup_schur_block_solver = [&]() {
4138 MOFEM_LOG(
"EP", Sev::inform) <<
"Setting up Schur block solver";
4140 "append options prefix");
4143
4144 boost::shared_ptr<EshelbianCore::SetUpSchur> schur_ptr;
4145 if constexpr (
A == AssemblyType::BLOCK_MAT) {
4146 schur_ptr =
4149 }
4150 MOFEM_LOG(
"EP", Sev::inform) <<
"Setting up Schur block solver done";
4151 return schur_ptr;
4152 };
4153
4154
4155
4156
4157#ifdef ENABLE_PYTHON_BINDING
4158 return std::make_tuple(setup_sdf(), setup_ts_monitor(),
4159 setup_snes_monitor(), setup_snes_conergence_test(),
4160 setup_section(), set_vector_on_mesh(),
4161 setup_schur_block_solver());
4162#else
4163 return std::make_tuple(setup_ts_monitor(), setup_snes_monitor(),
4164 setup_snes_conergence_test(), setup_section(),
4165 set_vector_on_mesh(), setup_schur_block_solver());
4166#endif
4167 }
#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.
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
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.