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

Public Types

using SetPtsData = FieldEvaluatorInterface::SetPtsData
 

Public Member Functions

 EshelbianTestingMonitor (EshelbianCore &ep, boost::shared_ptr< EshelbianMonitor > base_monitor_ptr)
 
MoFEMErrorCode preProcess ()
 
MoFEMErrorCode operator() ()
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode checkExternalStrain (std::array< double, 3 > point, std::string str, PetscInt atom_test)
 

Protected Attributes

boost::shared_ptr< EshelbianMonitorbaseMonitorPtr
 
EshelbianCoreeP
 
std::map< std::string, std::array< double, 6 > > & reactionForcesMap
 
boost::shared_ptr< SetPtsDatadataFieldEval
 
std::map< std::string, std::array< double, 3 > > & ptsHashMap
 
boost::shared_ptr< doublegEnergy
 

Detailed Description

Definition at line 6 of file EshelbianTestingMonitor.cpp.

Member Typedef Documentation

◆ SetPtsData

using EshelbianTestingMonitor::SetPtsData = FieldEvaluatorInterface::SetPtsData

Definition at line 7 of file EshelbianTestingMonitor.cpp.

Constructor & Destructor Documentation

◆ EshelbianTestingMonitor()

EshelbianTestingMonitor::EshelbianTestingMonitor ( EshelbianCore ep,
boost::shared_ptr< EshelbianMonitor base_monitor_ptr 
)
inline

Definition at line 9 of file EshelbianTestingMonitor.cpp.

11 : baseMonitorPtr(base_monitor_ptr), eP(baseMonitorPtr->getEpCore()),
12 ptsHashMap(baseMonitorPtr->getHashMap()),
13 reactionForcesMap(baseMonitorPtr->getReactionMap()),
14 gEnergy(baseMonitorPtr->getEnergy()),
15 dataFieldEval(baseMonitorPtr->getDataField()) {
16
17 PetscBool test_cook_flg = PETSC_FALSE;
18 PetscInt atom_test = 0;
19 CHK_THROW_MESSAGE(PetscOptionsGetBool(PETSC_NULLPTR, "", "-test_cook_pts",
20 &test_cook_flg, PETSC_NULLPTR),
21 "get post proc points");
22 CHKERR PetscOptionsGetInt(PETSC_NULLPTR, "", "-atom_test", &atom_test,
23 PETSC_NULLPTR);
24
25 if (test_cook_flg) {
26 ptsHashMap["Point A"] = {48., 60., 4.999};
27 ptsHashMap["Point B"] = {48. / 2., 44. + (60. - 44.) / 2., 0.};
28 ptsHashMap["Point C"] = {48. / 2., (44. - 0.) / 2., 0.};
29 }
30 if (atom_test == 14) {
31 // Points for atom test 14: check external strain
32 ptsHashMap["Point (2.5, 0., 0.)"] = {2.5, 0, 0.};
33 }
34 }
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define CHKERR
Inline error check.
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)
std::map< std::string, std::array< double, 3 > > & ptsHashMap
boost::shared_ptr< double > gEnergy
boost::shared_ptr< EshelbianMonitor > baseMonitorPtr
std::map< std::string, std::array< double, 6 > > & reactionForcesMap
boost::shared_ptr< SetPtsData > dataFieldEval
int atom_test
Atom test.
Definition plastic.cpp:122

Member Function Documentation

◆ checkExternalStrain()

MoFEMErrorCode EshelbianTestingMonitor::checkExternalStrain ( std::array< double, 3 >  point,
std::string  str,
PetscInt  atom_test 
)

Definition at line 140 of file EshelbianTestingMonitor.cpp.

