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 261 of file EshelbianMonitor.cpp.

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

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

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

◆ 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 455 of file EshelbianMonitor.cpp.

456 {
458
459 dataFieldEval->setEvalPoints(point.data(), point.size() / 3);
460
461 struct OpPrint : public VolOp {
462
463 EshelbianCore &eP;
464 std::array<double, 3> point;
465 std::string str;
466
467 OpPrint(EshelbianCore &ep, std::array<double, 3> &point, std::string &str)
468 : VolOp(ep.spatialL2Disp, VolOp::OPROW), eP(ep), point(point),
469 str(str) {}
470
471 MoFEMErrorCode doWork(int side, EntityType type,
472 EntitiesFieldData::EntData &data) {
474 if (type == MBTET) {
475 const int nb_gauss_pts = getGaussPts().size2();
476 if (nb_gauss_pts) {
477
478 auto t_h = eP.dataAtPts->getFTensorSmallH(nb_gauss_pts);
479 auto t_approx_P = eP.dataAtPts->getFTensorApproxP(nb_gauss_pts);
480
481 FTensor::Index<'i', 3> i;
482 FTensor::Index<'j', 3> j;
483 FTensor::Index<'k', 3> k;
484 const double jac = determinantTensor3by3(t_h);
486 t_cauchy(i, j) = (1. / jac) * (t_approx_P(i, k) * t_h(j, k));
487
488 auto add = [&]() {
489 std::ostringstream s;
490 s << str << " elem " << getFEEntityHandle() << " ";
491 return s.str();
492 };
493
494 auto print_tensor = [](auto &t) {
495 std::ostringstream s;
496 s << t;
497 return s.str();
498 };
499
500 std::ostringstream print;
501 MOFEM_LOG("EPSYNC", Sev::inform)
502 << add() << "comm rank " << eP.mField.get_comm_rank();
503 MOFEM_LOG("EPSYNC", Sev::inform)
504 << add() << "point " << getVectorAdaptor(point.data(), 3);
505 MOFEM_LOG("EPSYNC", Sev::inform)
506 << add() << "coords at gauss pts " << getCoordsAtGaussPts();
507 MOFEM_LOG("EPSYNC", Sev::inform)
508 << add() << "w " << *(eP.dataAtPts->getSmallWL2AtPts());
509 MOFEM_LOG("EPSYNC", Sev::inform)
510 << add() << "Piola " << *(eP.dataAtPts->getApproxPAtPts());
511 MOFEM_LOG("EPSYNC", Sev::inform)
512 << add() << "Cauchy " << print_tensor(t_cauchy);
513 }
514 }
516 }
517 };
518
519 if (auto fe_ptr = dataFieldEval->feMethodPtr) {
520 fe_ptr->data_ctx |= PetscData::CtxSetTime;
521 fe_ptr->ts_t = EshelbianCore::physicalTimeFlg
523 : ts_t;
524 fe_ptr->ts_dt =
526
527 fe_ptr->getOpPtrVector().push_back(new OpPrint(eP, point, str));
528 CHKERR eP.mField.getInterface<FieldEvaluatorInterface>()
529 ->evalFEAtThePoint<SPACE_DIM>(
530 point.data(), 1e-12, problemPtr->getName(), "EP", dataFieldEval,
532 MF_EXIST, QUIET);
533 fe_ptr->getOpPtrVector().pop_back();
534 }
535
537}
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 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 335 of file EshelbianMonitor.cpp.

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

◆ postProcessSkeletonResults()

MoFEMErrorCode EshelbianMonitor::postProcessSkeletonResults ( )

Definition at line 349 of file EshelbianMonitor.cpp.

