v0.16.3
Loading...
Searching...
No Matches
PlasticIncrementalOptimizationInternal.hpp
Go to the documentation of this file.
1/**
2 * @file PlasticIncrementalOptimizationInternal.hpp
3 * @brief Shared implementation details for plastic incremental optimization
4 */
5
6#ifndef MOFEM_PLASTIC_INCREMENTAL_OPTIMIZATION_INTERNAL_HPP
7#define MOFEM_PLASTIC_INCREMENTAL_OPTIMIZATION_INTERNAL_HPP
8
9
11
12/** Restore a borrowed PETSc view while unwinding from a failed callback. */
13template <typename Restore> class PetscRestoreGuard {
14public:
15 explicit PetscRestoreGuard(Restore restore)
16 : restoreFunction(std::move(restore)) {}
19
21 if (active)
22 (void)restoreFunction();
23 }
24
25 MoFEMErrorCode restore() {
26 active = false;
27 return restoreFunction();
28 }
29
30private:
32 bool active = true;
33};
34
35/** Reconstruct a trace-free tensor in the orthonormal basis of Eq. (1.52),
36 * label eq:sym-basis. */
37template <typename T>
41 &t_coordinates) {
42 static_assert(SPACE_DIM == 3,
43 "The five-coordinate plastic basis is three-dimensional");
44 return Tensor2SymmetricDeviatorBasis::getTensor(t_coordinates);
45}
46
47/** Contract a symmetric tensor with the orthonormal basis of Eq. (1.52),
48 * label eq:sym-basis. */
49template <typename T>
53 static_assert(SPACE_DIM == 3,
54 "The five-coordinate plastic basis is three-dimensional");
55 return Tensor2SymmetricDeviatorBasis::getCoordinates(t_values);
56}
57
58/** Contract a full tensor with the symmetric trace-free basis of Eq. (1.52),
59 * label eq:sym-basis. Only its symmetric part contributes. */
60template <typename T>
64 static_assert(SPACE_DIM == 3,
65 "The five-coordinate plastic basis is three-dimensional");
66 return Tensor2SymmetricDeviatorBasis::getCoordinates(t_values);
67}
68
69/** Euclidean coordinate norm, equal to the Frobenius norm by Eq. (1.53),
70 * label eq:symmetric-basis-gram. */
71template <typename T>
74 &t_values) {
76 return std::sqrt(t_values(L) * t_values(L));
77}
78
79/** Frobenius norm of a symmetric tensor. */
80template <typename T>
81double
84 return std::sqrt(t_values(i, j) * t_values(i, j));
85}
86
87constexpr double plasticEquivalentIncrementScale = 0.81649658092772603273;
88constexpr double plasticEquivalentIncrementScaleSquared = 2. / 3.;
89constexpr double plasticYieldFunctionScale = 1.22474487139158904910;
90
91/** Evaluate alpha_epsilon from Eq. (1.81), including the exact epsilon=0
92 * limit. The quotient avoids cancellation close to the rounded apex. */
93inline double plasticEquivalentIncrement(const double coordinate_norm,
94 const double epsilon) {
95 const double scaled_norm = plasticEquivalentIncrementScale * coordinate_norm;
96 if (epsilon == 0)
97 return scaled_norm;
98 return scaled_norm * scaled_norm /
99 (std::hypot(scaled_norm, epsilon) + epsilon);
100}
101
103 std::array<double, plasticLogarithmicStretchCoordinateSize>;
104using PlasticHistory = std::map<EntityHandle, PackedPlasticCoordinates>;
105using PlasticKappaHistory = std::map<EntityHandle, double>;
106
107MoFEMErrorCode savePlasticHistory(EshelbianCore &ep, PlasticHistory &history);
108
109MoFEMErrorCode setPlasticHistory(
110 EshelbianCore &ep, const PlasticHistory &history,
112 double scale);
113
114MoFEMErrorCode savePlasticKappaHistory(EshelbianCore &ep,
115 PlasticKappaHistory &history);
116
117MoFEMErrorCode setPlasticKappaHistory(EshelbianCore &ep,
118 const PlasticKappaHistory &history);
119
120/** Clear only increment-valued mesh fields, preserving committed kappa. */
122
123MoFEMErrorCode setStateOnMesh(EshelbianCore &ep, Vec state);
124
126 const PlasticIncrementalOptimizationProblem &problem, Vec control,
127 double &value);
128
130 PlasticIncrementalOptimizationProblem &problem, Vec control,
131 Vec smooth_gradient, Vec objective_gradient);
132
134 const PlasticIncrementalOptimizationProblem &problem, DM constraint_dm,
135 Vec multipliers);
136
138 const PlasticIncrementalOptimizationProblem &problem, Vec control,
139 Vec constraints);
140
142 PlasticIncrementalOptimizationProblem &problem, Vec control,
143 Vec smooth_gradient, Mat jacobian);
144
146 PlasticIncrementalOptimizationProblem &problem, DM constraint_dm,
147 Vec control, Vec smooth_gradient, Vec inequality_multipliers,
148 PetscReal gradient_tolerance, PetscReal constraint_tolerance,
149 std::string &diagnostics);
150
151/** Assemble the fixed-state mixed-kinematic plastic conjugate diagnostic. */
152MoFEMErrorCode assemblePlasticForce(EshelbianCore &ep, Vec force);
153
154/** Assemble the reduced bulk Helmholtz-energy plastic gradient by adjoint. */
155MoFEMErrorCode assembleReducedHelmholtzGradient(EshelbianCore &ep, TS ts,
156 Vec gradient);
157
158} // namespace EshelbianPlasticity::PlasticIncrementalOptimizationInternal
159
160#endif // MOFEM_PLASTIC_INCREMENTAL_OPTIMIZATION_INTERNAL_HPP
#define FTENSOR_INDEXES(DIM,...)
#define FTENSOR_INDEX(DIM, I)
constexpr int SPACE_DIM
PetscRestoreGuard & operator=(const PetscRestoreGuard &)=delete
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'j', 3 > j
MoFEMErrorCode assemblePlasticInequalityJacobian(PlasticIncrementalOptimizationProblem &problem, Vec control, Vec smooth_gradient, Mat jacobian)
MoFEMErrorCode setPlasticHistory(EshelbianCore &ep, const PlasticHistory &history, const FTensor::Tensor2_symmetric< double, SPACE_DIM > &t_direction, const double scale)
MoFEMErrorCode assembleIncrementalObjectiveGradient(PlasticIncrementalOptimizationProblem &problem, Vec control, Vec smooth_gradient, Vec objective_gradient)
MoFEMErrorCode initialisePlasticInequalityMultipliers(const PlasticIncrementalOptimizationProblem &problem, DM constraint_dm, Vec multipliers)
MoFEMErrorCode setPlasticKappaHistory(EshelbianCore &ep, const PlasticKappaHistory &history)
MoFEMErrorCode savePlasticHistory(EshelbianCore &ep, PlasticHistory &history)
MoFEMErrorCode evaluatePlasticInequalityConstraints(const PlasticIncrementalOptimizationProblem &problem, Vec control, Vec constraints)
std::array< double, plasticLogarithmicStretchCoordinateSize > PackedPlasticCoordinates
MoFEMErrorCode savePlasticKappaHistory(EshelbianCore &ep, PlasticKappaHistory &history)
double plasticCoordinateNorm(const FTensor::Tensor1< T, plasticLogarithmicStretchCoordinateSize > &t_values)
MoFEMErrorCode validatePlasticIncrementalSolution(PlasticIncrementalOptimizationProblem &problem, DM constraint_dm, Vec control, Vec smooth_gradient, Vec inequality_multipliers, PetscReal gradient_tolerance, PetscReal constraint_tolerance, std::string &diagnostics)
MoFEMErrorCode evaluatePlasticIncrementalResistanceValue(const PlasticIncrementalOptimizationProblem &problem, Vec control, double &value)
double plasticEquivalentIncrement(const double coordinate_norm, const double epsilon)
FTensor::Tensor1< double, plasticLogarithmicStretchCoordinateSize > plasticLogarithmicStretchCoordinatesFromTensor(const FTensor::Tensor2_symmetric< T, SPACE_DIM > &t_values)
MoFEMErrorCode assembleReducedHelmholtzGradient(EshelbianCore &ep, TS ts, Vec gradient)
FTensor::Tensor2_symmetric< double, SPACE_DIM > plasticLogarithmicStretchTensorFromCoordinates(const FTensor::Tensor1< T, plasticLogarithmicStretchCoordinateSize > &t_coordinates)
double plasticFrobeniusNorm(const FTensor::Tensor2_symmetric< T, SPACE_DIM > &t_values)
double scale
Definition plastic.cpp:123