v0.16.3
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | Static Private Member Functions | List of all members
EshelbianTesting Struct Reference

Public Types

using MonitorPtr = boost::shared_ptr< EshelbianMonitor >
 

Static Public Member Functions

static MoFEMErrorCode addMonitorTests (EshelbianCore &ep, TS ts, MonitorPtr monitor)
 
static MoFEMErrorCode addFinalTests (EshelbianCore &ep, MonitorPtr monitor)
 Register final-state checks; the solver runs them with runTests().
 

Static Private Member Functions

static MoFEMErrorCode getReactionBlockName (std::string &name)
 
static MoFEMErrorCode getReaction (MonitorPtr monitor, const std::string &block, int component, double &value)
 

Detailed Description

Definition at line 14 of file EshelbianTestingMonitor.cpp.

Member Typedef Documentation

◆ MonitorPtr

using EshelbianTesting::MonitorPtr = boost::shared_ptr<EshelbianMonitor>

Definition at line 16 of file EshelbianTestingMonitor.cpp.

Member Function Documentation

◆ addFinalTests()

MoFEMErrorCode EshelbianTesting::addFinalTests ( EshelbianCore &  ep,
MonitorPtr  monitor 
)
static

Register final-state checks; the solver runs them with runTests().

Examples
/home/lk58p/mofem_install/vanilla_dev_release/mofem-cephas/mofem/users_modules/eshelbian_plasticity/src/impl/EshelbianPlasticity.cpp.

Definition at line 125 of file EshelbianTestingMonitor.cpp.

126 {
128 auto testing = ep.mField.getInterface<TestingInterface>();
129
130 auto add_reaction_test = [&](int number, const std::string &name,
131 const char *block_or_null, int component,
132 double expected, double tolerance) {
133 return testing->addTestCommandLine(
134 "", number, name,
135 [monitor, testing, name, block_or_null, component, expected,
136 tolerance]() {
138 std::string block;
139 if (block_or_null)
140 block = block_or_null;
141 else
143 double reaction;
144 CHKERR getReaction(monitor, block, component, reaction);
145 CHKERR testing->checkValue<TestType::SCALAR>(name, reaction, expected,
146 {tolerance, 0.});
148 });
149 };
150
151 // L = 5, ty = tz = 1, A = 1, UDL 0.1 on the top face: moment at x = 0.
152 CHKERR add_reaction_test(15, "reaction_moment", nullptr, 5, 0.25, 1e-3);
153 // L = 5, A = 1, E = 1000 exp(0.1 x), u = 0.1: F = 1000*0.1/(1-exp(-0.5)).
154 CHKERR add_reaction_test(16, "reaction_force", nullptr, 0, -25.4149, 1e-4);
155 CHKERR add_reaction_test(19, "spring_reaction", "SPRING_BC", 2, 2.016e1,
156 1e-3);
157
158 CHKERR testing->addTestCommandLine(
159 "", 17, "strain_energy", [monitor, testing]() {
161 CHKERR testing->checkValue<TestType::SCALAR>(
162 "strain energy", *monitor->getEnergy(), 1.27096, {1e-5, 0.});
164 });
165
166 // Load-factor solver: the factor reached at physical step 7 is fixed by
167 // the Griffith energy; other steps are not checked.
168 CHKERR testing->addTestCommandLine("", 18, "load_factor", [&ep, testing]() {
171 CHKERR testing->checkValue<TestType::SCALAR>(
172 "load factor at step 7", ep.loadFactor, 16.0393, {1e-5, 0.});
174 });
175
177}
EshelbianCore * ep
int number
std::string name
#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.
PetscBool testing
MoFEM::Interface & mField
static int physicalStepNumber
static MoFEMErrorCode getReactionBlockName(std::string &name)
static MoFEMErrorCode getReaction(MonitorPtr monitor, const std::string &block, int component, double &value)
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

◆ addMonitorTests()

MoFEMErrorCode EshelbianTesting::addMonitorTests ( EshelbianCore &  ep,
TS  ts,
MonitorPtr  monitor 
)
static

Register per-step checks. Call after TSMonitorSet(ts, TsMonitorSet, ...) so PETSc invokes them after EshelbianMonitor::postProcess.

Examples
/home/lk58p/mofem_install/vanilla_dev_release/mofem-cephas/mofem/users_modules/eshelbian_plasticity/src/impl/EshelbianPlasticity.cpp.

Definition at line 55 of file EshelbianTestingMonitor.cpp.