349 {
351 auto get_material_force_tags = [&]() {
352 auto &moab = eP.mField.get_moab();
353 std::vector<Tag> tag(2);
354 CHK_MOAB_THROW(moab.tag_get_handle("MaterialForce", tag[0]),
355 "can't get tag");
356 CHK_MOAB_THROW(moab.tag_get_handle("FacePressure", tag[1]),
357 "can't get tag");
358 return tag;
359 };
360 // Post-process skeleton elements
361 bool post_process_skeleton = false;
362#ifndef NDEBUG
363 post_process_skeleton = true;
364#endif
365 if (post_process_skeleton) {
367 1, "out_skeleton_" + getStep() + ".h5m", PETSC_NULLPTR,
368 get_material_force_tags(), ts);
369 }
371};
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 327 of file EshelbianMonitor.cpp.

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

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

◆ saveRestartFile()

MoFEMErrorCode EshelbianMonitor::saveRestartFile ( )

Definition at line 310 of file EshelbianMonitor.cpp.

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

◆ setElementForFieldEval()

MoFEMErrorCode EshelbianMonitor::setElementForFieldEval ( )

Definition at line 401 of file EshelbianMonitor.cpp.

401 {
403 boost::shared_ptr<Ele> vol_ele(dataFieldEval->feMethodPtr);
404 auto no_rule = [](int, int, int) { return -1; };
405 vol_ele->getRuleHook = no_rule;
406 vol_ele->getUserPolynomialBase() =
407 boost::make_shared<CGGUserPolynomialBase>();
408 EshelbianPlasticity::AddHOOps<SPACE_DIM, SPACE_DIM, SPACE_DIM>::add(
409 vol_ele->getOpPtrVector(), {HDIV, H1, L2}, eP.materialH1Positions,
411
412 auto piola_scale_ptr = boost::make_shared<double>(1.0);
413 vol_ele->getOpPtrVector().push_back(new OpCalculateHVecTensorField<3, 3>(
414 eP.piolaStress, eP.dataAtPts->getApproxPAtPts(), piola_scale_ptr));
415 vol_ele->getOpPtrVector().push_back(new OpCalculateHTensorTensorField<3, 3>(
416 eP.bubbleField, eP.dataAtPts->getApproxPAtPts(), piola_scale_ptr,
417 SmartPetscObj<Vec>(), MBMAXTYPE));
418 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
419 eP.rotAxis, eP.dataAtPts->getRotAxisAtPts(), MBTET));
422 vol_ele->getOpPtrVector(), eP.physicalEquations, eP.dataAtPts,
424 } else {
425 vol_ele->getOpPtrVector().push_back(
426 new OpCalculateTensor2SymmetricFieldValues<3>(
427 eP.stretchTensor, eP.dataAtPts->getLogStretchTensorAtPts(), MBTET));
428 }
429 CHKERR VecSetDM(eP.solTSStep, PETSC_NULLPTR);
430 vol_ele->getOpPtrVector().push_back(new OpCalculateHVecTensorField<3, 3>(
431 eP.piolaStress, eP.dataAtPts->getApproxP0AtPts(), nullptr,
432 eP.solTSStep));
434 vol_ele->getOpPtrVector().push_back(
435 new OpCalculateTensor2SymmetricFieldValues<3>(
436 eP.stretchTensor, eP.dataAtPts->getLogStretchTensor0AtPts(),
437 eP.solTSStep, MBTET));
438 }
439 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
440 eP.rotAxis, eP.dataAtPts->getRotAxis0AtPts(), eP.solTSStep, MBTET));
441 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
442 eP.spatialL2Disp, eP.dataAtPts->getSmallWL2AtPts(), MBTET));
443
444 // H1 displacements
445 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<3>(
446 eP.spatialH1Disp, eP.dataAtPts->getSmallWH1AtPts()));
447 vol_ele->getOpPtrVector().push_back(new OpCalculateVectorFieldGradient<3, 3>(
448 eP.spatialH1Disp, eP.dataAtPts->getSmallWGradH1AtPts()));
449
450 vol_ele->getOpPtrVector().push_back(
453};
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 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
125 volPostProcEnergy->getOpPtrVector(), eP.physicalEquations,
127 eP.dataAtPts->getLogStretchTotalTensorAtPts());
128 }
129
130 volPostProcEnergy->getOpPtrVector().push_back(op);
131 }
132
134};
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: