v0.16.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
EshelbianMonitor Struct Reference
Inheritance diagram for EshelbianMonitor:
[legend]
Collaboration diagram for EshelbianMonitor:
[legend]

Public Types

using Ele = ForcesAndSourcesCore
 
using VolEle = VolumeElementForcesAndSourcesCore
 
using VolOp = VolumeElementForcesAndSourcesCore::UserDataOperator
 
using SetPtsData = FieldEvaluatorInterface::SetPtsData
 
using PtsHashMap = std::map< std::string, std::array< double, 3 > >
 
using FaceSideEle = PipelineManager::ElementsAndOpsByDim< SPACE_DIM >::FaceSideEle
 

Public Member Functions

 EshelbianMonitor (EshelbianCore &ep)
 
virtual ~EshelbianMonitor ()
 
MoFEMErrorCode preProcess ()
 
MoFEMErrorCode operator() ()
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode setElementForPostProcessEnergy ()
 
std::string getStep ()
 
MoFEMErrorCode calculateReactionForces ()
 
MoFEMErrorCode calculateEnergy ()
 
MoFEMErrorCode saveRestartFile ()
 
MoFEMErrorCode postProcessSkin ()
 
MoFEMErrorCode postProcessMaterialForces ()
 
MoFEMErrorCode postProcessSkeletonResults ()
 
MoFEMErrorCode readPtsFromFile ()
 
MoFEMErrorCode setElementForFieldEval ()
 
MoFEMErrorCode postProcAtPoints (std::array< double, 3 > point, std::string str)
 
std::map< std::string, std::array< double, 6 > > & getReactionMap ()
 
EshelbianCoregetEpCore ()
 
boost::shared_ptr< SetPtsData > & getDataField ()
 
PtsHashMapgetHashMap ()
 
boost::shared_ptr< double > & getEnergy ()
 

Static Public Attributes

static SmartPetscObj< Vec > adjointGradientVector = SmartPetscObj<Vec>()
 

Protected Attributes

std::map< std::string, std::array< double, 6 > > reactionForcesMap
 
EshelbianCoreeP
 
boost::shared_ptr< SetPtsDatadataFieldEval
 
PtsHashMap ptsHashMap
 
boost::shared_ptr< doublegEnergy
 
boost::shared_ptr< VolElevolPostProcEnergy
 
PetscBool writeRestart = PETSC_FALSE
 
PetscInt writeRestartEvery = 1
 

Detailed Description

Definition at line 6 of file EshelbianMonitor.cpp.

Member Typedef Documentation

◆ Ele

Definition at line 8 of file EshelbianMonitor.cpp.

◆ FaceSideEle

using EshelbianMonitor::FaceSideEle = PipelineManager::ElementsAndOpsByDim<SPACE_DIM>::FaceSideEle

Definition at line 13 of file EshelbianMonitor.cpp.

◆ PtsHashMap

using EshelbianMonitor::PtsHashMap = std::map<std::string, std::array<double, 3> >

Definition at line 12 of file EshelbianMonitor.cpp.

◆ SetPtsData

using EshelbianMonitor::SetPtsData = FieldEvaluatorInterface::SetPtsData

Definition at line 11 of file EshelbianMonitor.cpp.

◆ VolEle

using EshelbianMonitor::VolEle = VolumeElementForcesAndSourcesCore

Definition at line 9 of file EshelbianMonitor.cpp.

◆ VolOp

using EshelbianMonitor::VolOp = VolumeElementForcesAndSourcesCore::UserDataOperator

Definition at line 10 of file EshelbianMonitor.cpp.

Constructor & Destructor Documentation

◆ EshelbianMonitor()

EshelbianMonitor::EshelbianMonitor ( EshelbianCore ep)
inline

Definition at line 16 of file EshelbianMonitor.cpp.

