Base class that provides capability for Newton return mapping iterations on a single variable.
More...
#include <ADSingleVariableReturnMappingSolution.h>
|
void | returnMappingSolve (const ADReal &effective_trial_stress, ADReal &scalar, const ConsoleStream &console) |
| Perform the return mapping iterations. More...
|
|
virtual ADReal | minimumPermissibleValue (const ADReal &effective_trial_stress) const |
| Compute the minimum permissible value of the scalar. More...
|
|
virtual ADReal | maximumPermissibleValue (const ADReal &effective_trial_stress) const |
| Compute the maximum permissible value of the scalar. More...
|
|
virtual ADReal | initialGuess (const ADReal &) |
| Compute an initial guess for the value of the scalar. More...
|
|
virtual ADReal | computeResidual (const ADReal &effective_trial_stress, const ADReal &scalar)=0 |
| Compute the residual for a predicted value of the scalar. More...
|
|
virtual ADReal | computeDerivative (const ADReal &effective_trial_stress, const ADReal &scalar)=0 |
| Compute the derivative of the residual as a function of the scalar variable. More...
|
|
virtual Real | computeReferenceResidual (const ADReal &effective_trial_stress, const ADReal &scalar)=0 |
| Compute a reference quantity to be used for checking relative convergence. More...
|
|
virtual void | iterationFinalize (ADReal) |
| Finalize internal state variables for a model for a given iteration. More...
|
|
virtual void | outputIterationSummary (std::stringstream *iter_output, const unsigned int total_it) |
| Output summary information for the convergence history of the model. More...
|
|
virtual void | outputIterationStep (std::stringstream *iter_output, const ADReal &effective_trial_stress, const ADReal &scalar, const Real reference_residual) |
| Output information for a single iteration step to build the convergence history of the model. More...
|
|
bool | converged (const ADReal &residual, const Real reference) |
| Check to see whether the residual is within the convergence limits. More...
|
|
|
bool | _check_range |
| Whether to check to see whether iterative solution is within admissible range, and set within that range if outside. More...
|
|
bool | _line_search |
| Whether to use line searches to improve convergence. More...
|
|
bool | _bracket_solution |
| Whether to save upper and lower bounds of root for scalar, and set solution to the midpoint between those bounds if outside them. More...
|
|
|
SolveState | internalSolve (const ADReal effective_trial_stress, ADReal &scalar, std::stringstream *iter_output=nullptr) |
| Method called from within this class to perform the actual return mappping iterations. More...
|
|
bool | convergedAcceptable (const unsigned int it, const Real reference) |
| Check to see whether the residual is within acceptable convergence limits. More...
|
|
void | checkPermissibleRange (ADReal &scalar, ADReal &scalar_increment, const ADReal &scalar_old, const ADReal min_permissible_scalar, const ADReal max_permissible_scalar, std::stringstream *iter_output) |
| Check to see whether solution is within admissible range, and set it within that range if it is not. More...
|
|
void | updateBounds (const ADReal &scalar, const ADReal &residual, const Real init_resid_sign, ADReal &scalar_upper_bound, ADReal &scalar_lower_bound, std::stringstream *iter_output) |
| Update the upper and lower bounds of the root for the effective inelastic strain. More...
|
|
template<ComputeStage compute_stage>
class ADSingleVariableReturnMappingSolution< compute_stage >
Base class that provides capability for Newton return mapping iterations on a single variable.
Definition at line 32 of file ADSingleVariableReturnMappingSolution.h.
◆ InternalSolveOutput
template<ComputeStage compute_stage>
◆ SolveState
template<ComputeStage compute_stage>
◆ ADSingleVariableReturnMappingSolution()
template<ComputeStage compute_stage>
◆ ~ADSingleVariableReturnMappingSolution()
template<ComputeStage compute_stage>
◆ checkPermissibleRange()
template<ComputeStage compute_stage>
void ADSingleVariableReturnMappingSolution< compute_stage >::checkPermissibleRange |
( |
ADReal & |
scalar, |
|
|
ADReal & |
scalar_increment, |
|
|
const ADReal & |
scalar_old, |
|
|
const ADReal |
min_permissible_scalar, |
|
|
const ADReal |
max_permissible_scalar, |
|
|
std::stringstream * |
iter_output |
|
) |
| |
|
private |
Check to see whether solution is within admissible range, and set it within that range if it is not.
- Parameters
-
scalar | Current value of the inelastic strain increment |
scalar_increment | Incremental change in scalar from the previous iteration |
scalar_old | Previous value of scalar |
min_permissible_scalar | Minimum permissible value of scalar |
max_permissible_scalar | Maximum permissible value of scalar |
iter_output | Output stream |
Definition at line 334 of file ADSingleVariableReturnMappingSolution.C.
342 if (scalar > max_permissible_scalar)
344 scalar_increment = (max_permissible_scalar - scalar_old) / 2.0;
345 scalar = scalar_old + scalar_increment;
347 *iter_output <<
"Scalar greater than maximum ("
348 << MetaPhysicL::raw_value(max_permissible_scalar)
349 <<
") adjusted scalar=" << MetaPhysicL::raw_value(scalar)
350 <<
" scalar_increment=" << MetaPhysicL::raw_value(scalar_increment) << std::endl;
352 else if (scalar < min_permissible_scalar)
354 scalar_increment = (min_permissible_scalar - scalar_old) / 2.0;
355 scalar = scalar_old + scalar_increment;
357 *iter_output <<
"Scalar less than minimum (" << MetaPhysicL::raw_value(min_permissible_scalar)
358 <<
") adjusted scalar=" << MetaPhysicL::raw_value(scalar)
359 <<
" scalar_increment=" << MetaPhysicL::raw_value(scalar_increment) << std::endl;
◆ computeDerivative()
template<ComputeStage compute_stage>
◆ computeReferenceResidual()
template<ComputeStage compute_stage>
◆ computeResidual()
template<ComputeStage compute_stage>
◆ converged()
template<ComputeStage compute_stage>
Check to see whether the residual is within the convergence limits.
- Parameters
-
residual | Current value of the residual |
reference | Current value of the reference quantity |
- Returns
- Whether the model converged
Definition at line 301 of file ADSingleVariableReturnMappingSolution.C.
304 const Real residual = MetaPhysicL::raw_value(ad_residual);
◆ convergedAcceptable()
template<ComputeStage compute_stage>
Check to see whether the residual is within acceptable convergence limits.
This will only return true if it has been determined that progress is no longer being made and that the residual is within the acceptable limits.
- Parameters
-
residual | Current iteration count |
residual | Current value of the residual |
reference | Current value of the reference quantity |
- Returns
- Whether the model converged
Definition at line 311 of file ADSingleVariableReturnMappingSolution.C.
322 const Real convergence_history_factor = 10.0;
323 if (std::abs(
_residual * convergence_history_factor) <
◆ initialGuess()
template<ComputeStage compute_stage>
Compute an initial guess for the value of the scalar.
For some cases, an intellegent starting point can provide enhanced robustness in the Newton iterations. This is also an opportunity for classes that derive from this to perform initialization tasks.
- Parameters
-
effective_trial_stress | Effective trial stress |
Reimplemented in ADViscoplasticityStressUpdate< compute_stage >.
Definition at line 82 of file ADSingleVariableReturnMappingSolution.h.
◆ internalSolve()
template<ComputeStage compute_stage>
Method called from within this class to perform the actual return mappping iterations.
- Parameters
-
effective_trial_stress | Effective trial stress |
scalar | Inelastic strain increment magnitude being solved for |
iter_output | Output stream – if null, no output is produced |
- Returns
- Whether the solution was successful
Definition at line 162 of file ADSingleVariableReturnMappingSolution.C.
166 ADReal scalar_old = scalar;
167 ADReal scalar_increment = 0.0;
170 ADReal scalar_upper_bound = max_permissible_scalar;
171 ADReal scalar_lower_bound = min_permissible_scalar;
177 Real init_resid_sign = MathUtils::sign(MetaPhysicL::raw_value(
_residual));
194 scalar = scalar_old + scalar_increment;
200 min_permissible_scalar,
201 max_permissible_scalar,
210 scalar,
_residual, init_resid_sign, scalar_upper_bound, scalar_lower_bound, iter_output);
219 bool modified_increment =
false;
226 ADReal alpha = residual_old / (residual_old -
_residual);
227 alpha = MathUtils::clamp(alpha, 1.0e-2, 1.0);
231 modified_increment =
true;
232 scalar_increment *= alpha;
234 *iter_output <<
" Line search alpha = " << MetaPhysicL::raw_value(alpha)
235 <<
" increment = " << MetaPhysicL::raw_value(scalar_increment)
245 if (scalar_old + scalar_increment >= scalar_upper_bound ||
246 scalar_old + scalar_increment <= scalar_lower_bound)
248 if (scalar_upper_bound != max_permissible_scalar &&
249 scalar_lower_bound != min_permissible_scalar)
251 const Real frac = 0.5;
253 (1.0 - frac) * scalar_lower_bound + frac * scalar_upper_bound - scalar_old;
254 modified_increment =
true;
256 *iter_output <<
" Trial scalar_increment exceeded bounds. Setting between "
257 "lower/upper bounds. frac: "
258 << frac << std::endl;
265 if (modified_increment)
267 scalar = scalar_old + scalar_increment;
◆ iterationFinalize()
template<ComputeStage compute_stage>
◆ maximumPermissibleValue()
template<ComputeStage compute_stage>
◆ minimumPermissibleValue()
template<ComputeStage compute_stage>
◆ outputIterationStep()
template<ComputeStage compute_stage>
void ADSingleVariableReturnMappingSolution< compute_stage >::outputIterationStep |
( |
std::stringstream * |
iter_output, |
|
|
const ADReal & |
effective_trial_stress, |
|
|
const ADReal & |
scalar, |
|
|
const Real |
reference_residual |
|
) |
| |
|
protectedvirtual |
Output information for a single iteration step to build the convergence history of the model.
- Parameters
-
iter_output | Output stream |
it | Current iteration count |
effective_trial_stress | Effective trial stress |
scalar | Inelastic strain increment magnitude being solved for |
residual | Current value of the residual |
reference | Current value of the reference quantity |
Definition at line 393 of file ADSingleVariableReturnMappingSolution.C.
402 const Real residual = MetaPhysicL::raw_value(
_residual);
404 *iter_output <<
" iteration=" << it
405 <<
" trial_stress=" << MetaPhysicL::raw_value(effective_trial_stress)
406 <<
" scalar=" << MetaPhysicL::raw_value(scalar) <<
" residual=" << residual
407 <<
" ref_res=" << reference_residual
408 <<
" rel_res=" << std::abs(residual) / reference_residual
◆ outputIterationSummary()
template<ComputeStage compute_stage>
◆ returnMappingSolve()
template<ComputeStage compute_stage>
Perform the return mapping iterations.
- Parameters
-
effective_trial_stress | Effective trial stress |
scalar | Inelastic strain increment magnitude being solved for |
console | Console output |
Definition at line 101 of file ADSingleVariableReturnMappingSolution.C.
105 std::unique_ptr<std::stringstream> iter_output =
107 ? libmesh_make_unique<std::stringstream>()
121 throw MooseException(
"");
125 iter_output = libmesh_make_unique<std::stringstream>();
131 *iter_output <<
"Encountered inf or nan in material return mapping iterations.\n";
135 *iter_output <<
"Exceeded maximum iterations in material return mapping iterations.\n";
139 mooseError(
"Unhandled solver state");
145 internalSolve(effective_trial_stress, scalar, iter_output.get());
149 throw MooseException(iter_output->str());
156 console << iter_output->str();
◆ updateBounds()
template<ComputeStage compute_stage>
void ADSingleVariableReturnMappingSolution< compute_stage >::updateBounds |
( |
const ADReal & |
scalar, |
|
|
const ADReal & |
residual, |
|
|
const Real |
init_resid_sign, |
|
|
ADReal & |
scalar_upper_bound, |
|
|
ADReal & |
scalar_lower_bound, |
|
|
std::stringstream * |
iter_output |
|
) |
| |
|
private |
Update the upper and lower bounds of the root for the effective inelastic strain.
- Parameters
-
scalar | Current value of the inelastic strain increment |
residual | Current value of the residual |
init_resid_sign | Sign of the initial value of the residual |
scalar_upper_bound | Upper bound value of scalar |
scalar_lower_bound | Lower bound value of scalar |
iter_output | Output stream |
Definition at line 365 of file ADSingleVariableReturnMappingSolution.C.
373 if (residual * init_resid_sign < 0.0 && scalar < scalar_upper_bound)
375 scalar_upper_bound = scalar;
376 if (scalar_upper_bound < scalar_lower_bound)
378 scalar_upper_bound = scalar_lower_bound;
379 scalar_lower_bound = 0.0;
381 *iter_output <<
" Corrected for scalar_upper_bound < scalar_lower_bound" << std::endl;
386 else if (residual * init_resid_sign > 0.0 && scalar > scalar_lower_bound &&
387 scalar < scalar_upper_bound)
388 scalar_lower_bound = scalar;
◆ validParams()
template<ComputeStage compute_stage>
Definition at line 32 of file ADSingleVariableReturnMappingSolution.C.
34 InputParameters params = emptyInputParameters();
35 params.addParam<Real>(
36 "relative_tolerance", 1e-8,
"Relative convergence tolerance for Newton iteration");
37 params.addParam<Real>(
38 "absolute_tolerance", 1e-11,
"Absolute convergence tolerance for Newton iteration");
39 params.addParam<Real>(
"acceptable_multiplier",
41 "Factor applied to relative and absolute "
42 "tolerance for acceptable convergence if "
43 "iterations are no longer making progress");
46 MooseEnum internal_solve_output_on_enum(
"never on_error always",
"on_error");
47 params.addParam<MooseEnum>(
"internal_solve_output_on",
48 internal_solve_output_on_enum,
49 "When to output internal Newton solve information");
50 params.addParam<
bool>(
"internal_solve_full_iteration_history",
52 "Set true to output full internal Newton iteration history at times "
53 "determined by `internal_solve_output_on`. If false, only a summary is "
55 params.addParamNamesToGroup(
"internal_solve_output_on internal_solve_full_iteration_history",
Referenced by ADViscoplasticityStressUpdateBase< compute_stage >::validParams(), and ADRadialReturnStressUpdate< compute_stage >::validParams().
◆ _absolute_tolerance
template<ComputeStage compute_stage>
◆ _acceptable_multiplier
template<ComputeStage compute_stage>
◆ _bracket_solution
template<ComputeStage compute_stage>
◆ _check_range
template<ComputeStage compute_stage>
◆ _initial_residual
template<ComputeStage compute_stage>
◆ _internal_solve_full_iteration_history
template<ComputeStage compute_stage>
◆ _internal_solve_output_on
template<ComputeStage compute_stage>
◆ _iteration
template<ComputeStage compute_stage>
◆ _line_search
template<ComputeStage compute_stage>
◆ _max_its
template<ComputeStage compute_stage>
Maximum number of return mapping iterations.
This exists only to avoid an infinite loop, and is is intended to be a large number that is not settable by the user.
Definition at line 172 of file ADSingleVariableReturnMappingSolution.h.
◆ _num_resids
template<ComputeStage compute_stage>
◆ _relative_tolerance
template<ComputeStage compute_stage>
◆ _residual
template<ComputeStage compute_stage>
◆ _residual_history
template<ComputeStage compute_stage>
◆ _svrms_name
template<ComputeStage compute_stage>
The documentation for this class was generated from the following files:
virtual ADReal initialGuess(const ADReal &)
Compute an initial guess for the value of the scalar.
const bool _internal_solve_full_iteration_history
Whether to output iteration information all the time (regardless of whether iterations converge)
bool _bracket_solution
Whether to save upper and lower bounds of root for scalar, and set solution to the midpoint between t...
virtual void outputIterationStep(std::stringstream *iter_output, const ADReal &effective_trial_stress, const ADReal &scalar, const Real reference_residual)
Output information for a single iteration step to build the convergence history of the model.
unsigned int _iteration
iteration number
ADReal _initial_residual
Residual values, kept as members to retain solver state for summary outputting.
bool convergedAcceptable(const unsigned int it, const Real reference)
Check to see whether the residual is within acceptable convergence limits.
std::vector< Real > _residual_history
History of residuals used to check whether progress is still being made on decreasing the residual.
virtual ADReal maximumPermissibleValue(const ADReal &effective_trial_stress) const
Compute the maximum permissible value of the scalar.
Real _relative_tolerance
Relative convergence tolerance.
enum ADSingleVariableReturnMappingSolution::InternalSolveOutput _internal_solve_output_on
Real _acceptable_multiplier
Multiplier applied to relative and absolute tolerances for acceptable convergence.
bool converged(const ADReal &residual, const Real reference)
Check to see whether the residual is within the convergence limits.
void updateBounds(const ADReal &scalar, const ADReal &residual, const Real init_resid_sign, ADReal &scalar_upper_bound, ADReal &scalar_lower_bound, std::stringstream *iter_output)
Update the upper and lower bounds of the root for the effective inelastic strain.
const unsigned int _max_its
Maximum number of return mapping iterations.
const std::string _svrms_name
MOOSE input name of the object performing the solve.
void checkPermissibleRange(ADReal &scalar, ADReal &scalar_increment, const ADReal &scalar_old, const ADReal min_permissible_scalar, const ADReal max_permissible_scalar, std::stringstream *iter_output)
Check to see whether solution is within admissible range, and set it within that range if it is not.
virtual void iterationFinalize(ADReal)
Finalize internal state variables for a model for a given iteration.
virtual ADReal minimumPermissibleValue(const ADReal &effective_trial_stress) const
Compute the minimum permissible value of the scalar.
bool _check_range
Whether to check to see whether iterative solution is within admissible range, and set within that ra...
const std::size_t _num_resids
Number of residuals to be stored in history.
Real _absolute_tolerance
Absolute convergence tolerance.
bool _line_search
Whether to use line searches to improve convergence.
virtual ADReal computeResidual(const ADReal &effective_trial_stress, const ADReal &scalar)=0
Compute the residual for a predicted value of the scalar.
virtual void outputIterationSummary(std::stringstream *iter_output, const unsigned int total_it)
Output summary information for the convergence history of the model.
SolveState internalSolve(const ADReal effective_trial_stress, ADReal &scalar, std::stringstream *iter_output=nullptr)
Method called from within this class to perform the actual return mappping iterations.
virtual ADReal computeDerivative(const ADReal &effective_trial_stress, const ADReal &scalar)=0
Compute the derivative of the residual as a function of the scalar variable.
virtual Real computeReferenceResidual(const ADReal &effective_trial_stress, const ADReal &scalar)=0
Compute a reference quantity to be used for checking relative convergence.