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 readPtsFromOptions ()
 
MoFEMErrorCode setElementForFieldEval ()
 
MoFEMErrorCode postProcessPoints ()
 
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_THROW_MESSAGE(readPtsFromFile(), "read post proc points");
27 CHK_THROW_MESSAGE(readPtsFromOptions(), "read post proc point options");
29 "set element for post energy");
30
31 CHK_THROW_MESSAGE(PetscOptionsGetBool(PETSC_NULLPTR, "", "-write_restart",
32 &writeRestart, PETSC_NULLPTR),
33 "get write restart option");
34 CHK_THROW_MESSAGE(PetscOptionsGetInt(PETSC_NULLPTR, "",
35 "-write_restart_every",
36 &writeRestartEvery, PETSC_NULLPTR),
37 "get write restart option");
38
39 MOFEM_LOG("EP", Sev::inform) << "EshelbianMonitor writeRestart "
40 << (writeRestart ? "true" : "false");
41
42 MOFEM_LOG("EP", Sev::inform) << "EshelbianMonitor writeRestartEvery "
43 << writeRestartEvery << " steps";
44 }
constexpr int SPACE_DIM
#define CHK_THROW_MESSAGE(err, msg)
Check 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
MoFEMErrorCode readPtsFromOptions()
VolumeElementForcesAndSourcesCore VolEle
MoFEMErrorCode readPtsFromFile()
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

◆ ~EshelbianMonitor()

virtual EshelbianMonitor::~EshelbianMonitor ( )
inlinevirtual

Definition at line 46 of file EshelbianMonitor.cpp.

46 {
48 }
static SmartPetscObj< Vec > adjointGradientVector

Member Function Documentation

◆ calculateEnergy()

MoFEMErrorCode EshelbianMonitor::calculateEnergy ( )

Definition at line 265 of file EshelbianMonitor.cpp.

265 {
267 // Loop boundary elements with traction boundary conditions
268 *gEnergy = 0;
269 // set time to post proc energy
270 const bool has_ts = (ts != PETSC_NULLPTR);
271 if (has_ts) {
272 CHKERR TSGetTime(ts, &(volPostProcEnergy->ts_t));
273 CHKERR TSGetTimeStep(ts, &(volPostProcEnergy->ts_dt));
274 }
275 TetPolynomialBase::switchCacheBaseOn<HDIV>({volPostProcEnergy.get()});
276 CHKERR eP.mField.loop_finite_elements(problemPtr->getName(), "EP",
278 TetPolynomialBase::switchCacheBaseOff<HDIV>({volPostProcEnergy.get()});
279
280 double body_energy = 0;
281 MPI_Allreduce(gEnergy.get(), &body_energy, 1, MPI_DOUBLE, MPI_SUM,
282 eP.mField.get_comm());
283 *gEnergy = body_energy;
286 // store strain energy
287 eP.strainEnergy = body_energy;
288 MOFEM_LOG_C("EP", Sev::inform,
289 "Step %d time %3.4g strain energy %3.12e crack "
290 "area %3.12e",
291 ts_step, ts_t, body_energy, *eP.currentCrackAreaPtr);
292 if (eP.mField.get_comm_rank() == 0) {
293 auto crack_faces = *eP.crackFaces;
294 if (crack_faces.empty()) {
295 crack_faces = *eP.frontEdges;
296 }
299 (boost::format("crack_faces_step_%d.vtk") % ts_step).str(),
300 crack_faces);
303 (boost::format("front_edges_step_%d.vtk") % ts_step).str(),
304 *eP.frontEdges);
305 }
306
307 } else {
308 MOFEM_LOG_C("EP", Sev::inform, "Step %d time %3.4g strain energy %3.6e",
309 ts_step, ts_t, body_energy);
310 }
312};
#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 146 of file EshelbianMonitor.cpp.

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

91{ return dataFieldEval; }

◆ getEnergy()

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

Definition at line 95 of file EshelbianMonitor.cpp.

95{ return gEnergy; }

◆ getEpCore()

EshelbianCore & EshelbianMonitor::getEpCore ( )
inline

Definition at line 89 of file EshelbianMonitor.cpp.

89{ return eP; }

◆ getHashMap()

PtsHashMap & EshelbianMonitor::getHashMap ( )
inline

Definition at line 93 of file EshelbianMonitor.cpp.

93{ return ptsHashMap; }

◆ getReactionMap()

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

Definition at line 85 of file EshelbianMonitor.cpp.

85 {
86 return reactionForcesMap;
87 }

◆ getStep()

std::string EshelbianMonitor::getStep ( )