17 : eP(ep), dataFieldEval(ep.mField.getInterface<FieldEvaluatorInterface>()
18 ->getData<VolEle>()),
19 volPostProcEnergy(new VolEle(ep.mField)), gEnergy(new double) {
21 ep.mField.getInterface<FieldEvaluatorInterface>()->buildTree<SPACE_DIM>(
22 dataFieldEval, "EP"),
23 "build field evaluator tree");
24
25 CHK_THROW_MESSAGE(setElementForFieldEval(), "set element for field");
26 CHK_MOAB_THROW(readPtsFromFile(), "read post proc points");
28 "set element for post energy");
29
30 CHK_THROW_MESSAGE(PetscOptionsGetBool(PETSC_NULLPTR, "", "-write_restart",
31 &writeRestart, PETSC_NULLPTR),
32 "get write restart option");
33 CHK_THROW_MESSAGE(PetscOptionsGetInt(PETSC_NULLPTR, "",
34 "-write_restart_every",
35 &writeRestartEvery, PETSC_NULLPTR),
36 "get write restart option");
37
38 MOFEM_LOG("EP", Sev::inform) << "EshelbianMonitor writeRestart "
39 << (writeRestart ? "true" : "false");
40
41 MOFEM_LOG("EP", Sev::inform) << "EshelbianMonitor writeRestartEvery "
42 << writeRestartEvery << " steps";
43 }
constexpr int SPACE_DIM
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
#define MOFEM_LOG(channel, severity)
Log.
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)
MoFEM::Interface & mField
MoFEMErrorCode setElementForPostProcessEnergy()
boost::shared_ptr< double > gEnergy
boost::shared_ptr< VolEle > volPostProcEnergy
MoFEMErrorCode setElementForFieldEval()
boost::shared_ptr< SetPtsData > dataFieldEval
EshelbianCore & eP
VolumeElementForcesAndSourcesCore VolEle
MoFEMErrorCode readPtsFromFile()
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

◆ ~EshelbianMonitor()

virtual EshelbianMonitor::~EshelbianMonitor ( )
inlinevirtual

Definition at line 45 of file EshelbianMonitor.cpp.

45 {
47 }
static SmartPetscObj< Vec > adjointGradientVector

Member Function Documentation

◆ calculateEnergy()

MoFEMErrorCode EshelbianMonitor::calculateEnergy ( )

Definition at line 256 of file EshelbianMonitor.cpp.

256 {
258 // Loop boundary elements with traction boundary conditions
259 *gEnergy = 0;
260 // set time to post proc energy
261 const bool has_ts = (ts != PETSC_NULLPTR);
262 if (has_ts) {
263 CHKERR TSGetTime(ts, &(volPostProcEnergy->ts_t));
264 CHKERR TSGetTimeStep(ts, &(volPostProcEnergy->ts_dt));
265 }
266 TetPolynomialBase::switchCacheBaseOn<HDIV>({volPostProcEnergy.get()});
267 CHKERR eP.mField.loop_finite_elements(problemPtr->getName(), "EP",
269 TetPolynomialBase::switchCacheBaseOff<HDIV>({volPostProcEnergy.get()});
270
271 double body_energy = 0;
272 MPI_Allreduce(gEnergy.get(), &body_energy, 1, MPI_DOUBLE, MPI_SUM,
273 eP.mField.get_comm());
274 *gEnergy = body_energy;
277 // store strain energy
278 eP.strainEnergy = body_energy;
279 MOFEM_LOG_C("EP", Sev::inform,
280 "Step %d time %3.4g strain energy %3.12e crack "
281 "area %3.12e",
282 ts_step, ts_t, body_energy, *eP.currentCrackAreaPtr);
283 if (eP.mField.get_comm_rank() == 0) {
284 auto crack_faces = *eP.crackFaces;
285 if (crack_faces.empty()) {
286 crack_faces = *eP.frontEdges;
287 }
290 (boost::format("crack_faces_step_%d.vtk") % ts_step).str(),
291 crack_faces);
294 (boost::format("front_edges_step_%d.vtk") % ts_step).str(),
295 *eP.frontEdges);
296 }
297
298 } else {
299 MOFEM_LOG_C("EP", Sev::inform, "Step %d time %3.4g strain energy %3.6e",
300 ts_step, ts_t, body_energy);
301 }
303};
#define MOFEM_LOG_C(channel, severity, format,...)
#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.
virtual MoFEMErrorCode loop_finite_elements(const std::string problem_name, const std::string &fe_name, FEMethod &method, boost::shared_ptr< NumeredEntFiniteElement_multiIndex > fe_ptr=nullptr, MoFEMTypes bh=MF_EXIST, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr(), int verb=DEFAULT_VERBOSITY)=0
Make a loop over finite elements.
static PetscBool crackingOn
MoFEMErrorCode calculateCrackArea(boost::shared_ptr< double > &area_ptr)
boost::shared_ptr< double > currentCrackAreaPtr
boost::shared_ptr< Range > crackFaces
boost::shared_ptr< Range > frontEdges
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
auto save_range