141 {
143
144 dataFieldEval->setEvalPoints(point.data(), point.size() / 3);
145 auto vec = createVectorMPI(eP.mField.get_comm(), 1, 1);
146 auto w_l2_at_pts = eP.dataAtPts->getSmallWL2AtPts();
147 w_l2_at_pts->resize(0, 0, false);
148
149 if (auto fe_ptr = dataFieldEval->feMethodPtr) {
150 CHKERR eP.mField.getInterface<FieldEvaluatorInterface>()
151 ->evalFEAtThePoint<SPACE_DIM>(
152 point.data(), 1e-12, problemPtr->getName(), "EP", dataFieldEval,
154 MF_EXIST, QUIET);
155 }
156 if (w_l2_at_pts->size1() == 0 || w_l2_at_pts->size2() == 0) {
157 CHKERR VecSetValue(vec, 0, 0.0, ADD_VALUES);
158 } else if (w_l2_at_pts->size1() == 1 || w_l2_at_pts->size2() == 1) {
159 auto add = [&]() {
160 std::ostringstream s;
161 s << str << " elem " << getFEEntityHandle() << " ";
162 return s.str();
163 };
164 MOFEM_LOG("EPSYNC", Sev::inform)
165 << add() << "comm rank " << eP.mField.get_comm_rank();
166 MOFEM_LOG("EPSYNC", Sev::inform)
167 << add() << "point " << getVectorAdaptor(point.data(), 3);
168 MOFEM_LOG("EPSYNC", Sev::inform)
169 << add() << "w " << *w_l2_at_pts;
170 double disp_at_point = (*w_l2_at_pts)(0, 0);
171 CHKERR VecSetValue(vec, 0, disp_at_point, ADD_VALUES);
172 } else {
173 SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY,
174 "Unexpected displacement data shape (%ld, %ld).",
175 static_cast<long>(w_l2_at_pts->size1()),
176 static_cast<long>(w_l2_at_pts->size2()));
177 }
178
180 if (ts_t > 0.0) {
181 CHKERR VecAssemblyBegin(vec);
182 CHKERR VecAssemblyEnd(vec);
183 double error;
184 PetscInt idx = 0;
185 if (eP.mField.get_comm_rank() == 0) {
186 CHKERR VecGetValues(vec, 1, &idx, &error);
187 }
188 MPI_Bcast(&error, 1, MPI_DOUBLE, 0, PETSC_COMM_WORLD);
189 // Check if the displacement is correct for the applied external
190 // strain For the bar problem, we expect a displacement of 0.25 at
191 // point A
192 if (std::abs(error - 0.25) > 1e-5) {
193 SETERRQ(PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
194 "Atom test %d failed: wrong displacement %.12g.", atom_test,
195 error);
196 }
197 }
199}
#define MOFEM_LOG_SEVERITY_SYNC(comm, severity)
Synchronise "SYNC" on curtain severity level.
@ QUIET
@ MF_EXIST
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
Definition definitions.h:40
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MOFEM_LOG(channel, severity)
Log.
auto getVectorAdaptor(T1 ptr, const size_t n)
Get Vector adaptor.
Definition Templates.hpp:49
auto createVectorMPI(MPI_Comm comm, PetscInt n, PetscInt N)
Create MPI Vector.
MoFEM::Interface & mField
boost::shared_ptr< DataAtIntegrationPts > dataAtPts
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

◆ operator()()

MoFEMErrorCode EshelbianTestingMonitor::operator() ( )
inline

Definition at line 38 of file EshelbianTestingMonitor.cpp.

38{ return 0; }

◆ postProcess()

MoFEMErrorCode EshelbianTestingMonitor::postProcess ( )
inline

Definition at line 40 of file EshelbianTestingMonitor.cpp.

40 {
42
43 MOFEM_LOG("EP", Sev::inform) << "Testing Monitor postProcess";
44
45 PetscBool test_cook_flg = PETSC_FALSE;
46 PetscInt atom_test = 0;
47 CHK_THROW_MESSAGE(PetscOptionsGetBool(PETSC_NULLPTR, "", "-test_cook_pts",
48 &test_cook_flg, PETSC_NULLPTR),
49 "get post proc points");
50 CHKERR PetscOptionsGetInt(PETSC_NULLPTR, "", "-atom_test", &atom_test,
51 PETSC_NULLPTR);
52
53 if (test_cook_flg) {
54 // Points for Cook beam
55 for (auto &pts : ptsHashMap) {
56 CHKERR baseMonitorPtr->postProcAtPoints(pts.second, pts.first);
58 }
59 }
60
61 switch (atom_test) {
62 case 14:
63 // Points for external strain
64 for (auto &pts : ptsHashMap) {
65 CHKERR checkExternalStrain(pts.second, pts.first, atom_test);
66 }
67 break;
68 case 15:
69 if (ts_t > 0.0) {
70 // L = 5, ty = tz = 1, A = 1, UDL Top face 0.1,
71 // Moment at x = 0 should be 0.25.
72 if (std::abs(reactionForcesMap["FIX_ALL"][5] - 0.25) > 1e-3) {
74 SETERRQ(
75 PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
76 "Atom test 15 failed: reaction moment does not match expected "
77 "value. Got [%3.6e], expected [0.25].",
78 reactionForcesMap["FIX_ALL"][5]);
79 }
80 }
81 break;
82 case 16:
83 if (ts_t > 0.0) {
84 // L = 5, ty = tz = 1, A = 1, E = 1000 * exp(0.1*x), u = 0.1, F = 1000 *
85 // 0.1/(1-exp(-0.5)) = 25.4149, so reaction force should
86 // be -25.4149
87 if (std::abs(reactionForcesMap["FIX_ALL"][0] - (-25.4149)) > 1e-4) {
89 SETERRQ(PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
90 "Atom test 16 failed: reaction force does not match expected "
91 "value. Got [%3.6e, %3.6e, %3.6e], expected [-25.4149, 0.0, "
92 "0.0].",
93 reactionForcesMap["FIX_ALL"][0],
94 reactionForcesMap["FIX_ALL"][1],
95 reactionForcesMap["FIX_ALL"][2]);
96 }
97 }
98 break;
99 case 17:
100 if (ts_t > 0.0) {
101 if (std::abs(*gEnergy - 1.27096) > 1e-5) {
103 SETERRQ(PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
104 "Atom test 17 failed: strain energy does not match expected "
105 "value. Got %3.6e, expected 1.27096.",
106 *gEnergy);
107 }
108 }
109 break;
110 case 18:
111 if (ts_step == 4) {
112 if (std::abs(eP.loadFactor - 12.5325) > 1e-5) {
114 SETERRQ(PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
115 "Atom test 18 failed: load factor does not match expected "
116 "value. Got %3.6e, expected 12.5325.",
117 eP.loadFactor);
118 }
119 }
120 break;
121 default:
122 break;
123 }
124
126 }
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
MoFEMErrorCode checkExternalStrain(std::array< double, 3 > point, std::string str, PetscInt atom_test)

◆ preProcess()

MoFEMErrorCode EshelbianTestingMonitor::preProcess ( )
inline

Definition at line 36 of file EshelbianTestingMonitor.cpp.

36{ return 0; }

Member Data Documentation

◆ baseMonitorPtr

boost::shared_ptr<EshelbianMonitor> EshelbianTestingMonitor::baseMonitorPtr
protected

Definition at line 132 of file EshelbianTestingMonitor.cpp.

◆ dataFieldEval

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

Definition at line 135 of file EshelbianTestingMonitor.cpp.

◆ eP

EshelbianCore& EshelbianTestingMonitor::eP
protected

Definition at line 133 of file EshelbianTestingMonitor.cpp.

◆ gEnergy

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

Definition at line 137 of file EshelbianTestingMonitor.cpp.

◆ ptsHashMap

std::map<std::string, std::array<double, 3> >& EshelbianTestingMonitor::ptsHashMap
protected

Definition at line 136 of file EshelbianTestingMonitor.cpp.

◆ reactionForcesMap

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

Definition at line 134 of file EshelbianTestingMonitor.cpp.


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