Definition at line 140 of file EshelbianMonitor.cpp.

140 {
141 std::ostringstream ss;
142 ss << boost::str(boost::format("%d") % static_cast<int>(ts_step));
143 return ss.str();
144};

◆ operator()()

MoFEMErrorCode EshelbianMonitor::operator() ( )
inline

Definition at line 52 of file EshelbianMonitor.cpp.

52{ return 0; }

◆ postProcAtPoints()

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

Definition at line 497 of file EshelbianMonitor.cpp.

498 {
500
501 dataFieldEval->setEvalPoints(point.data(), point.size() / 3);
502 auto point_found_ptr = boost::make_shared<int>(0);
503
504 struct OpPrint : public VolOp {
505
506 EshelbianCore &eP;
507 std::array<double, 3> point;
508 std::string str;
509 boost::shared_ptr<int> pointFoundPtr;
510 PetscInt step;
511 double time;
512
513 OpPrint(EshelbianCore &ep, std::array<double, 3> &point, std::string &str,
514 boost::shared_ptr<int> point_found_ptr, PetscInt step, double time)
515 : VolOp(ep.spatialL2Disp, VolOp::OPROW), eP(ep), point(point),
516 str(str), pointFoundPtr(point_found_ptr), step(step), time(time) {}
517
518 MoFEMErrorCode doWork(int side, EntityType type,
519 EntitiesFieldData::EntData &data) {
521 if (type == MBTET) {
522 const int nb_gauss_pts = getGaussPts().size2();
523 if (nb_gauss_pts) {
524 *pointFoundPtr = 1;
525
526 auto t_h = eP.dataAtPts->getFTensorSmallH(nb_gauss_pts);
527 auto t_approx_P = eP.dataAtPts->getFTensorApproxP(nb_gauss_pts);
528 auto t_disp =
529 getFTensor1FromMat<SPACE_DIM>(*eP.dataAtPts->getSmallWL2AtPts());
530
531 FTensor::Index<'i', 3> i;
532 FTensor::Index<'j', 3> j;
533 FTensor::Index<'k', 3> k;
534 const double jac = determinantTensor3by3(t_h);
536 t_cauchy(i, j) = (1. / jac) * (t_approx_P(i, k) * t_h(j, k));
537
538 auto add = [&]() {
539 std::ostringstream s;
540 s << str << " elem " << getFEEntityHandle() << " ";
541 return s.str();
542 };
543
544 auto print_tensor = [](auto &t) {
545 std::ostringstream s;
546 s << t;
547 return s.str();
548 };
549
550 std::ostringstream print;
551 MOFEM_LOG("EPSYNC", Sev::inform)
552 << add() << "comm rank " << eP.mField.get_comm_rank();
553 MOFEM_LOG("EPSYNC", Sev::inform)
554 << add() << "point " << getVectorAdaptor(point.data(), 3);
555 MOFEM_LOG("EPSYNC", Sev::inform)
556 << add() << "coords at gauss pts " << getCoordsAtGaussPts();
557 MOFEM_LOG("EPSYNC", Sev::inform)
558 << add() << "w " << *(eP.dataAtPts->getSmallWL2AtPts());
559 MOFEM_LOG("EPSYNC", Sev::inform)
560 << add() << "Piola " << *(eP.dataAtPts->getApproxPAtPts());
561 MOFEM_LOG("EPSYNC", Sev::inform)
562 << add() << "Cauchy " << print_tensor(t_cauchy);
564 "EPSYNC", Sev::inform,
565 "FieldEvaluator step %d time %6.4e label \"%s\" point [%6.4e, "
566 "%6.4e, %6.4e]",
567 step, time, str.c_str(), point[0], point[1], point[2]);
568 MOFEM_LOG_C("EPSYNC", Sev::inform,
569 "FieldEvaluator displacement [Ux, Uy, Uz] = [%6.4e, "
570 "%6.4e, %6.4e]",
571 t_disp(0), t_disp(1), t_disp(2));
573 "EPSYNC", Sev::inform,
574 "FieldEvaluator Cauchy stress [Sxx, Syy, Szz, Sxy, Syz, Sxz] "
575 "= [%6.4e, %6.4e, %6.4e, %6.4e, %6.4e, %6.4e]",
576 t_cauchy(0, 0), t_cauchy(1, 1), t_cauchy(2, 2),
577 t_cauchy(0, 1), t_cauchy(1, 2), t_cauchy(0, 2));
578 }
579 }
581 }
582 };
583
584 if (auto fe_ptr = dataFieldEval->feMethodPtr) {
585 fe_ptr->data_ctx |= PetscData::CtxSetTime;
586 fe_ptr->ts_t = EshelbianCore::physicalTimeFlg
588 : ts_t;
589 fe_ptr->ts_dt =
591
592 const double time = EshelbianCore::physicalTimeFlg
594 : ts_t;
595 fe_ptr->getOpPtrVector().push_back(
596 new OpPrint(eP, point, str, point_found_ptr, ts_step, time));
597 CHKERR eP.mField.getInterface<FieldEvaluatorInterface>()
598 ->evalFEAtThePoint<SPACE_DIM>(
599 point.data(), 1e-12, problemPtr->getName(), "EP", dataFieldEval,
601 MF_EXIST, QUIET);
602 fe_ptr->getOpPtrVector().pop_back();
603 }
604
605 int global_point_found = 0;
606 MPI_Allreduce(point_found_ptr.get(), &global_point_found, 1, MPI_INT, MPI_SUM,
607 eP.mField.get_comm());
608 if (!global_point_found && !eP.mField.get_comm_rank())
609 MOFEM_LOG_C("EP", Sev::warning,
610 "FieldEvaluator did not find point [%6.4e, %6.4e, %6.4e] in "
611 "the EP domain",
612 point[0], point[1], point[2]);
613
615}
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
static double physicalDt
static PetscBool physicalTimeFlg
static double currentPhysicalTime

