30using namespace boost::multi_index;
31using namespace boost::multiprecision;
32using namespace boost::numeric;
36#ifdef ENABLE_PYTHON_BINDING
37 #include <boost/python.hpp>
38 #include <boost/python/def.hpp>
39 #include <boost/python/numpy.hpp>
40namespace bp = boost::python;
41namespace np = boost::python::numpy;
49static char help[] =
"...\n\n";
51int main(
int argc,
char *argv[]) {
54 const char param_file[] =
"param_file.petsc";
58 auto core_log = logging::core::get();
67#ifdef ENABLE_PYTHON_BINDING
70 MOFEM_LOG(
"EP", Sev::inform) <<
"Python initialised";
72 MOFEM_LOG(
"EP", Sev::inform) <<
"Python NOT initialised";
85 PetscBool flg = PETSC_FALSE;
86 char mesh_file_name[255] =
"";
91 mesh_file_name, 255, &flg);
95 "Missing required mesh option: use -file_name or -my_file");
105 MOFEM_LOG(
"EP", Sev::inform) <<
"Mesh file: " << mesh_file_name;
107 MOFEM_LOG(
"EP", Sev::inform) <<
"Time: " << time;
110 DMType dm_name =
"DMMOFEM";
112 DMType dm_name_mg =
"DMMOFEM_MG";
116 moab::Core moab_core;
117 moab::Interface &moab = moab_core;
119 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
121 pcomm =
new ParallelComm(&moab, PETSC_COMM_WORLD);
123 PetscBool fully_distributed = PETSC_FALSE;
125 &fully_distributed, PETSC_NULLPTR);
126 if (fully_distributed) {
128 if (pcomm->proc_config().proc_size() == 1)
131 option =
"PARALLEL=READ_PART;"
132 "PARALLEL_RESOLVE_SHARED_ENTS;"
133 "PARTITION=PARALLEL_PARTITION";
134 CHKERR moab.load_file(mesh_file_name, 0, option);
141 MOFEM_LOG(
"EP", Sev::inform) <<
"Initialise MoFEM database";
144 MOFEM_LOG(
"EP", Sev::inform) <<
"Initialise MoFEM database <- done";
164 auto get_adj = [&](
Range ents,
int dim) {
166 CHKERR moab.get_adjacencies(ents, dim,
false, adj,
167 moab::Interface::UNION);
211 PetscInt start_step = 0;
219 TestIncrementalOptimizationTransaction ||
221 EshelbianCore::SolverType::
222 TestIncrementalOptimizationObjectiveDerivative ||
227 "Incremental optimization does not support -restart");
231 FILE_MODE_READ, &viewer);
232 CHKERR VecLoad(x_elastic, viewer);
233 CHKERR PetscViewerDestroy(&viewer);
234 CHKERR VecGhostUpdateBegin(x_elastic, INSERT_VALUES, SCATTER_FORWARD);
235 CHKERR VecGhostUpdateEnd(x_elastic, INSERT_VALUES, SCATTER_FORWARD);
240 CHKERR VecGhostUpdateBegin(ep.
solTSStep, INSERT_VALUES, SCATTER_FORWARD);
241 CHKERR VecGhostUpdateEnd(ep.
solTSStep, INSERT_VALUES, SCATTER_FORWARD);
244 std::regex restart_pattern(R
"(restart_([1-9]\d*)\.dat)");
246 if (std::regex_search(restart_file_str, match, restart_pattern)) {
247 start_step = std::stoi(match[1]);
250 "Restart file name must be in the format restart_##.dat");
254 auto ts_elastic =
createTS(PETSC_COMM_WORLD);
255 CHKERR TSSetType(ts_elastic, TSBEULER);
258 CHKERR TSGetAdapt(ts_elastic, &adapt);
259 CHKERR TSAdaptSetType(adapt, TSADAPTNONE);
263 MOFEM_LOG(
"EP", Sev::inform) <<
"Solver type: TS";
264 CHKERR TSSetTime(ts_elastic, time);
265 CHKERR TSSetStepNumber(ts_elastic, start_step);
269 MOFEM_LOG(
"EP", Sev::inform) <<
"Solver type: Dynamic Relaxation";
275 MOFEM_LOG(
"EP", Sev::inform) <<
"Solver type: Incremental Optimization";
282 MOFEM_LOG(
"EP", Sev::inform) <<
"Solver type: Load Factor";
288 MOFEM_LOG(
"EP", Sev::inform) <<
"Solver type: Shape Optimization";
296 <<
"Solver type: Test Topological Derivative";
304 <<
"Solver type: Test Equilibrated Mechanical Value";
312 <<
"Solver type: Test Incremental Optimization Layout";
318 <<
"Solver type: Test Incremental Optimization Transaction";
322 ts_elastic, x_elastic, start_step, time);
327 <<
"Solver type: Test Incremental Optimization Objective Derivative";
331 ts_elastic, x_elastic, start_step, time);
336 <<
"Solver type: Test Incremental Optimization Constraint Derivative";
340 ts_elastic, x_elastic, start_step, time);
344 "Unknown solver type");
353#ifdef ENABLE_PYTHON_BINDING
354 if (Py_FinalizeEx() < 0) {
Eshelbian plasticity interface.
Native restart vector layout validation.
#define CATCH_ERRORS
Catch errors.
#define MYPCOMM_INDEX
default communicator number PCOMM
@ MOFEM_DATA_INCONSISTENCY
#define CHKERR
Inline error check.
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
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
MoFEMErrorCode DMRegister_MGViaApproxOrders(const char sname[])
Register DM for Multi-Grid via approximation orders.
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
MoFEM::MoFEMErrorCode validateRestartLayout(const EshelbianCore &ep, Vec state, const std::string &binary_file)
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
implementation of Data Operators for Forces and Sources
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
PetscErrorCode PetscOptionsGetScalar(PetscOptions *, const char pre[], const char name[], PetscScalar *dval, PetscBool *set)
auto createTS(MPI_Comm comm)
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
auto get_temp_meshset_ptr(moab::Interface &moab)
Create smart pointer to temporary meshset.
PetscErrorCode TSAdaptCreateMoFEM(TSAdapt adapt)
Craete MOFEM adapt.
MoFEMErrorCode setElasticElementOps(const int tag)
MoFEMErrorCode createCrackSurfaceMeshset()
MoFEMErrorCode addBoundaryFiniteElement(const EntityHandle meshset=0)
MoFEMErrorCode getSpatialRotationBc()
static enum SolverType solverType
MoFEMErrorCode solveSchapeOptimisation(TS ts, Vec x, int start_step, double start_time)
Solve shape optimisation problem.
MoFEMErrorCode setBlockTagsOnSkin()
MoFEMErrorCode solveTestIncrementalOptimizationLayout(TS ts, Vec x, int start_step, double start_time)
MoFEMErrorCode solveElastic(TS ts, Vec x)
@ TestIncrementalOptimizationConstraintDerivative
@ TestIncrementalOptimizationLayout
@ TestIncrementalOptimizationTransaction
@ TestIncrementalOptimizationObjectiveDerivative
@ IncrementalOptimization
@ TestTopologicalDerivative
@ TestEquilibratedMechanicalValue
MoFEMErrorCode solveTestIncrementalOptimizationTransaction(TS ts, Vec x, int start_step, double start_time)
MoFEMErrorCode setElasticElementToTs(DM dm)
MoFEMErrorCode solveTestEquilibratedMechanicalValue(TS ts, Vec x, int start_step, double start_time)
MoFEMErrorCode solveIncrementalOptimizationTAO(TS ts, Vec x, int start_step, double start_time)
Solve the incremental constitutive optimization with TAO.
MoFEMErrorCode solveTestIncrementalOptimizationObjectiveDerivative(TS ts, Vec x, int start_step, double start_time)
MoFEMErrorCode resolveDissipationEntities(const EntityHandle meshset=0)
MoFEMErrorCode projectGeometry(const EntityHandle meshset=0, double time=0)
MoFEMErrorCode projectMaterialTags(const EntityHandle meshset=0)
MoFEMErrorCode solveDynamicRelaxation(TS ts, Vec x, int start_step, double start_time)
Solve problem using dynamic relaxation method.
MoFEMErrorCode solveTestTopologicalDerivative(TS ts, Vec x, int start_step, double start_time)
MoFEMErrorCode addVolumeFiniteElement(const EntityHandle meshset=0, const bool add_bubble=true)
MoFEMErrorCode solveTestIncrementalOptimizationConstraintDerivative(TS ts, Vec x, int start_step, double start_time)
MoFEMErrorCode getSpatialTractionFreeBc(const EntityHandle meshset=0)
MoFEMErrorCode getExternalStrain()
MoFEMErrorCode getSpatialTractionBc()
MoFEMErrorCode addDMs(const BitRefLevel bit=BitRefLevel().set(0), const EntityHandle meshset=0)
MoFEMErrorCode getSpatialDispBc()
[Getting norms]
MoFEMErrorCode solveLoadFactor(TS ts, Vec x, int start_step, double start_time)
Solve load factor crack growth problem.
MoFEMErrorCode createExchangeVectors(Sev sev)
SmartPetscObj< Vec > solTSStep
SmartPetscObj< DM > dmElastic
Elastic problem.
MoFEMErrorCode addFields(const EntityHandle meshset=0, const bool add_bubble=true)
static MoFEMErrorCode create(EshelbianCore &ep)
Select and configure the material before registering fields and DMs.
static Range getPartEntities(moab::Interface &moab, int part)
static MoFEMErrorCode loadFileRootProcAllRestDistributed(moab::Interface &moab, const char *file_name, int dim, LoadFileFun proc_skin_fun=defaultProcSkinFun, const char *options="PARALLEL=BCAST;PARTITION=")
Root proc has whole mesh, other procs only part of it.
virtual MPI_Comm & get_comm() const =0
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Deprecated interface functions.
static MoFEMErrorCode setMeshFileFromJson()
Set -file_name from JSON before Core is available.
static MoFEMErrorCode addCanonicalAttributeNames(const std::vector< std::string > &names)
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
static boost::shared_ptr< std::ostream > getStrmSync()
Get the strm sync object.
static boost::shared_ptr< std::ostream > getStrmSelf()
Get the strm self object.
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.