50 {
51
52
53 const char param_file[] = "param_file.petsc";
55
56
57 auto core_log = logging::core::get();
61 core_log->add_sink(
65
66 #ifdef ENABLE_PYTHON_BINDING
67 Py_Initialize();
68 np::initialize();
69 MOFEM_LOG(
"EP", Sev::inform) <<
"Python initialised";
70#else
71 MOFEM_LOG(
"EP", Sev::inform) <<
"Python NOT initialised";
72#endif
73
74 core_log->add_sink(
78
79 try {
80
81
82 PetscBool flg = PETSC_TRUE;
85 255, &flg);
87 255, &flg);
92 double time = 0;
94
95
96 DMType dm_name = "DMMOFEM";
98 DMType dm_name_mg = "DMMOFEM_MG";
100
101
102 moab::Core moab_core;
103 moab::Interface &moab = moab_core;
104
105 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
106 if (pcomm == NULL)
107 pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
108
109 PetscBool fully_distributed = PETSC_FALSE;
111 &fully_distributed, PETSC_NULLPTR);
112 if (fully_distributed) {
113 const char *option;
114 if (pcomm->proc_config().proc_size() == 1)
115 option = "";
116 else
117 option = "PARALLEL=READ_PART;"
118 "PARALLEL_RESOLVE_SHARED_ENTS;"
119 "PARTITION=PARALLEL_PARTITION";
121 } else {
124 }
125
126
127 MOFEM_LOG(
"EP", Sev::inform) <<
"Initialise MoFEM database";
130 MOFEM_LOG(
"EP", Sev::inform) <<
"Initialise MoFEM database <- done";
131
133
134
136
139 0, 3, bit_level0);
140
141
143
147 auto get_adj = [&](
Range ents,
int dim) {
149 CHKERR moab.get_adjacencies(ents, dim,
false, adj,
150 moab::Interface::UNION);
151 return adj;
152 };
154 *meshset_ptr,
157 2));
159 *meshset_ptr,
162 1));
164 *meshset_ptr,
167 0));
168
169
170 CHKERR ep.createCrackSurfaceMeshset();
171
172 CHKERR ep.getSpatialDispBc();
173 CHKERR ep.getSpatialRotationBc();
174 CHKERR ep.getSpatialTractionBc();
175 CHKERR ep.getSpatialTractionFreeBc();
176 CHKERR ep.getExternalStrain();
177 CHKERR ep.setBlockTagsOnSkin();
178
179 CHKERR ep.createExchangeVectors(Sev::inform);
180
181 CHKERR ep.addFields(*meshset_ptr);
182 CHKERR ep.projectGeometry(*meshset_ptr);
183 CHKERR ep.addVolumeFiniteElement(*meshset_ptr);
184 CHKERR ep.addBoundaryFiniteElement(*meshset_ptr);
186
188 "stvenant_kirchhoff", "mooney_rivlin", "hencky", "neo_hookean"};
191 list_materials,
193 &choice_material, PETSC_NULLPTR);
196
197 switch (choice_material) {
199 MOFEM_LOG(
"EP", Sev::inform) <<
"StVenantKirchhoff material model";
202 break;
204 MOFEM_LOG(
"EP", Sev::inform) <<
"MooneyRivlin material model";
205 MOFEM_LOG(
"EP", Sev::inform) <<
"MU(1, 0)/2 = " <<
MU(1, 0) / 2;
209 break;
211 MOFEM_LOG(
"EP", Sev::inform) <<
"Hencky material model";
212 CHKERR ep.addMaterial_Hencky(5., 0.25);
213 break;
215 MOFEM_LOG(
"EP", Sev::inform) <<
"Neo-Hookean material model";
217 break;
218 default:
220 break;
221 }
222
224 CHKERR ep.setElasticElementToTs(ep.dmElastic);
225
229 CHKERR VecSetOption(f_elastic, VEC_IGNORE_NEGATIVE_INDICES, PETSC_TRUE);
230
231 PetscInt start_step = 0;
233 PetscViewer viewer;
235 FILE_MODE_READ, &viewer);
236 CHKERR VecLoad(x_elastic, viewer);
237 CHKERR PetscViewerDestroy(&viewer);
239 SCATTER_REVERSE);
240
242 std::regex restart_pattern(R"(restart_([1-9]\d*)\.dat)");
243 std::smatch match;
244 if (std::regex_match(restart_file_str, match, restart_pattern)) {
245 start_step = std::stoi(match[1]);
246 } else {
248 "Restart file name must be in the format restart_##.dat");
249 }
250 }
251
252 auto ts_elastic =
createTS(PETSC_COMM_WORLD);
253 CHKERR TSSetType(ts_elastic, TSBEULER);
255 TSAdapt adapt;
256 CHKERR TSGetAdapt(ts_elastic, &adapt);
257 CHKERR TSAdaptSetType(adapt, TSADAPTNONE);
258
259 if(ep.dynamicRelaxation) {
260 CHKERR ep.solveDynamicRelaxation(ts_elastic, x_elastic, start_step, time);
261 } else {
262 CHKERR TSSetTime(ts_elastic, time);
263 CHKERR TSSetStepNumber(ts_elastic, start_step);
264 CHKERR ep.solveElastic(ts_elastic, x_elastic);
265 }
266
267 }
269
270
272
273#ifdef ENABLE_PYTHON_BINDING
274 if (Py_FinalizeEx() < 0) {
275 exit(120);
276 }
277#endif
278}
constexpr int SPACE_DIM
[Define dimension]
#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)
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.
PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g)
DMShellSetCreateGlobalVector.
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.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
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.
static enum MaterialModel materialModel
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 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.
intrusive_ptr for managing petsc objects
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.