◆ postProcess()

MoFEMErrorCode EshelbianMonitor::postProcess ( )
inline

Definition at line 54 of file EshelbianMonitor.cpp.

54 {
56
57 MOFEM_LOG("EP", Sev::inform) << "Monitor postProcess";
58
63
67
69 }
MoFEMErrorCode postProcessMaterialForces()
MoFEMErrorCode saveRestartFile()
MoFEMErrorCode postProcessPoints()
MoFEMErrorCode postProcessSkin()
MoFEMErrorCode calculateReactionForces()
MoFEMErrorCode postProcessSkeletonResults()
MoFEMErrorCode calculateEnergy()

◆ postProcessMaterialForces()

MoFEMErrorCode EshelbianMonitor::postProcessMaterialForces ( )

Definition at line 339 of file EshelbianMonitor.cpp.

339 {
341 // Function to get material force tags
343 int nb_front_faces = eP.frontEdges->size();
344 MPI_Allreduce(MPI_IN_PLACE, &nb_front_faces, 1, MPI_INT, MPI_SUM,
345 eP.mField.get_comm());
346 if (nb_front_faces > 0) {
348 }
349 }
351};
MoFEMErrorCode calculateFaceMaterialForce(const int tag, TS ts, SmartPetscObj< Vec > *adjoint_gradient_vector=nullptr)

◆ postProcessPoints()

MoFEMErrorCode EshelbianMonitor::postProcessPoints ( )

Definition at line 485 of file EshelbianMonitor.cpp.

485 {
487
488 for (const auto &[label, point] : ptsHashMap)
489 CHKERR postProcAtPoints(point, label);
490
491 if (!ptsHashMap.empty())
493
495}
#define MOFEM_LOG_SEVERITY_SYNC(comm, severity)
Synchronise "SYNC" on curtain severity level.
MoFEMErrorCode postProcAtPoints(std::array< double, 3 > point, std::string str)

◆ postProcessSkeletonResults()

MoFEMErrorCode EshelbianMonitor::postProcessSkeletonResults ( )

Definition at line 353 of file EshelbianMonitor.cpp.

353 {
355 auto get_material_force_tags = [&]() {
356 auto &moab = eP.mField.get_moab();
357 std::vector<Tag> tag(2);
358 CHK_MOAB_THROW(moab.tag_get_handle("MaterialForce", tag[0]),
359 "can't get tag");
360 CHK_MOAB_THROW(moab.tag_get_handle("FacePressure", tag[1]),
361 "can't get tag");
362 return tag;
363 };
364 // Post-process skeleton elements
365 bool post_process_skeleton = false;
366#ifndef NDEBUG
367 post_process_skeleton = true;
368#endif
369 if (post_process_skeleton) {
371 1, "out_skeleton_" + getStep() + ".h5m", PETSC_NULLPTR,
372 get_material_force_tags(), ts);
373 }
375};
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
MoFEMErrorCode postProcessSkeletonResults(const int tag, const std::string file, Vec f_residual=PETSC_NULLPTR, std::vector< Tag > tags_to_transfer={}, TS ts=PETSC_NULLPTR)

◆ postProcessSkin()