◆ calculateReactionForces()

MoFEMErrorCode EshelbianMonitor::calculateReactionForces ( )

Definition at line 141 of file EshelbianMonitor.cpp.

141 {
143
144 // Get boundary faces marked in blocks name "SPATIAL_DISP_...".
145 auto get_ents_on_mesh_skin = [&]() {
146 std::map<std::string, Range> boundary_entities_vec;
147
148 auto get_block_vec_impl = [&](auto block_name) {
149 return eP.mField.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(
150 std::regex(
151
152 (boost::format("%s(.*)") % block_name).str()
153
154 ));
155 };
156
157 auto add_blockset_ents_impl = [&](auto &&vec) {
159 for (auto it : vec) {
160 Range boundary_entities;
161 CHKERR it->getMeshsetIdEntitiesByDimension(eP.mField.get_moab(), 2,
162 boundary_entities, true);
163 std::string meshset_name = it->getName();
164 boundary_entities_vec[meshset_name] = boundary_entities;
165 boundary_entities.clear();
166 }
168 };
169
170 for (auto block_name : {"SPATIAL_DISP", "FIX", "CONTACT",
171 "SPATIAL_ROTATION", "NORMAL_DISPLACEMENT"}) {
172 CHK_THROW_MESSAGE(add_blockset_ents_impl(get_block_vec_impl(block_name)),
173 "add blockset entities");
174 }
175
176 return boundary_entities_vec;
177 };
178
179 auto boundary_entities_vec = get_ents_on_mesh_skin();
180
181 std::vector<std::tuple<std::string, Range, std::array<double, 6>>>
182 reactionForces;
183 for (const auto &pair : boundary_entities_vec) {
184 reactionForces.push_back(
185 std::make_tuple(pair.first, pair.second,
186 std::array<double, 6>{0.0, 0.0, 0.0, 0.0, 0.0, 0.0}));
187 }
188
189 auto integration_rule_face = [](int, int, int approx_order) {
190 return 2 * approx_order + 1;
191 };
192 auto face_fe = boost::make_shared<FaceElementForcesAndSourcesCore>(eP.mField);
193 auto no_rule = [](int, int, int) { return -1; };
194 face_fe->getRuleHook = integration_rule_face;
195 CHKERR
196 EshelbianPlasticity::AddHOOps<SPACE_DIM - 1, SPACE_DIM, SPACE_DIM>::add(
197 face_fe->getOpPtrVector(), {L2}, eP.materialH1Positions,
199
200 auto op_side =
201 new OpLoopSide<FaceSideEle>(eP.mField, "EP", SPACE_DIM, Sev::noisy);
202 face_fe->getOpPtrVector().push_back(op_side);
203 auto side_fe_ptr = op_side->getSideFEPtr();
204 auto base_ptr =
205 boost::make_shared<EshelbianPlasticity::CGGUserPolynomialBase>();
206 side_fe_ptr->getUserPolynomialBase() = base_ptr;
207 CHKERR
208 EshelbianPlasticity::AddHOOps<SPACE_DIM, SPACE_DIM, SPACE_DIM>::add(
209 side_fe_ptr->getOpPtrVector(), {H1, HDIV, L2}, eP.materialH1Positions,
211 auto piola_scale_ptr = boost::make_shared<double>(1.0);
212 side_fe_ptr->getOpPtrVector().push_back(
213 new OpCalculateHVecTensorField<SPACE_DIM, SPACE_DIM>(
214 eP.piolaStress, eP.dataAtPts->getApproxPAtPts(), piola_scale_ptr));
215 side_fe_ptr->getOpPtrVector().push_back(
216 new OpCalculateHTensorTensorField<3, 3>(
217 eP.bubbleField, eP.dataAtPts->getApproxPAtPts(), MBMAXTYPE));
218 side_fe_ptr->getOpPtrVector().push_back(
220 side_fe_ptr->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
221 eP.spatialL2Disp, eP.dataAtPts->getSmallWL2AtPts(), MBTET));
222 for (auto &[name, ents, reaction_vec] : reactionForces) {
223 face_fe->getOpPtrVector().push_back(
224 new OpCalculateReactionForces(eP.dataAtPts, name, ents, reaction_vec));
225 }
226
227 CHKERR eP.mField.loop_finite_elements(problemPtr->getName(), eP.skinElement,
228 *face_fe);
229
230 for (auto &[name, ents, reaction_vec] : reactionForces) {
231 std::array<double, 6> block_reaction_force{0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
232
233 MPI_Allreduce(reaction_vec.data(), &block_reaction_force, 6, MPI_DOUBLE,
234 MPI_SUM, eP.mField.get_comm());
235
236 for (auto &force : block_reaction_force) {
237 if (std::abs(force) < 1e-12) {
238 force = 0.0;
239 }
240 }
241 // Store the reaction forces for later access
242 reactionForcesMap[name] = block_reaction_force;
243 MOFEM_LOG_C("EP", Sev::inform,
244 "Step %d time %3.4g Block %s Reaction force [%3.6e, "
245 "%3.6e, %3.6e]",
246 ts_step, ts_t, name.c_str(), block_reaction_force[0],
247 block_reaction_force[1], block_reaction_force[2]);
248 MOFEM_LOG_C("EP", Sev::inform,
249 "Step %d time %3.4g Block %s Moment [%3.6e, %3.6e, %3.6e]",
250 ts_step, ts_t, name.c_str(), block_reaction_force[3],
251 block_reaction_force[4], block_reaction_force[5]);
252 }
254};
static constexpr int approx_order
boost::shared_ptr< Range > frontAdjEdges
const std::string spatialL2Disp
const std::string materialH1Positions
const std::string piolaStress
const std::string bubbleField
const std::string skinElement
boost::shared_ptr< DataAtIntegrationPts > dataAtPts
std::map< std::string, std::array< double, 6 > > reactionForcesMap

◆ getDataField()

boost::shared_ptr< SetPtsData > & EshelbianMonitor::getDataField ( )
inline

Definition at line 87 of file EshelbianMonitor.cpp.

87{ return dataFieldEval; }

◆ getEnergy()

boost::shared_ptr< double > & EshelbianMonitor::getEnergy ( )
inline

Definition at line 91 of file EshelbianMonitor.cpp.

91{ return gEnergy; }

◆ getEpCore()

EshelbianCore & EshelbianMonitor::getEpCore ( )
inline

Definition at line 85 of file EshelbianMonitor.cpp.

85{ return eP; }

◆ getHashMap()

PtsHashMap & EshelbianMonitor::getHashMap ( )
inline

Definition at line 89 of file EshelbianMonitor.cpp.

89{ return ptsHashMap; }

◆ getReactionMap()

std::map< std::string, std::array< double, 6 > > & EshelbianMonitor::getReactionMap ( )
inline

Definition at line 81 of file EshelbianMonitor.cpp.

81 {
82 return reactionForcesMap;
83 }

◆ getStep()

std::string EshelbianMonitor::getStep ( )

Definition at line 135 of file EshelbianMonitor.cpp.

135 {
136 std::ostringstream ss;
137 ss << boost::str(boost::format("%d") % static_cast<int>(ts_step));
138 return ss.str();
139};

◆ operator()()

MoFEMErrorCode EshelbianMonitor::operator() ( )
inline

Definition at line 51 of file EshelbianMonitor.cpp.

51{ return 0; }

◆ postProcAtPoints()

MoFEMErrorCode EshelbianMonitor::postProcAtPoints ( std::array< double, 3 >  point,
std::string  str 
)

Definition at line 440 of file EshelbianMonitor.cpp.

441 {
443
444 dataFieldEval->setEvalPoints(point.data(), point.size() / 3);
445
446 struct OpPrint : public VolOp {
447
448 EshelbianCore &eP;
449 std::array<double, 3> point;
450 std::string str;
451
452 OpPrint(EshelbianCore &ep, std::array<double, 3> &point, std::string &str)
453 : VolOp(ep.spatialL2Disp, VolOp::OPROW), eP(ep), point(point),
454 str(str) {}
455
456 MoFEMErrorCode doWork(int side, EntityType type,
457 EntitiesFieldData::EntData &data) {
459 if (type == MBTET) {
460 const int nb_gauss_pts = getGaussPts().size2();
461 if (nb_gauss_pts) {
462
463 auto t_h = eP.dataAtPts->getFTensorSmallH(nb_gauss_pts);
464 auto t_approx_P = eP.dataAtPts->getFTensorApproxP(nb_gauss_pts);
465
466 FTensor::Index<'i', 3> i;
467 FTensor::Index<'j', 3> j;
468 FTensor::Index<'k', 3> k;
469 const double jac = determinantTensor3by3(t_h);
471 t_cauchy(i, j) = (1. / jac) * (t_approx_P(i, k) * t_h(j, k));
472
473 auto add = [&]() {
474 std::ostringstream s;
475 s << str << " elem " << getFEEntityHandle() << " ";
476 return s.str();
477 };
478
479 auto print_tensor = [](auto &t) {
480 std::ostringstream s;
481 s << t;
482 return s.str();
483 };
484
485 std::ostringstream print;
486 MOFEM_LOG("EPSYNC", Sev::inform)
487 << add() << "comm rank " << eP.mField.get_comm_rank();
488 MOFEM_LOG("EPSYNC", Sev::inform)
489 << add() << "point " << getVectorAdaptor(point.data(), 3);
490 MOFEM_LOG("EPSYNC", Sev::inform)
491 << add() << "coords at gauss pts " << getCoordsAtGaussPts();
492 MOFEM_LOG("EPSYNC", Sev::inform)
493 << add() << "w " << *(eP.dataAtPts->getSmallWL2AtPts());
494 MOFEM_LOG("EPSYNC", Sev::inform)
495 << add() << "Piola " << *(eP.dataAtPts->getApproxPAtPts());
496 MOFEM_LOG("EPSYNC", Sev::inform)
497 << add() << "Cauchy " << print_tensor(t_cauchy);
498 }
499 }
501 }
502 };
503
504 if (auto fe_ptr = dataFieldEval->feMethodPtr) {
505
506 fe_ptr->getOpPtrVector().push_back(new OpPrint(eP, point, str));
507 CHKERR eP.mField.getInterface<FieldEvaluatorInterface>()
508 ->evalFEAtThePoint<SPACE_DIM>(
509 point.data(), 1e-12, problemPtr->getName(), "EP", dataFieldEval,
511 MF_EXIST, QUIET);
512 fe_ptr->getOpPtrVector().pop_back();
513 }
514
516}
std::string type
@ QUIET
@ MF_EXIST
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
auto getVectorAdaptor(T1 ptr, const size_t n)
Get Vector adaptor.
Definition Templates.hpp:49
MoFEMErrorCode determinantTensor3by3(T1 &t, T2 &det)
Calculate determinant 3 by 3.
constexpr double t
plate stiffness
Definition plate.cpp:58

◆ postProcess()

MoFEMErrorCode EshelbianMonitor::postProcess ( )
inline

Definition at line 53 of file EshelbianMonitor.cpp.

53 {
55
56 MOFEM_LOG("EP", Sev::inform) << "Monitor postProcess";
57
61
65
67 }
MoFEMErrorCode postProcessMaterialForces()
MoFEMErrorCode saveRestartFile()
MoFEMErrorCode postProcessSkin()
MoFEMErrorCode calculateReactionForces()
MoFEMErrorCode postProcessSkeletonResults()
MoFEMErrorCode calculateEnergy()

◆ postProcessMaterialForces()

MoFEMErrorCode EshelbianMonitor::postProcessMaterialForces ( )

Definition at line 330 of file EshelbianMonitor.cpp.

330 {
332 // Function to get material force tags
334 int nb_front_faces = eP.frontEdges->size();
335 MPI_Allreduce(MPI_IN_PLACE, &nb_front_faces, 1, MPI_INT, MPI_SUM,
336 eP.mField.get_comm());
337 if (nb_front_faces > 0) {
339 }
340 }
342};
MoFEMErrorCode calculateFaceMaterialForce(const int tag, TS ts, SmartPetscObj< Vec > *adjoint_gradient_vector=nullptr)

◆ postProcessSkeletonResults()

MoFEMErrorCode EshelbianMonitor::postProcessSkeletonResults ( )

Definition at line 344 of file EshelbianMonitor.cpp.

344 {
346 auto get_material_force_tags = [&]() {
347 auto &moab = eP.mField.get_moab();
348 std::vector<Tag> tag(2);
349 CHK_MOAB_THROW(moab.tag_get_handle("MaterialForce", tag[0]),
350 "can't get tag");
351 CHK_MOAB_THROW(moab.tag_get_handle("FacePressure", tag[1]),
352 "can't get tag");
353 return tag;
354 };
355 // Post-process skeleton elements
356 bool post_process_skeleton = false;
357#ifndef NDEBUG
358 post_process_skeleton = true;
359#endif
360 if (post_process_skeleton) {
362 1, "out_skeleton_" + getStep() + ".h5m", PETSC_NULLPTR,
363 get_material_force_tags());
364 }
366};
MoFEMErrorCode postProcessSkeletonResults(const int tag, const std::string file, Vec f_residual=PETSC_NULLPTR, std::vector< Tag > tags_to_transfer={})