56 {
58 auto testing = ep.mField.getInterface<TestingInterface>();
59
60 // Bar with imposed external strain: the L2 displacement at x = 2.5 is 0.25.
61 CHKERR testing->addTSMonitor(
62 "", 14, "external_strain", ts,
63 [&ep, testing](TS, PetscInt, PetscReal, Vec) {
65 const std::array<double, 3> point{2.5, 0., 0.};
66 auto w_ptr = boost::make_shared<MatrixDouble>();
67 auto evaluator = ep.mField.getInterface<FieldEvaluatorInterface>();
68 auto data = evaluator->getData<VolumeElementForcesAndSourcesCore>(
69 point.data(), 1);
70 auto fe = data->feMethodPtr;
71 fe->getRuleHook = [](int, int, int) { return -1; };
72 // EP prepares its USER_BASE bubble field even when only the L2
73 // displacement is evaluated; no bubble values are consumed here.
74 fe->getUserPolynomialBase() =
75 boost::make_shared<CGGUserPolynomialBase>(nullptr, true);
76 CHKERR EshelbianPlasticity::AddHOOps<
78 fe->getOpPtrVector(), {H1, L2}, ep.materialH1Positions,
80 fe->getOpPtrVector().push_back(new OpCalculateVectorFieldValues<SPACE_DIM>(
81 ep.spatialL2Disp, w_ptr, MBTET));
82 CHKERR evaluator->buildTree<SPACE_DIM>(data, "EP");
83 CHKERR evaluator->evalFEAtThePoint<SPACE_DIM>(
84 point.data(), 1e-12, getProblemPtr(ep.dmElastic)->getName(), "EP",
87 const bool found = fe->gaussPts.size2() == 1;
88 // The point is owned by one rank; share its value so the check is
89 // collective with identical data everywhere.
90 double owner_data[2] = {0., 0.};
91 if (found && w_ptr->size1() && w_ptr->size2()) {
92 owner_data[0] = (*w_ptr)(0, 0);
93 owner_data[1] = 1.;
94 }
95 CHKERR MPI_Allreduce(MPI_IN_PLACE, owner_data, 2, MPI_DOUBLE, MPI_SUM,
97 if (owner_data[1] == 0.)
99 "Evaluation point (2.5, 0, 0) not found on any rank");
100 CHKERR testing->checkValue<TestType::POINTWISE>(
101 "external strain displacement", owner_data[0] / owner_data[1], 0.25,
102 {1e-5, 0.});
104 });
105
106 // Cook cantilever (cook.jou): end face height 16, thickness 5, traction
107 // profile 4*eta*(1-eta) with eta = (y-44)/16 and load scale t. Its integral
108 // 16*5*(2/3)*t is balanced by the clamp y reaction at every step.
109 CHKERR testing->addTSMonitor(
110 "", 20, "cook_reaction", ts,
111 [monitor, testing](TS, PetscInt, PetscReal t, Vec) {
113 std::string block;
115 double reaction;
116 CHKERR getReaction(monitor, block, 1, reaction);
117 CHKERR testing->checkValue<TestType::SCALAR>(
118 "cook clamp reaction", reaction, -(160.0 / 3.0) * t, {1e-7, 0.});
120 });
121
123}
boost::shared_ptr< DataAtIntegrationPts > data
constexpr int SPACE_DIM
@ QUIET
@ MF_EXIST
@ MOFEM_ATOM_TEST_INVALID
Definition definitions.h:40
auto getProblemPtr(DM dm)
get problem pointer from DM
Definition DMMoFEM.hpp:1195
constexpr double t
plate stiffness
Definition plate.cpp:58
boost::shared_ptr< Range > frontAdjEdges
const std::string spatialL2Disp
const std::string materialH1Positions
SmartPetscObj< DM > dmElastic
Elastic problem.
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0

◆ getReaction()

MoFEMErrorCode EshelbianTesting::getReaction ( MonitorPtr  monitor,
const std::string &  block,
int  component,
double &  value 
)
staticprivate

Definition at line 42 of file EshelbianTestingMonitor.cpp.

44 {
46 auto &reactions = monitor->getReactionMap();
47 auto it = reactions.find(block);
48 if (it == reactions.end())
49 SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
50 "No reaction computed for block %s", block.c_str());
51 value = it->second[component];
53}

◆ getReactionBlockName()

MoFEMErrorCode EshelbianTesting::getReactionBlockName ( std::string &  name)
staticprivate

Definition at line 33 of file EshelbianTestingMonitor.cpp.

33 {
35 char block_name[255] = "FIX_ALL";
36 CHKERR PetscOptionsGetString(PETSC_NULLPTR, "", "-test_reaction_block",
37 block_name, sizeof(block_name), PETSC_NULLPTR);
38 name = block_name;
40}
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)

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