MoFEMErrorCode EshelbianMonitor::postProcessSkin ( )

Definition at line 331 of file EshelbianMonitor.cpp.

331 {
333 CHKERR eP.postProcessResults(1, "out_sol_elastic_" + getStep() + ".h5m",
334 PETSC_NULLPTR, PETSC_NULLPTR,
335 adjointGradientVector, {}, ts);
337};
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 50 of file EshelbianMonitor.cpp.

50{ return 0; }

◆ readPtsFromFile()

MoFEMErrorCode EshelbianMonitor::readPtsFromFile ( )

Definition at line 377 of file EshelbianMonitor.cpp.

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

◆ readPtsFromOptions()

MoFEMErrorCode EshelbianMonitor::readPtsFromOptions ( )

Definition at line 405 of file EshelbianMonitor.cpp.

405 {
407
408 std::array<double, SPACE_DIM> field_eval_coords{};
409 PetscInt coords_dim = SPACE_DIM;
410 PetscBool do_eval_field = PETSC_FALSE;
412 PETSC_NULLPTR, PETSC_NULLPTR, "-field_eval_coords",
413 field_eval_coords.data(), &coords_dim, &do_eval_field);
414
415 if (do_eval_field && coords_dim != SPACE_DIM)
416 SETERRQ(PETSC_COMM_WORLD, MOFEM_INVALID_DATA,
417 "-field_eval_coords requires exactly three coordinates");
418
419 if (do_eval_field) {
420 ptsHashMap["field_eval_coords"] = field_eval_coords;
421 MOFEM_LOG_C("EP", Sev::inform,
422 "FieldEvaluator added command-line point [%6.4e, %6.4e, "
423 "%6.4e]",
424 field_eval_coords[0], field_eval_coords[1],
425 field_eval_coords[2]);
426 }
427
429}
@ MOFEM_INVALID_DATA
Definition definitions.h:36
PetscErrorCode PetscOptionsGetRealArray(PetscOptions *, const char pre[], const char name[], PetscReal dval[], PetscInt *nmax, PetscBool *set)
PetscBool do_eval_field
Evaluate field.
Definition plastic.cpp:120

◆ saveRestartFile()

MoFEMErrorCode EshelbianMonitor::saveRestartFile ( )

Definition at line 314 of file EshelbianMonitor.cpp.

314 {
316
317 if (writeRestart && ts_u && (ts_step % writeRestartEvery == 0)) {
318 PetscViewer viewer;
319 CHKERR PetscViewerBinaryOpen(PETSC_COMM_WORLD,
320 ("restart_" + getStep() + ".dat").c_str(),
321 FILE_MODE_WRITE, &viewer);
322 CHKERR PetscViewerBinarySetSkipInfo(viewer, PETSC_TRUE);
323 CHKERR VecView(ts_u, viewer);
324 CHKERR PetscViewerDestroy(&viewer);
325 CHKERR eP.postProcessRestartMesh(1, "out_restart_mesh_" +
326 getStep() + ".h5m");
327 }
329};
MoFEMErrorCode postProcessRestartMesh(const int tag, const std::string file, std::vector< Tag > tags_to_transfer={})

◆ setElementForFieldEval()

MoFEMErrorCode EshelbianMonitor::setElementForFieldEval ( )

Definition at line 431 of file EshelbianMonitor.cpp.

431 {
433 boost::shared_ptr<Ele> vol_ele(dataFieldEval->feMethodPtr);
434 auto no_rule = [](int, int, int) { return -1; };
435 vol_ele->getRuleHook = no_rule;
436 vol_ele->getUserPolynomialBase() =
437 boost::make_shared<CGGUserPolynomialBase>();
438 EshelbianPlasticity::AddHOOps<SPACE_DIM, SPACE_DIM, SPACE_DIM>::add(
439 vol_ele->getOpPtrVector(), {HDIV, H1, L2}, eP.materialH1Positions,
441
442 auto piola_scale_ptr = boost::make_shared<double>(1.0);
443 vol_ele->getOpPtrVector().push_back(new OpCalculateHVecTensorField<3, 3>(
444 eP.piolaStress, eP.dataAtPts->getApproxPAtPts(), piola_scale_ptr));
445 vol_ele->getOpPtrVector().push_back(new OpCalculateHTensorTensorField<3, 3>(
446 eP.bubbleField, eP.dataAtPts->getApproxPAtPts(), piola_scale_ptr,
447 SmartPetscObj<Vec>(), MBMAXTYPE));
448 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
449 eP.rotAxis, eP.dataAtPts->getRotAxisAtPts(), MBTET));
452 vol_ele->getOpPtrVector(), eP.physicalEquations, eP.dataAtPts,
454 } else {
455 vol_ele->getOpPtrVector().push_back(
456 new OpCalculateTensor2SymmetricFieldValues<3>(
457 eP.stretchTensor, eP.dataAtPts->getLogStretchTensorAtPts(), MBTET));
458 }
459 CHKERR VecSetDM(eP.solTSStep, PETSC_NULLPTR);
460 vol_ele->getOpPtrVector().push_back(new OpCalculateHVecTensorField<3, 3>(
461 eP.piolaStress, eP.dataAtPts->getApproxP0AtPts(), nullptr,
462 eP.solTSStep));
464 vol_ele->getOpPtrVector().push_back(
465 new OpCalculateTensor2SymmetricFieldValues<3>(
466 eP.stretchTensor, eP.dataAtPts->getLogStretchTensor0AtPts(),
467 eP.solTSStep, MBTET));
468 }
469 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
470 eP.rotAxis, eP.dataAtPts->getRotAxis0AtPts(), eP.solTSStep, MBTET));
471 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
472 eP.spatialL2Disp, eP.dataAtPts->getSmallWL2AtPts(), MBTET));
473
474 // H1 displacements
475 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
476 eP.spatialH1Disp, eP.dataAtPts->getSmallWH1AtPts()));
477 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldGradient<3, 3>(
478 eP.spatialH1Disp, eP.dataAtPts->getSmallWGradH1AtPts()));
479
480 vol_ele->getOpPtrVector().push_back(
483};
void pushOpCalculateStretchFromStress(OpVector &op_vector, boost::shared_ptr< PhysicalEquations > physics_ptr, boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< ExternalStrainVec > external_strain_vec_ptr, const std::map< std::string, boost::shared_ptr< ScalingMethod > > &smv, boost::shared_ptr< MatrixDouble > strain_ptr=nullptr)
Push pointwise external-pressure evaluation before stress recovery.
boost::shared_ptr< ExternalStrainVec > externalStrainVecPtr
std::map< std::string, boost::shared_ptr< ScalingMethod > > timeScaleMap
const std::string spatialH1Disp
boost::shared_ptr< PhysicalEquations > physicalEquations
const std::string rotAxis
static bool isNoStretch()
SmartPetscObj< Vec > solTSStep
const std::string stretchTensor

◆ setElementForPostProcessEnergy()

MoFEMErrorCode EshelbianMonitor::setElementForPostProcessEnergy ( )

Definition at line 110 of file EshelbianMonitor.cpp.

110 {
112 // set time to post processing elements
113 volPostProcEnergy->data_ctx |= PetscData::CTX_SET_TIME;
114 CHKERR eP.setBaseVolumeElementOps(1, false, false, false, volPostProcEnergy);
115
116 if (auto op = eP.physicalEquations->returnOpCalculateEnergy(eP.dataAtPts,
117 gEnergy)) {
118
121 // We have to use actual strains to evaluate J integral and energy,
122 // in this case. Note actual stresses, and actual energy can only
123 // drive crack growth
124
125 // Note: Calling this bellow we overwrite the stretch calculation
126 // from setBaseVolumeElementOps
127
129 volPostProcEnergy->getOpPtrVector(), eP.physicalEquations,
131 eP.dataAtPts->getLogStretchTotalTensorAtPts());
132 }
133
134 volPostProcEnergy->getOpPtrVector().push_back(op);
135 }
136
138};
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 97 of file EshelbianMonitor.cpp.

◆ dataFieldEval

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

Definition at line 102 of file EshelbianMonitor.cpp.

◆ eP

EshelbianCore& EshelbianMonitor::eP
protected

Definition at line 101 of file EshelbianMonitor.cpp.

◆ gEnergy

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

Definition at line 104 of file EshelbianMonitor.cpp.

◆ ptsHashMap

PtsHashMap EshelbianMonitor::ptsHashMap
protected

Definition at line 103 of file EshelbianMonitor.cpp.

◆ reactionForcesMap

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

Definition at line 100 of file EshelbianMonitor.cpp.

◆ volPostProcEnergy

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

Definition at line 105 of file EshelbianMonitor.cpp.

◆ writeRestart

PetscBool EshelbianMonitor::writeRestart = PETSC_FALSE
protected

Definition at line 106 of file EshelbianMonitor.cpp.

◆ writeRestartEvery

PetscInt EshelbianMonitor::writeRestartEvery = 1
protected

Definition at line 107 of file EshelbianMonitor.cpp.


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