◆ postProcessSkin()

MoFEMErrorCode EshelbianMonitor::postProcessSkin ( )

Definition at line 322 of file EshelbianMonitor.cpp.

322 {
324 CHKERR eP.postProcessResults(1, "out_sol_elastic_" + getStep() + ".h5m",
325 PETSC_NULLPTR, PETSC_NULLPTR,
326 adjointGradientVector, {}, ts);
328};
MoFEMErrorCode postProcessResults(const int tag, const std::string file, Vec f_residual=PETSC_NULLPTR, Vec var_vec=PETSC_NULLPTR, Vec gradient=PETSC_NULLPTR, std::vector< Tag > tags_to_transfer={}, TS ts=PETSC_NULLPTR)

◆ preProcess()

MoFEMErrorCode EshelbianMonitor::preProcess ( )
inline

Definition at line 49 of file EshelbianMonitor.cpp.

49{ return 0; }

◆ readPtsFromFile()

MoFEMErrorCode EshelbianMonitor::readPtsFromFile ( )

Definition at line 368 of file EshelbianMonitor.cpp.

368 {
370 std::ifstream file("points.txt"); // Open the file with the name "data.txt"
371
372 if (!file.is_open()) {
374 }
375
376 std::string line;
377
378 while (std::getline(file, line)) {
379 std::istringstream iss(line);
380 std::string col1;
381 double col2, col3, col4;
382
383 if (iss >> col1 >> col2 >> col3 >> col4) {
384 MOFEM_LOG("EP", Sev::verbose)
385 << "Read: " << col1 << ", " << col2 << ", " << col3 << ", " << col4;
386 ptsHashMap[col1] = {col2, col3, col4};
387 } else {
388 MOFEM_LOG("EP", Sev::error) << "Error parsing line: " << line;
389 }
390 }
391
392 file.close(); // Close the file
394};
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()

