4231 {
4232
4233#ifdef ENABLE_PYTHON_BINDING
4235#endif
4236
4237 auto setup_ts_monitor = [&]() {
4238 boost::shared_ptr<TsCtx>
ts_ctx;
4240 "get TS ctx");
4241 if (set_ts_monitor) {
4244 "TS monitor set");
4245 auto monitor_ptr = boost::make_shared<EshelbianMonitor>(*ep_ptr);
4246 auto testing_monitor_ptr =
4247 boost::make_shared<EshelbianTestingMonitor>(*ep_ptr, monitor_ptr);
4250
4251 PetscBool test_cook_flg = PETSC_FALSE;
4252 PetscBool test_cook_pts_flg = PETSC_FALSE;
4255 &test_cook_flg, PETSC_NULLPTR);
4257 &test_cook_pts_flg, PETSC_NULLPTR);
4259 PETSC_NULLPTR);
4260 if (
atom_test || test_cook_flg || test_cook_pts_flg) {
4263 }
4264 }
4265 MOFEM_LOG(
"EP", Sev::inform) <<
"TS monitor setup";
4266 return std::make_tuple(
ts_ctx);
4267 };
4268
4269 auto setup_snes_monitor = [&]() {
4271 SNES snes;
4272 CHKERR TSGetSNES(ts, &snes);
4274 CHKERR SNESMonitorSet(snes,
4277 (void *)(snes_ctx.get()), PETSC_NULLPTR);
4278 MOFEM_LOG(
"EP", Sev::inform) <<
"SNES monitor setup";
4280 };
4281
4282 auto setup_snes_conergence_test = [&]() {
4284
4285 auto snes_convergence_test = [](SNES snes, PetscInt it, PetscReal xnorm,
4286 PetscReal snorm, PetscReal fnorm,
4287 SNESConvergedReason *reason, void *cctx) {
4289
4290 CHKERR SNESConvergedDefault(snes, it, xnorm, snorm, fnorm, reason,
4291 PETSC_NULLPTR);
4292
4294 CHKERR SNESGetSolutionUpdate(snes, &x_update);
4295 CHKERR SNESGetFunction(snes, &r, PETSC_NULLPTR, PETSC_NULLPTR);
4296
4298 };
4299
4300
4301
4302
4303
4304
4306 };
4307
4308 auto setup_section = [&]() {
4309 PetscSection section_raw;
4311 "get DM section");
4312 int num_fields;
4314 "get num fields");
4315 for (int ff = 0; ff != num_fields; ff++) {
4318 PetscSectionGetFieldName(section_raw, ff, &
field_name),
4319 "get field name");
4321 }
4323 };
4324
4325 auto set_vector_on_mesh = [&]() {
4328 SCATTER_FORWARD);
4329 CHKERR VecGhostUpdateBegin(x, INSERT_VALUES, SCATTER_FORWARD);
4330 CHKERR VecGhostUpdateEnd(x, INSERT_VALUES, SCATTER_FORWARD);
4331 MOFEM_LOG(
"EP", Sev::inform) <<
"Vector set on mesh";
4333 };
4334
4335 auto setup_schur_block_solver = [&]() {
4336 MOFEM_LOG(
"EP", Sev::inform) <<
"Setting up Schur block solver";
4338 "append options prefix");
4341
4342 boost::shared_ptr<EshelbianCore::SetUpSchur> schur_ptr;
4343 if constexpr (
A == AssemblyType::BLOCK_MAT) {
4344 schur_ptr =
4347 }
4348 MOFEM_LOG(
"EP", Sev::inform) <<
"Setting up Schur block solver done";
4349 return schur_ptr;
4350 };
4351
4352
4353
4354
4355#ifdef ENABLE_PYTHON_BINDING
4356 return std::make_tuple(setup_sdf(), setup_ts_monitor(),
4357 setup_snes_monitor(), setup_snes_conergence_test(),
4358 setup_section(), set_vector_on_mesh(),
4359 setup_schur_block_solver());
4360#else
4361 return std::make_tuple(setup_ts_monitor(), setup_snes_monitor(),
4362 setup_snes_conergence_test(), setup_section(),
4363 set_vector_on_mesh(), setup_schur_block_solver());
4364#endif
4365 }
#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(MoFEM::Interface &m_field)
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.