31using namespace boost::multi_index;
32using namespace boost::multiprecision;
33using namespace boost::numeric;
37#ifdef ENABLE_PYTHON_BINDING
38 #include <boost/python.hpp>
39 #include <boost/python/def.hpp>
40 #include <boost/python/numpy.hpp>
41namespace bp = boost::python;
42namespace np = boost::python::numpy;
50static char help[] =
"...\n\n";
52int main(
int argc,
char *argv[]) {
55 const char param_file[] =
"param_file.petsc";
59 auto core_log = logging::core::get();
68 #ifdef ENABLE_PYTHON_BINDING
71 MOFEM_LOG(
"EP", Sev::inform) <<
"Python initialised";
73 MOFEM_LOG(
"EP", Sev::inform) <<
"Python NOT initialised";
86 PetscBool flg = PETSC_FALSE;
87 char mesh_file_name[255] =
"";
92 mesh_file_name, 255, &flg);
96 "Missing required mesh option: use -file_name or -my_file");
106 MOFEM_LOG(
"EP", Sev::inform) <<
"Mesh file: " << mesh_file_name;
108 MOFEM_LOG(
"EP", Sev::inform) <<
"Time: " << time;
111 DMType dm_name =
"DMMOFEM";
113 DMType dm_name_mg =
"DMMOFEM_MG";
117 moab::Core moab_core;
118 moab::Interface &moab = moab_core;
120 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
122 pcomm =
new ParallelComm(&moab, PETSC_COMM_WORLD);
124 PetscBool fully_distributed = PETSC_FALSE;
126 &fully_distributed, PETSC_NULLPTR);
127 if (fully_distributed) {
129 if (pcomm->proc_config().proc_size() == 1)
132 option =
"PARALLEL=READ_PART;"
133 "PARALLEL_RESOLVE_SHARED_ENTS;"
134 "PARTITION=PARALLEL_PARTITION";
135 CHKERR moab.load_file(mesh_file_name, 0, option);
142 MOFEM_LOG(
"EP", Sev::inform) <<
"Initialise MoFEM database";
145 MOFEM_LOG(
"EP", Sev::inform) <<
"Initialise MoFEM database <- done";
162 auto get_adj = [&](
Range ents,
int dim) {
164 CHKERR moab.get_adjacencies(ents, dim,
false, adj,
165 moab::Interface::UNION);
204 "stvenant_kirchhoff",
"mooney_rivlin",
"hencky",
205 "neo_hookean",
"storakers",
"meta"};
210 &choice_material, PETSC_NULLPTR);
214 auto material_model_names_dictionary = std::map<std::string, std::string>{
215 {
"grad",
"stretchH1AtPts"}, {
"P",
"PAtPts"}, {
"P_dF",
"PAtPts_du"}};
219 switch (choice_material) {
221 MOFEM_LOG(
"EP", Sev::inform) <<
"St. Venant-Kirchhoff material model";
222 MOFEM_LOG(
"EP", Sev::inform) <<
"Meta Material model";
223 ep.
dataAtPts = boost::make_shared<DataAtIntegrationPts>();
227 material_model_names_dictionary),
229 CHKERR physical_equations_ptr->getOptions(&m_field);
230 CHKERR physical_equations_ptr->recordTape();
234 MOFEM_LOG(
"EP", Sev::inform) <<
"Mooney-Rivlin material model";
235 ep.
dataAtPts = boost::make_shared<DataAtIntegrationPts>();
239 material_model_names_dictionary),
241 CHKERR physical_equations_ptr->getOptions(&m_field);
242 CHKERR physical_equations_ptr->recordTape();
246 MOFEM_LOG(
"EP", Sev::inform) <<
"Hencky material model";
250 MOFEM_LOG(
"EP", Sev::inform) <<
"Neo-Hookean material model";
257 MOFEM_LOG(
"EP", Sev::inform) <<
"Storakers material model";
261 MOFEM_LOG(
"EP", Sev::inform) <<
"Meta Material model";
262 ep.
dataAtPts = boost::make_shared<DataAtIntegrationPts>();
263 auto physical_equations_ptr =
267 material_model_names_dictionary),
269 CHKERR physical_equations_ptr->getOptions(&m_field);
270 CHKERR physical_equations_ptr->recordTape();
283 CHKERR VecSetOption(f_elastic, VEC_IGNORE_NEGATIVE_INDICES, PETSC_TRUE);
285 PetscInt start_step = 0;
289 FILE_MODE_READ, &viewer);
290 CHKERR VecLoad(x_elastic, viewer);
291 CHKERR PetscViewerDestroy(&viewer);
292 CHKERR VecGhostUpdateBegin(x_elastic, INSERT_VALUES, SCATTER_FORWARD);
293 CHKERR VecGhostUpdateEnd(x_elastic, INSERT_VALUES, SCATTER_FORWARD);
296 std::regex restart_pattern(R
"(restart_([1-9]\d*)\.dat)");
298 if (std::regex_search(restart_file_str, match, restart_pattern)) {
299 start_step = std::stoi(match[1]);
302 "Restart file name must be in the format restart_##.dat");
306 auto ts_elastic =
createTS(PETSC_COMM_WORLD);
307 CHKERR TSSetType(ts_elastic, TSBEULER);
310 CHKERR TSGetAdapt(ts_elastic, &adapt);
311 CHKERR TSAdaptSetType(adapt, TSADAPTNONE);
315 MOFEM_LOG(
"EP", Sev::inform) <<
"Solver type: TS";
316 CHKERR TSSetTime(ts_elastic, time);
317 CHKERR TSSetStepNumber(ts_elastic, start_step);
321 MOFEM_LOG(
"EP", Sev::inform) <<
"Solver type: Dynamic Relaxation";
327 MOFEM_LOG(
"EP", Sev::inform) <<
"Solver type: Cohesive";
334 MOFEM_LOG(
"EP", Sev::inform) <<
"Solver type: Load Factor";
340 MOFEM_LOG(
"EP", Sev::inform) <<
"Solver type: Shape Optimization";
348 <<
"Solver type: Test Topological Derivative";
356 "Unknown solver type");
366#ifdef ENABLE_PYTHON_BINDING
367 if (Py_FinalizeEx() < 0) {
Eshelbian plasticity interface.
#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.
boost::shared_ptr< PhysicalEquations > createMatOpsPhysicalEquationsPtr(boost::shared_ptr< MatOpsData > mat_ops_data_ptr, int tag)
boost::shared_ptr< MatOpsData > createMatOpsDataPtr()
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)
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
auto createTS(MPI_Comm comm)
PetscErrorCode PetscOptionsGetEList(PetscOptions *, const char pre[], const char name[], const char *const *list, PetscInt next, PetscInt *value, PetscBool *set)
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()
MoFEMErrorCode addMaterial_Hencky(double E, double nu)
static enum SolverType solverType
MoFEMErrorCode solveSchapeOptimisation(TS ts, Vec x, int start_step, double start_time)
Solve shape optimisation problem.
MoFEMErrorCode addMaterial_HMHStorakers(const double eta, const double mu, const double beta)
MoFEMErrorCode setBlockTagsOnSkin()
MoFEMErrorCode addMaterial_HMHNeohookean(const double c10, const double K)
MoFEMErrorCode solveElastic(TS ts, Vec x)
@ TestTopologicalDerivative
static enum MaterialModel materialModel
MoFEMErrorCode setElasticElementToTs(DM dm)
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 addMaterial_Core(boost::weak_ptr< MatOps::PhysicalEquations > mat_physical_equations_ptr)
MoFEMErrorCode getSpatialTractionFreeBc(const EntityHandle meshset=0)
MoFEMErrorCode getExternalStrain()
MoFEMErrorCode getSpatialTractionBc()
MoFEMErrorCode addDMs(const BitRefLevel bit=BitRefLevel().set(0), const EntityHandle meshset=0)
MoFEMErrorCode solveCohesiveCrackGrowth(TS ts, Vec x, int start_step, double start_time)
Solve cohesive crack growth problem.
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)
boost::shared_ptr< DataAtIntegrationPts > dataAtPts
SmartPetscObj< DM > dmElastic
Elastic problem.
MoFEMErrorCode addFields(const EntityHandle meshset=0, const bool add_bubble=true)
static bool useDeformationGradient
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.