◆ saveRestartFile()

MoFEMErrorCode EshelbianMonitor::saveRestartFile ( )

Definition at line 305 of file EshelbianMonitor.cpp.

305 {
307
308 if (writeRestart && ts_u && (ts_step % writeRestartEvery == 0)) {
309 PetscViewer viewer;
310 CHKERR PetscViewerBinaryOpen(PETSC_COMM_WORLD,
311 ("restart_" + getStep() + ".dat").c_str(),
312 FILE_MODE_WRITE, &viewer);
313 CHKERR PetscViewerBinarySetSkipInfo(viewer, PETSC_TRUE);
314 CHKERR VecView(ts_u, viewer);
315 CHKERR PetscViewerDestroy(&viewer);
316 CHKERR eP.postProcessRestartMesh(1, "out_restart_mesh_" +
317 getStep() + ".h5m");
318 }
320};
MoFEMErrorCode postProcessRestartMesh(const int tag, const std::string file, std::vector< Tag > tags_to_transfer={})

◆ setElementForFieldEval()

MoFEMErrorCode EshelbianMonitor::setElementForFieldEval ( )

Definition at line 396 of file EshelbianMonitor.cpp.

396 {
398 boost::shared_ptr<Ele> vol_ele(dataFieldEval->feMethodPtr);
399 auto no_rule = [](int, int, int) { return -1; };
400 vol_ele->getRuleHook = no_rule;
401 vol_ele->getUserPolynomialBase() =
402 boost::make_shared<CGGUserPolynomialBase>();
403 EshelbianPlasticity::AddHOOps<SPACE_DIM, SPACE_DIM, SPACE_DIM>::add(
404 vol_ele->getOpPtrVector(), {HDIV, H1, L2}, eP.materialH1Positions,
406
407 auto piola_scale_ptr = boost::make_shared<double>(1.0);
408 vol_ele->getOpPtrVector().push_back(new OpCalculateHVecTensorField<3, 3>(
409 eP.piolaStress, eP.dataAtPts->getApproxPAtPts(), piola_scale_ptr));
410 vol_ele->getOpPtrVector().push_back(new OpCalculateHTensorTensorField<3, 3>(
411 eP.bubbleField, eP.dataAtPts->getApproxPAtPts(), piola_scale_ptr,
412 SmartPetscObj<Vec>(), MBMAXTYPE));
414 vol_ele->getOpPtrVector().push_back(
415 eP.physicalEquations->returnOpCalculateStretchFromStress(
417 } else {
418 vol_ele->getOpPtrVector().push_back(
419 new OpCalculateTensor2SymmetricFieldValues<3>(
420 eP.stretchTensor, eP.dataAtPts->getLogStretchTensorAtPts(), MBTET));
421 }
422 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
423 eP.rotAxis, eP.dataAtPts->getRotAxisAtPts(), MBTET));
424 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
425 eP.rotAxis, eP.dataAtPts->getRotAxis0AtPts(), eP.solTSStep, MBTET));
426 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
427 eP.spatialL2Disp, eP.dataAtPts->getSmallWL2AtPts(), MBTET));
428
429 // H1 displacements
430 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
431 eP.spatialH1Disp, eP.dataAtPts->getSmallWH1AtPts()));
432 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldGradient<3, 3>(
433 eP.spatialH1Disp, eP.dataAtPts->getSmallWGradH1AtPts()));
434
435 vol_ele->getOpPtrVector().push_back(
438};
static enum StretchHandling stretchHandling
const std::string spatialH1Disp
boost::shared_ptr< PhysicalEquations > physicalEquations
const std::string rotAxis
SmartPetscObj< Vec > solTSStep
const std::string stretchTensor

