v0.14.0
Public Member Functions | Private Attributes | List of all members
PlasticOps::Monitor Struct Reference

#include <tutorials/adv-0/src/PlasticOpsMonitor.hpp>

Inheritance diagram for PlasticOps::Monitor:
[legend]
Collaboration diagram for PlasticOps::Monitor:
[legend]

Public Member Functions

 Monitor (SmartPetscObj< DM > dm, std::pair< boost::shared_ptr< PostProcEle >, boost::shared_ptr< SkinPostProcEle >> pair_post_proc_fe, boost::shared_ptr< DomainEle > reaction_fe, std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter >> ux_scatter, std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter >> uy_scatter, std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter >> uz_scatter)
 
MoFEMErrorCode preProcess ()
 
MoFEMErrorCode operator() ()
 
MoFEMErrorCode postProcess ()
 

Private Attributes

SmartPetscObj< DM > dM
 
boost::shared_ptr< PostProcElepostProcFe
 
boost::shared_ptr< SkinPostProcEleskinPostProcFe
 
boost::shared_ptr< DomainElereactionFe
 
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uXScatter
 
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uYScatter
 
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uZScatter
 

Detailed Description

Examples
plastic.cpp.

Definition at line 9 of file PlasticOpsMonitor.hpp.

Constructor & Destructor Documentation

◆ Monitor()

PlasticOps::Monitor::Monitor ( SmartPetscObj< DM >  dm,
std::pair< boost::shared_ptr< PostProcEle >, boost::shared_ptr< SkinPostProcEle >>  pair_post_proc_fe,
boost::shared_ptr< DomainEle reaction_fe,
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter >>  ux_scatter,
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter >>  uy_scatter,
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter >>  uz_scatter 
)
inline
Examples
PlasticOpsMonitor.hpp.

Definition at line 11 of file PlasticOpsMonitor.hpp.

19  : dM(dm), reactionFe(reaction_fe), uXScatter(ux_scatter),
20  uYScatter(uy_scatter), uZScatter(uz_scatter) {
21  postProcFe = pair_post_proc_fe.first;
22  skinPostProcFe = pair_post_proc_fe.second;
23  };

Member Function Documentation

◆ operator()()

MoFEMErrorCode PlasticOps::Monitor::operator() ( )
inline
Examples
PlasticOpsMonitor.hpp.

Definition at line 26 of file PlasticOpsMonitor.hpp.

26 { return 0; }

◆ postProcess()

MoFEMErrorCode PlasticOps::Monitor::postProcess ( )
inline
Examples
PlasticOpsMonitor.hpp.

Definition at line 28 of file PlasticOpsMonitor.hpp.

28  {
30 
31  MoFEM::Interface *m_field_ptr;
32  CHKERR DMoFEMGetInterfacePtr(dM, &m_field_ptr);
33 
34  auto make_vtk = [&]() {
36  if (postProcFe) {
38  getCacheWeakPtr());
39  CHKERR postProcFe->writeFile("out_plastic_" +
40  boost::lexical_cast<std::string>(ts_step) +
41  ".h5m");
42  }
43  if (skinPostProcFe) {
45  getCacheWeakPtr());
46  CHKERR skinPostProcFe->writeFile(
47  "out_skin_plastic_" + boost::lexical_cast<std::string>(ts_step) +
48  ".h5m");
49  }
51  };
52 
53  auto calculate_reaction = [&]() {
55  auto r = createDMVector(dM);
56  reactionFe->f = r;
57  CHKERR VecZeroEntries(r);
58  CHKERR DMoFEMLoopFiniteElements(dM, "dFE", reactionFe, getCacheWeakPtr());
59 
60 #ifndef NDEBUG
61  auto post_proc_residual = [&](auto dm, auto f_res, auto out_name) {
63  auto post_proc_fe =
64  boost::make_shared<PostProcBrokenMeshInMoab<DomainEle>>(
65  *m_field_ptr);
66  using OpPPMap = OpPostProcMapInMoab<SPACE_DIM, SPACE_DIM>;
67  auto u_vec = boost::make_shared<MatrixDouble>();
68  post_proc_fe->getOpPtrVector().push_back(
69  new OpCalculateVectorFieldValues<SPACE_DIM>("U", u_vec, f_res));
70  post_proc_fe->getOpPtrVector().push_back(
71 
72  new OpPPMap(
73 
74  post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
75 
76  {},
77 
78  {{"RES", u_vec}},
79 
80  {}, {})
81 
82  );
83 
84  CHKERR DMoFEMLoopFiniteElements(dM, "dFE", post_proc_fe);
85  post_proc_fe->writeFile("res.h5m");
87  };
88 
89  CHKERR post_proc_residual(dM, r, "reaction");
90 #endif // NDEBUG
91 
93  };
94 
95  auto print_max_min = [&](auto &tuple, const std::string msg) {
97  CHKERR VecScatterBegin(std::get<1>(tuple), ts_u, std::get<0>(tuple),
98  INSERT_VALUES, SCATTER_FORWARD);
99  CHKERR VecScatterEnd(std::get<1>(tuple), ts_u, std::get<0>(tuple),
100  INSERT_VALUES, SCATTER_FORWARD);
101  double max, min;
102  CHKERR VecMax(std::get<0>(tuple), PETSC_NULL, &max);
103  CHKERR VecMin(std::get<0>(tuple), PETSC_NULL, &min);
104  MOFEM_LOG_C("PLASTICITY", Sev::inform, "%s time %3.4e min %3.4e max %3.4e",
105  msg.c_str(), ts_t, min, max);
107  };
108 
109  int se = 1;
110  CHKERR PetscOptionsGetInt(PETSC_NULL, "", "-save_every", &se, PETSC_NULL);
111  if (!(ts_step % se)) {
112  CHKERR make_vtk();
113  }
114  if (reactionFe)
115  CHKERR calculate_reaction();
116  CHKERR print_max_min(uXScatter, "Ux");
117  CHKERR print_max_min(uYScatter, "Uy");
118  if constexpr (SPACE_DIM == 3)
119  CHKERR print_max_min(uZScatter, "Uz");
120 
122  }

◆ preProcess()

MoFEMErrorCode PlasticOps::Monitor::preProcess ( )
inline
Examples
PlasticOpsMonitor.hpp.

Definition at line 25 of file PlasticOpsMonitor.hpp.

25 { return 0; }

Member Data Documentation

◆ dM

SmartPetscObj<DM> PlasticOps::Monitor::dM
private
Examples
PlasticOpsMonitor.hpp.

Definition at line 125 of file PlasticOpsMonitor.hpp.

◆ postProcFe

boost::shared_ptr<PostProcEle> PlasticOps::Monitor::postProcFe
private
Examples
PlasticOpsMonitor.hpp.

Definition at line 126 of file PlasticOpsMonitor.hpp.

◆ reactionFe

boost::shared_ptr<DomainEle> PlasticOps::Monitor::reactionFe
private
Examples
PlasticOpsMonitor.hpp.

Definition at line 128 of file PlasticOpsMonitor.hpp.

◆ skinPostProcFe

boost::shared_ptr<SkinPostProcEle> PlasticOps::Monitor::skinPostProcFe
private
Examples
PlasticOpsMonitor.hpp.

Definition at line 127 of file PlasticOpsMonitor.hpp.

◆ uXScatter

std::tuple<SmartPetscObj<Vec>, SmartPetscObj<VecScatter> > PlasticOps::Monitor::uXScatter
private
Examples
PlasticOpsMonitor.hpp.

Definition at line 129 of file PlasticOpsMonitor.hpp.

◆ uYScatter

std::tuple<SmartPetscObj<Vec>, SmartPetscObj<VecScatter> > PlasticOps::Monitor::uYScatter
private
Examples
PlasticOpsMonitor.hpp.

Definition at line 130 of file PlasticOpsMonitor.hpp.

◆ uZScatter

std::tuple<SmartPetscObj<Vec>, SmartPetscObj<VecScatter> > PlasticOps::Monitor::uZScatter
private
Examples
PlasticOpsMonitor.hpp.

Definition at line 131 of file PlasticOpsMonitor.hpp.


The documentation for this struct was generated from the following file:
PlasticOps::Monitor::uXScatter
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uXScatter
Definition: PlasticOpsMonitor.hpp:129
PlasticOps::Monitor::dM
SmartPetscObj< DM > dM
Definition: PlasticOpsMonitor.hpp:125
PlasticOps::Monitor::uYScatter
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uYScatter
Definition: PlasticOpsMonitor.hpp:130
sdf.r
int r
Definition: sdf.py:8
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
PlasticOps::Monitor::skinPostProcFe
boost::shared_ptr< SkinPostProcEle > skinPostProcFe
Definition: PlasticOpsMonitor.hpp:127
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::createDMVector
auto createDMVector(DM dm)
Get smart vector from DM.
Definition: DMMoFEM.hpp:1099
SPACE_DIM
constexpr int SPACE_DIM
Definition: child_and_parent.cpp:16
MOFEM_LOG_C
#define MOFEM_LOG_C(channel, severity, format,...)
Definition: LogManager.hpp:311
PlasticOps::Monitor::uZScatter
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uZScatter
Definition: PlasticOpsMonitor.hpp:131
OpPPMap
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
Definition: photon_diffusion.cpp:29
MoFEM::DMoFEMGetInterfacePtr
PetscErrorCode DMoFEMGetInterfacePtr(DM dm, MoFEM::Interface **m_field_ptr)
Get pointer to MoFEM::Interface.
Definition: DMMoFEM.cpp:414
PlasticOps::Monitor::postProcFe
boost::shared_ptr< PostProcEle > postProcFe
Definition: PlasticOpsMonitor.hpp:126
PlasticOps::Monitor::reactionFe
boost::shared_ptr< DomainEle > reactionFe
Definition: PlasticOpsMonitor.hpp:128
MoFEM::DMoFEMLoopFiniteElements
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
Definition: DMMoFEM.cpp:586
MoFEM::PetscOptionsGetInt
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
Definition: DeprecatedPetsc.hpp:142
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
MoFEM::OpPostProcMapInMoab
Post post-proc data at points from hash maps.
Definition: PostProcBrokenMeshInMoabBase.hpp:698