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 144 of file EshelbianTestingMonitor.cpp.

145 {
147
148 dataFieldEval->setEvalPoints(point.data(), point.size() / 3);
149 auto vec = createVectorMPI(eP.mField.get_comm(), 1, 1);
150 auto w_l2_at_pts = eP.dataAtPts->getSmallWL2AtPts();
151 w_l2_at_pts->resize(0, 0, false);
152
153 if (auto fe_ptr = dataFieldEval->feMethodPtr) {
154 CHKERR eP.mField.getInterface<FieldEvaluatorInterface>()
155 ->evalFEAtThePoint<SPACE_DIM>(
156 point.data(), 1e-12, problemPtr->getName(), "EP", dataFieldEval,
158 MF_EXIST, QUIET);
159 }
160 if (w_l2_at_pts->size1() == 0 || w_l2_at_pts->size2() == 0) {
161 CHKERR VecSetValue(vec, 0, 0.0, ADD_VALUES);
162 } else if (w_l2_at_pts->size1() == 1 || w_l2_at_pts->size2() == 1) {
163 auto add = [&]() {
164 std::ostringstream s;
165 s << str << " elem " << getFEEntityHandle() << " ";
166 return s.str();
167 };
168 MOFEM_LOG("EPSYNC", Sev::inform)
169 << add() << "comm rank " << eP.mField.get_comm_rank();
170 MOFEM_LOG("EPSYNC", Sev::inform)
171 << add() << "point " << getVectorAdaptor(point.data(), 3);
172 MOFEM_LOG("EPSYNC", Sev::inform)
173 << add() << "w " << *w_l2_at_pts;
174 double disp_at_point = (*w_l2_at_pts)(0, 0);
175 CHKERR VecSetValue(vec, 0, disp_at_point, ADD_VALUES);
176 } else {
177 SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY,
178 "Unexpected displacement data shape (%ld, %ld).",
179 static_cast<long>(w_l2_at_pts->size1()),
180 static_cast<long>(w_l2_at_pts->size2()));
181 }
182
184 if (ts_t > 0.0) {
185 CHKERR VecAssemblyBegin(vec);
186 CHKERR VecAssemblyEnd(vec);
187 double error;
188 PetscInt idx = 0;
189 if (eP.mField.get_comm_rank() == 0) {
190 CHKERR VecGetValues(vec, 1, &idx, &error);
191 }
192 MPI_Bcast(&error, 1, MPI_DOUBLE, 0, PETSC_COMM_WORLD);
193 // Check if the displacement is correct for the applied external
194 // strain For the bar problem, we expect a displacement of 0.25 at
195 // point A
196 if (std::abs(error - 0.25) > 1e-5) {
197 SETERRQ(PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
198 "Atom test %d failed: wrong displacement %.12g.", atom_test,
199 error);
200 }
201 }
203}
#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 PetscInt atom_test = 0;
46 char reaction_block_name[255] = "FIX_ALL";
47 CHKERR PetscOptionsGetInt(PETSC_NULLPTR, "", "-atom_test", &atom_test,
48 PETSC_NULLPTR);
49 CHKERR PetscOptionsGetString(PETSC_NULLPTR, "", "-atom_test_reaction_block",
50 reaction_block_name, 255, PETSC_NULLPTR);
51
52 switch (atom_test) {
53 case 14:
54 // Points for external strain
55 for (auto &pts : ptsHashMap) {
56 CHKERR checkExternalStrain(pts.second, pts.first, atom_test);
57 }
58 break;
59 case 15:
60 if (ts_t > 0.0) {
61 // L = 5, ty = tz = 1, A = 1, UDL Top face 0.1,
62 // Moment at x = 0 should be 0.25.
63 if (std::abs(reactionForcesMap[reaction_block_name][5] - 0.25) > 1e-3) {
65 SETERRQ(
66 PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
67 "Atom test 15 failed: reaction moment does not match expected "
68 "value. Got [%3.6e], expected [0.25].",
69 reactionForcesMap[reaction_block_name][5]);
70 }
71 }
72 break;
73 case 16:
74 if (ts_t > 0.0) {
75 // L = 5, ty = tz = 1, A = 1, E = 1000 * exp(0.1*x), u = 0.1, F = 1000 *
76 // 0.1/(1-exp(-0.5)) = 25.4149, so reaction force should
77 // be -25.4149
78 if (std::abs(reactionForcesMap[reaction_block_name][0] - (-25.4149)) >
79 1e-4) {
81 SETERRQ(PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
82 "Atom test 16 failed: reaction force does not match expected "
83 "value. Got [%3.6e, %3.6e, %3.6e], expected [-25.4149, 0.0, "
84 "0.0].",
85 reactionForcesMap[reaction_block_name][0],
86 reactionForcesMap[reaction_block_name][1],
87 reactionForcesMap[reaction_block_name][2]);
88 }
89 }
90 break;
91 case 17:
92 if (ts_t > 0.0) {
93 if (std::abs(*gEnergy - 1.27096) > 1e-5) {
95 SETERRQ(PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
96 "Atom test 17 failed: strain energy does not match expected "
97 "value. Got %3.6e, expected 1.27096.",
98 *gEnergy);
99 }
100 }
101 break;
102 case 18:
103 if (ts_step == 4) {
104 if (std::abs(eP.loadFactor - 12.5325) > 1e-5) {
106 SETERRQ(PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
107 "Atom test 18 failed: load factor does not match expected "
108 "value. Got %3.6e, expected 12.5325.",
109 eP.loadFactor);
110 }
111 }
112 break;
113 case 19:
114 if (ts_t > 0.0) {
115 if (std::abs(reactionForcesMap["SPRING_BC"][2] - 2.016e1) > 1e-3) {
117 SETERRQ(
118 PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
119 "Atom test 19 failed: reaction force does not match expected "
120 "value. Got [%3.6e], expected [2.016e1].",
121 reactionForcesMap["SPRING_BC"][2]);
122 }
123 }
124 break;
125 default:
126 break;
127 }
128
130 }
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
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 136 of file EshelbianTestingMonitor.cpp.

◆ dataFieldEval

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

Definition at line 139 of file EshelbianTestingMonitor.cpp.

◆ eP

EshelbianCore& EshelbianTestingMonitor::eP
protected

Definition at line 137 of file EshelbianTestingMonitor.cpp.

◆ gEnergy

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

Definition at line 141 of file EshelbianTestingMonitor.cpp.

◆ ptsHashMap

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

Definition at line 140 of file EshelbianTestingMonitor.cpp.

◆ reactionForcesMap

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

Definition at line 138 of file EshelbianTestingMonitor.cpp.


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