◆ setElementForPostProcessEnergy()

MoFEMErrorCode EshelbianMonitor::setElementForPostProcessEnergy ( )

Definition at line 106 of file EshelbianMonitor.cpp.

106 {
108 // set time to post processing elements
109 volPostProcEnergy->data_ctx |= PetscData::CTX_SET_TIME;
110 CHKERR eP.setBaseVolumeElementOps(1, false, false, false, volPostProcEnergy);
111
112 if (auto op = eP.physicalEquations->returnOpCalculateEnergy(eP.dataAtPts,
113 gEnergy)) {
114
117 // We have to use actual strains to evaluate J integral and energy,
118 // in this case. Note actual stresses, and actual energy can only
119 // drive crack growth
120
121 // Note: Calling this bellow we overwrite the stretch calculation
122 // from setBaseVolumeElementOps
123
124 volPostProcEnergy->getOpPtrVector().push_back(
125 eP.physicalEquations->returnOpCalculateStretchFromStress(
127 }
128
129 volPostProcEnergy->getOpPtrVector().push_back(op);
130 }
131
133};
static enum MaterialModel materialModel
MoFEMErrorCode setBaseVolumeElementOps(const int tag, const bool do_rhs, const bool do_lhs, const bool calc_rates, boost::shared_ptr< VolumeElementForcesAndSourcesCore > fe, const bool add_bubble=true)

Member Data Documentation

◆ adjointGradientVector

SmartPetscObj<Vec> EshelbianMonitor::adjointGradientVector = SmartPetscObj<Vec>()
inlinestatic

Definition at line 93 of file EshelbianMonitor.cpp.

◆ dataFieldEval

boost::shared_ptr<SetPtsData> EshelbianMonitor::dataFieldEval
protected

Definition at line 98 of file EshelbianMonitor.cpp.

◆ eP

EshelbianCore& EshelbianMonitor::eP
protected

Definition at line 97 of file EshelbianMonitor.cpp.

◆ gEnergy

boost::shared_ptr<double> EshelbianMonitor::gEnergy
protected

Definition at line 100 of file EshelbianMonitor.cpp.

◆ ptsHashMap

PtsHashMap EshelbianMonitor::ptsHashMap
protected

Definition at line 99 of file EshelbianMonitor.cpp.

◆ reactionForcesMap

std::map<std::string, std::array<double, 6> > EshelbianMonitor::reactionForcesMap
protected

Definition at line 96 of file EshelbianMonitor.cpp.

◆ volPostProcEnergy

boost::shared_ptr<VolEle> EshelbianMonitor::volPostProcEnergy
protected

Definition at line 101 of file EshelbianMonitor.cpp.

◆ writeRestart

PetscBool EshelbianMonitor::writeRestart = PETSC_FALSE
protected

Definition at line 102 of file EshelbianMonitor.cpp.

◆ writeRestartEvery

PetscInt EshelbianMonitor::writeRestartEvery = 1
protected

Definition at line 103 of file EshelbianMonitor.cpp.


The documentation for this struct was generated from the following file: