v0.16.3
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 ()
 
EshelbianCore & getEpCore ()
 
boost::shared_ptr< SetPtsData > & getDataField ()
 
PtsHashMap & getHashMap ()
 
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
 
EshelbianCore & eP
 
boost::shared_ptr< SetPtsData > dataFieldEval
 
PtsHashMap ptsHashMap
 
boost::shared_ptr< double > gEnergy
 
boost::shared_ptr< VolEle > volPostProcEnergy
 
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 if (writeRestartEvery <= 0)
40 "-write_restart_every must be positive");
41
42 MOFEM_LOG("EP", Sev::inform) << "EshelbianMonitor writeRestart "
43 << (writeRestart ? "true" : "false");
44
45 MOFEM_LOG("EP", Sev::inform) << "EshelbianMonitor writeRestartEvery "
46 << writeRestartEvery << " steps";
47 }
EshelbianCore * ep
constexpr int SPACE_DIM
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#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 49 of file EshelbianMonitor.cpp.

49 {
51 }
static SmartPetscObj< Vec > adjointGradientVector

Member Function Documentation

◆ calculateEnergy()

MoFEMErrorCode EshelbianMonitor::calculateEnergy ( )

Definition at line 249 of file EshelbianMonitor.cpp.

249 {
251 // Loop boundary elements with traction boundary conditions
252 *gEnergy = 0;
253 // set time to post proc energy
254 const bool has_ts = (ts != PETSC_NULLPTR);
255 if (has_ts) {
256 CHKERR TSGetTime(ts, &(volPostProcEnergy->ts_t));
257 CHKERR TSGetTimeStep(ts, &(volPostProcEnergy->ts_dt));
258 }
259 TetPolynomialBase::switchCacheBaseOn<HDIV>({volPostProcEnergy.get()});
260 CHKERR eP.mField.loop_finite_elements(problemPtr->getName(), "EP",
262 TetPolynomialBase::switchCacheBaseOff<HDIV>({volPostProcEnergy.get()});
263
264 double body_energy = 0;
265 MPI_Allreduce(gEnergy.get(), &body_energy, 1, MPI_DOUBLE, MPI_SUM,
266 eP.mField.get_comm());
267 *gEnergy = body_energy;
270 // store strain energy
271 eP.strainEnergy = body_energy;
272 MOFEM_LOG_C("EP", Sev::inform,
273 "Step %d time %3.4g strain energy %3.12e crack "
274 "area %3.12e",
275 ts_step, ts_t, body_energy, *eP.currentCrackAreaPtr);
276 if (eP.mField.get_comm_rank() == 0) {
277 auto crack_faces = *eP.crackFaces;
278 if (crack_faces.empty()) {
279 crack_faces = *eP.frontEdges;
280 }
283 (boost::format("crack_faces_step_%d.vtk") % ts_step).str(),
284 crack_faces);
287 (boost::format("front_edges_step_%d.vtk") % ts_step).str(),
288 *eP.frontEdges);
289 }
290
291 } else {
292 MOFEM_LOG_C("EP", Sev::inform, "Step %d time %3.4g strain energy %3.6e",
293 ts_step, ts_t, body_energy);
294 }
296};
#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 131 of file EshelbianMonitor.cpp.

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

94{ return dataFieldEval; }

◆ getEnergy()

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

Definition at line 98 of file EshelbianMonitor.cpp.

98{ return gEnergy; }

◆ getEpCore()

EshelbianCore & EshelbianMonitor::getEpCore ( )
inline

Definition at line 92 of file EshelbianMonitor.cpp.

92{ return eP; }

◆ getHashMap()

PtsHashMap & EshelbianMonitor::getHashMap ( )
inline

Definition at line 96 of file EshelbianMonitor.cpp.

96{ return ptsHashMap; }

◆ getReactionMap()

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

Definition at line 88 of file EshelbianMonitor.cpp.

88 {
89 return reactionForcesMap;
90 }

◆ getStep()

std::string EshelbianMonitor::getStep ( )

Definition at line 125 of file EshelbianMonitor.cpp.

125 {
126 std::ostringstream ss;
127 ss << boost::str(boost::format("%d") % static_cast<int>(ts_step));
128 return ss.str();
129};

◆ operator()()

MoFEMErrorCode EshelbianMonitor::operator() ( )
inline

Definition at line 55 of file EshelbianMonitor.cpp.

55{ return 0; }

◆ postProcAtPoints()

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

Definition at line 491 of file EshelbianMonitor.cpp.

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

57 {
59
60 MOFEM_LOG("EP", Sev::inform) << "Monitor postProcess";
61
66
70
72 }
MoFEMErrorCode postProcessMaterialForces()
MoFEMErrorCode saveRestartFile()
MoFEMErrorCode postProcessPoints()
MoFEMErrorCode postProcessSkin()
MoFEMErrorCode calculateReactionForces()
MoFEMErrorCode postProcessSkeletonResults()
MoFEMErrorCode calculateEnergy()

◆ postProcessMaterialForces()

MoFEMErrorCode EshelbianMonitor::postProcessMaterialForces ( )

Definition at line 325 of file EshelbianMonitor.cpp.

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

◆ postProcessPoints()

MoFEMErrorCode EshelbianMonitor::postProcessPoints ( )

Definition at line 479 of file EshelbianMonitor.cpp.

479 {
481
482 for (const auto &[label, point] : ptsHashMap)
483 CHKERR postProcAtPoints(point, label);
484
485 if (!ptsHashMap.empty())
487
489}
#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 339 of file EshelbianMonitor.cpp.

339 {
341 auto get_material_force_tags = [&]() {
342 auto &moab = eP.mField.get_moab();
343 std::vector<Tag> tags;
344 for (const auto *name : {"MaterialForce", "FacePressure"}) {
345 Tag tag;
346 const auto rval = moab.tag_get_handle(name, tag);
347 if (rval == MB_SUCCESS)
348 tags.push_back(tag);
349 else if (rval != MB_TAG_NOT_FOUND)
350 CHK_MOAB_THROW(rval, "can't get tag");
351 }
352 return tags;
353 };
354 // Post-process skeleton elements
355 bool post_process_skeleton = false;
356#ifndef NDEBUG
357 post_process_skeleton = true;
358#endif
359 if (post_process_skeleton) {
361 1, "out_skeleton_" + getStep() + ".h5m", PETSC_NULLPTR,
362 get_material_force_tags(), ts);
363 }
365};
#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 317 of file EshelbianMonitor.cpp.

317 {
319 CHKERR eP.postProcessResults(1, "out_sol_elastic_" + getStep() + ".h5m",
320 PETSC_NULLPTR, PETSC_NULLPTR,
321 adjointGradientVector, {}, ts);
323};
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 53 of file EshelbianMonitor.cpp.

53{ return 0; }

◆ readPtsFromFile()

MoFEMErrorCode EshelbianMonitor::readPtsFromFile ( )

Definition at line 367 of file EshelbianMonitor.cpp.

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

◆ readPtsFromOptions()

MoFEMErrorCode EshelbianMonitor::readPtsFromOptions ( )

Definition at line 395 of file EshelbianMonitor.cpp.

395 {
397
398 std::array<double, SPACE_DIM> field_eval_coords{};
399 PetscInt coords_dim = SPACE_DIM;
400 PetscBool do_eval_field = PETSC_FALSE;
402 PETSC_NULLPTR, PETSC_NULLPTR, "-field_eval_coords",
403 field_eval_coords.data(), &coords_dim, &do_eval_field);
404
405 if (do_eval_field && coords_dim != SPACE_DIM)
406 SETERRQ(PETSC_COMM_WORLD, MOFEM_INVALID_DATA,
407 "-field_eval_coords requires exactly three coordinates");
408
409 if (do_eval_field) {
410 ptsHashMap["field_eval_coords"] = field_eval_coords;
411 MOFEM_LOG_C("EP", Sev::inform,
412 "FieldEvaluator added command-line point [%6.4e, %6.4e, "
413 "%6.4e]",
414 field_eval_coords[0], field_eval_coords[1],
415 field_eval_coords[2]);
416 }
417
418 PetscBool test_cook_pts = PETSC_FALSE;
419 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "", "-test_cook_pts",
420 &test_cook_pts, PETSC_NULLPTR);
421 if (test_cook_pts) {
422 ptsHashMap["Point A"] = {48., 60., 4.999};
423 ptsHashMap["Point B"] = {48. / 2., 44. + (60. - 44.) / 2., 0.};
424 ptsHashMap["Point C"] = {48. / 2., (44. - 0.) / 2., 0.};
425 }
426
428}
@ 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 298 of file EshelbianMonitor.cpp.

298 {
300
301 if (writeRestart && ts_u && (ts_step % writeRestartEvery == 0)) {
302 const std::string restart_file = "restart_" + getStep() + ".dat";
303 PetscViewer viewer;
304 CHKERR PetscViewerBinaryOpen(PETSC_COMM_WORLD,
305 restart_file.c_str(),
306 FILE_MODE_WRITE, &viewer);
307 CHKERR PetscViewerBinarySetSkipInfo(viewer, PETSC_TRUE);
308 CHKERR VecView(ts_u, viewer);
309 CHKERR PetscViewerDestroy(&viewer);
311 CHKERR eP.postProcessRestartMesh(1, "out_restart_mesh_" +
312 getStep() + ".h5m");
313 }
315};
MoFEM::MoFEMErrorCode writeRestartLayout(const EshelbianCore &ep, Vec state, const std::string &binary_file)
MoFEMErrorCode postProcessRestartMesh(const int tag, const std::string file, std::vector< Tag > tags_to_transfer={})
char restart_file[255]

◆ setElementForFieldEval()

MoFEMErrorCode EshelbianMonitor::setElementForFieldEval ( )

Definition at line 430 of file EshelbianMonitor.cpp.

430 {
432 boost::shared_ptr<Ele> vol_ele(dataFieldEval->feMethodPtr);
433 auto no_rule = [](int, int, int) { return -1; };
434 vol_ele->getRuleHook = no_rule;
435 vol_ele->getUserPolynomialBase() =
436 boost::make_shared<CGGUserPolynomialBase>();
437 EshelbianPlasticity::AddHOOps<SPACE_DIM, SPACE_DIM, SPACE_DIM>::add(
438 vol_ele->getOpPtrVector(), {HDIV, H1, L2}, eP.materialH1Positions,
440
441 auto piola_scale_ptr = boost::make_shared<double>(1.0);
442 vol_ele->getOpPtrVector().push_back(new OpCalculateHVecTensorField<3, 3>(
443 eP.piolaStress, eP.dataAtPts->getApproxPAtPts(), piola_scale_ptr));
444 vol_ele->getOpPtrVector().push_back(new OpCalculateHTensorTensorField<3, 3>(
445 eP.bubbleField, eP.dataAtPts->getApproxPAtPts(), piola_scale_ptr,
446 SmartPetscObj<Vec>(), MBMAXTYPE));
447 vol_ele->getOpPtrVector().push_back(new OpCalculateL2RotationValues(
448 eP.rotAxis, eP.dataAtPts->getRotAxisAtPts(),
449 eP.dataAtPts->constantRotation, eP.dataAtPts->higherRotation));
450 CHKERR VecSetDM(eP.solTSStep, PETSC_NULLPTR);
451 vol_ele->getOpPtrVector().push_back(new OpCalculateHVecTensorField<3, 3>(
452 eP.piolaStress, eP.dataAtPts->getApproxP0AtPts(), nullptr,
453 eP.solTSStep));
454 CHKERR eP.physicalEquations->pushMaterialFields(
455 eP, vol_ele->getOpPtrVector(), eP.dataAtPts, PhysicalEquations::PREVIOUS);
456 CHKERR eP.physicalEquations->pushMaterialFields(eP, vol_ele->getOpPtrVector(),
457 eP.dataAtPts);
458 vol_ele->getOpPtrVector().push_back(new OpCalculateL2RotationValues(
459 eP.rotAxis, boost::make_shared<MatrixDouble>(),
460 eP.dataAtPts->previousConstantRotation,
461 eP.dataAtPts->previousHigherRotation, eP.solTSStep));
462 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
463 eP.spatialL2Disp, eP.dataAtPts->getSmallWL2AtPts(), MBTET));
464
465 // H1 displacements
466 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
467 eP.spatialH1Disp, eP.dataAtPts->getSmallWH1AtPts()));
468 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldGradient<3, 3>(
469 eP.spatialH1Disp, eP.dataAtPts->getSmallWGradH1AtPts()));
470
472 vol_ele->getOpPtrVector(), eP.plasticHField,
473 eP.dataAtPts->getPlasticH(), MBTET);
474 vol_ele->getOpPtrVector().push_back(
477};
MoFEMErrorCode addCalculatePlasticLogarithmicStretchFieldValues(boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pipeline, const std::string &field_name, boost::shared_ptr< MatrixDouble > tensor_values, const EntityType zero_type, SmartPetscObj< DM > data_dm, SmartPetscObj< Vec > data_vector)
const std::string spatialH1Disp
const std::string plasticHField
boost::shared_ptr< PhysicalEquations > physicalEquations
const std::string rotAxis
SmartPetscObj< Vec > solTSStep

◆ setElementForPostProcessEnergy()

MoFEMErrorCode EshelbianMonitor::setElementForPostProcessEnergy ( )

Definition at line 113 of file EshelbianMonitor.cpp.

113 {
115 // set time to post processing elements
116 volPostProcEnergy->data_ctx |= PetscData::CTX_SET_TIME;
117 CHKERR eP.setBaseVolumeElementOps(1, false, false, false, volPostProcEnergy);
118
119 CHKERR eP.physicalEquations->pushEnergyEvaluation(
120 eP, volPostProcEnergy->getOpPtrVector(), eP.dataAtPts, gEnergy);
121
123};
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 100 of file EshelbianMonitor.cpp.

◆ dataFieldEval

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

Definition at line 105 of file EshelbianMonitor.cpp.

◆ eP

EshelbianCore& EshelbianMonitor::eP
protected

Definition at line 104 of file EshelbianMonitor.cpp.

◆ gEnergy

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

Definition at line 107 of file EshelbianMonitor.cpp.

◆ ptsHashMap

PtsHashMap EshelbianMonitor::ptsHashMap
protected

Definition at line 106 of file EshelbianMonitor.cpp.

◆ reactionForcesMap

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

Definition at line 103 of file EshelbianMonitor.cpp.

◆ volPostProcEnergy

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

Definition at line 108 of file EshelbianMonitor.cpp.

◆ writeRestart

PetscBool EshelbianMonitor::writeRestart = PETSC_FALSE
protected

Definition at line 109 of file EshelbianMonitor.cpp.

◆ writeRestartEvery

PetscInt EshelbianMonitor::writeRestartEvery = 1
protected

Definition at line 110 of file EshelbianMonitor.cpp.


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