3116                                                {
 3117 
 3118#ifdef ENABLE_PYTHON_BINDING
 3119    auto setup_sdf = [&]() {
 3120      boost::shared_ptr<ContactOps::SDFPython> sdf_python_ptr;
 3121 
 3122      auto file_exists = [](std::string myfile) {
 3123        std::ifstream file(myfile.c_str());
 3124        if (file) {
 3125          return true;
 3126        }
 3127        return false;
 3128      };
 3129 
 3130      char sdf_file_name[255] = "sdf.py";
 3132                                   sdf_file_name, 255, PETSC_NULLPTR);
 3133 
 3134      if (file_exists(sdf_file_name)) {
 3135        MOFEM_LOG(
"EP", Sev::inform) << sdf_file_name << 
" file found";
 
 3136        sdf_python_ptr = boost::make_shared<ContactOps::SDFPython>();
 3137        CHKERR sdf_python_ptr->sdfInit(sdf_file_name);
 
 3138        ContactOps::sdfPythonWeakPtr = sdf_python_ptr;
 3139        MOFEM_LOG(
"EP", Sev::inform) << 
"SdfPython initialized";
 
 3140      } else {
 3141        MOFEM_LOG(
"EP", Sev::warning) << sdf_file_name << 
" file NOT found";
 
 3142      }
 3143      return sdf_python_ptr;
 3144    };
 3145    auto sdf_python_ptr = setup_sdf();
 3146#endif
 3147 
 3148    auto setup_ts_monitor = [&]() {
 3149      boost::shared_ptr<TsCtx> 
ts_ctx;
 
 3151      if (set_ts_monitor) {
 3153        auto monitor_ptr = boost::make_shared<EshelbianMonitor>(*ep_ptr);
 3156      }
 3157      MOFEM_LOG(
"EP", Sev::inform) << 
"TS monitor setup";
 
 3158      return std::make_tuple(
ts_ctx);
 
 3159    };
 3160 
 3161    auto setup_snes_monitor = [&]() {
 3163      SNES snes;
 3164      CHKERR TSGetSNES(ts, &snes);
 
 3166      CHKERR SNESMonitorSet(snes,
 
 3169                            (void *)(snes_ctx.get()), PETSC_NULLPTR);
 3170      MOFEM_LOG(
"EP", Sev::inform) << 
"SNES monitor setup";
 
 3172    };
 3173 
 3174    auto setup_snes_conergence_test = [&]() {
 3176 
 3177      auto snes_convergence_test = [](SNES snes, PetscInt it, PetscReal xnorm,
 3178                                      PetscReal snorm, PetscReal fnorm,
 3179                                      SNESConvergedReason *reason, void *cctx) {
 3181        
 3182        CHKERR SNESConvergedDefault(snes, it, xnorm, snorm, fnorm, reason,
 
 3183                                    PETSC_NULLPTR);
 3184 
 3186        CHKERR SNESGetSolutionUpdate(snes, &x_update);
 
 3187        CHKERR SNESGetFunction(snes, &r, PETSC_NULLPTR, PETSC_NULLPTR);
 
 3188 
 3189        
 3190        
 3191        
 3192        
 3193        
 3194        
 3195        
 3196        
 3197        
 3198        
 3199        
 3200        
 3201        
 3202        
 3203        
 3204        
 3205 
 3206        
 3207        
 3208        
 3209        
 3210        
 3211        
 3212        
 3213        
 3214        
 3215        
 3216        
 3217        
 3218 
 3219        
 3220        
 3221        
 3222        
 3223        
 3224        
 3225        
 3226        
 3227        
 3228        
 3229        
 3230        
 3231        
 3232        
 3233        
 3234        
 3235        
 3236        
 3237        
 3238        
 3239        
 3240        
 3241        
 3242        
 3243 
 3245      };
 3246 
 3247      
 3248      
 3249      
 3250      
 3251      
 3253    };
 3254 
 3255    auto setup_section = [&]() {
 3256      PetscSection section_raw;
 3258      int num_fields;
 3259      CHKERR PetscSectionGetNumFields(section_raw, &num_fields);
 
 3260      for (int ff = 0; ff != num_fields; ff++) {
 3264      }
 3265      return section_raw;
 3266    };
 3267 
 3268    auto set_vector_on_mesh = [&]() {
 3271                                     SCATTER_FORWARD);
 3272      CHKERR VecGhostUpdateBegin(x, INSERT_VALUES, SCATTER_FORWARD);
 
 3273      CHKERR VecGhostUpdateEnd(x, INSERT_VALUES, SCATTER_FORWARD);
 
 3274      MOFEM_LOG(
"EP", Sev::inform) << 
"Vector set on mesh";
 
 3276    };
 3277 
 3278    auto setup_schur_block_solver = [&]() {
 3279      MOFEM_LOG(
"EP", Sev::inform) << 
"Setting up Schur block solver";
 
 3280      CHKERR TSAppendOptionsPrefix(ts, 
"elastic_");
 
 3281      CHKERR TSSetFromOptions(ts);
 
 3283      
 3284      boost::shared_ptr<EshelbianCore::SetUpSchur> schur_ptr;
 3285      if constexpr (
A == AssemblyType::BLOCK_MAT) {
 
 3286        schur_ptr =
 3289      }
 3290      MOFEM_LOG(
"EP", Sev::inform) << 
"Setting up Schur block solver done";
 
 3291      return schur_ptr;
 3292    };
 3293 
 3294    
 3295    
 3296 
 3297#ifdef ENABLE_PYTHON_BINDING
 3298    return std::make_tuple(setup_sdf(), setup_ts_monitor(),
 3299                           setup_snes_monitor(), setup_snes_conergence_test(),
 3300                           setup_section(), set_vector_on_mesh(),
 3301                           setup_schur_block_solver());
 3302#else
 3303    return std::make_tuple(setup_ts_monitor(), setup_snes_monitor(),
 3304                           setup_snes_conergence_test(), setup_section(),
 3305                           set_vector_on_mesh(), setup_schur_block_solver());
 3306#endif
 3307  }
#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
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 PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, 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.
FEMethodsSequence & getLoopsMonitor()
Get the loops to do Monitor object.