www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
ADSingleVariableReturnMappingSolution< compute_stage > Class Template Referenceabstract

Base class that provides capability for Newton return mapping iterations on a single variable. More...

#include <ADSingleVariableReturnMappingSolution.h>

Inheritance diagram for ADSingleVariableReturnMappingSolution< compute_stage >:
[legend]

Public Member Functions

 ADSingleVariableReturnMappingSolution (const InputParameters &parameters)
 
virtual ~ADSingleVariableReturnMappingSolution ()
 

Protected Member Functions

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...
 

Protected Attributes

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...
 

Private Types

enum  InternalSolveOutput { InternalSolveOutput::NEVER, InternalSolveOutput::ON_ERROR, InternalSolveOutput::ALWAYS }
 
enum  SolveState { SolveState::SUCCESS, SolveState::NAN_INF, SolveState::EXCEEDED_ITERATIONS }
 

Private Member Functions

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 converged (const ADReal &residual, const Real reference)
 Check to see whether the residual is within the convergence limits. 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...
 
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...
 

Private Attributes

enum ADSingleVariableReturnMappingSolution::InternalSolveOutput _internal_solve_output_on
 
const unsigned int _max_its
 Maximum number of return mapping iterations. More...
 
const bool _internal_solve_full_iteration_history
 Whether to output iteration information all the time (regardless of whether iterations converge) More...
 
Real _relative_tolerance
 Relative convergence tolerance. More...
 
Real _absolute_tolerance
 Absolute convergence tolerance. More...
 
Real _acceptable_multiplier
 Multiplier applied to relative and absolute tolerances for acceptable convergence. More...
 
const std::size_t _num_resids
 Number of residuals to be stored in history. More...
 
std::vector< Real > _residual_history
 History of residuals used to check whether progress is still being made on decreasing the residual. More...
 
unsigned int _iteration
 iteration number More...
 
const std::string _svrms_name
 MOOSE input name of the object performing the solve. More...
 
ADReal _initial_residual
 Residual values, kept as members to retain solver state for summary outputting. More...
 
ADReal _residual
 

Detailed Description

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 31 of file ADSingleVariableReturnMappingSolution.h.

Member Enumeration Documentation

◆ InternalSolveOutput

template<ComputeStage compute_stage>
enum ADSingleVariableReturnMappingSolution::InternalSolveOutput
strongprivate
Enumerator
NEVER 
ON_ERROR 
ALWAYS 

Definition at line 131 of file ADSingleVariableReturnMappingSolution.h.

132  {
133  NEVER,
134  ON_ERROR,
135  ALWAYS
enum ADSingleVariableReturnMappingSolution::InternalSolveOutput _internal_solve_output_on

◆ SolveState

template<ComputeStage compute_stage>
enum ADSingleVariableReturnMappingSolution::SolveState
strongprivate
Enumerator
SUCCESS 
NAN_INF 
EXCEEDED_ITERATIONS 

Definition at line 138 of file ADSingleVariableReturnMappingSolution.h.

139  {
140  SUCCESS,
141  NAN_INF,
142  EXCEEDED_ITERATIONS
143  };

Constructor & Destructor Documentation

◆ ADSingleVariableReturnMappingSolution()

template<ComputeStage compute_stage>
ADSingleVariableReturnMappingSolution< compute_stage >::ADSingleVariableReturnMappingSolution ( const InputParameters &  parameters)

Definition at line 54 of file ADSingleVariableReturnMappingSolution.C.

56  : _check_range(false),
57  _line_search(true),
58  _bracket_solution(true),
60  parameters.get<MooseEnum>("internal_solve_output_on").getEnum<InternalSolveOutput>()),
61  _max_its(1000), // Far larger than ever expected to be needed
63  parameters.get<bool>("internal_solve_full_iteration_history")),
64  _relative_tolerance(parameters.get<Real>("relative_tolerance")),
65  _absolute_tolerance(parameters.get<Real>("absolute_tolerance")),
66  _acceptable_multiplier(parameters.get<Real>("acceptable_multiplier")),
67  _num_resids(30),
68  _residual_history(_num_resids, std::numeric_limits<Real>::max()),
69  _iteration(0),
70  _initial_residual(0.0),
71  _residual(0.0),
72  _svrms_name(parameters.get<std::string>("_object_name"))
73 {
74 }
ADReal _initial_residual
Residual values, kept as members to retain solver state for summary outputting.
bool _line_search
Whether to use line searches to improve convergence.
Real _absolute_tolerance
Absolute convergence tolerance.
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.
bool _bracket_solution
Whether to save upper and lower bounds of root for scalar, and set solution to the midpoint between t...
std::vector< Real > _residual_history
History of residuals used to check whether progress is still being made on decreasing the residual...
Real _acceptable_multiplier
Multiplier applied to relative and absolute tolerances for acceptable convergence.
bool _check_range
Whether to check to see whether iterative solution is within admissible range, and set within that ra...
enum ADSingleVariableReturnMappingSolution::InternalSolveOutput _internal_solve_output_on
Real _relative_tolerance
Relative convergence tolerance.
const std::size_t _num_resids
Number of residuals to be stored in history.
const bool _internal_solve_full_iteration_history
Whether to output iteration information all the time (regardless of whether iterations converge) ...

◆ ~ADSingleVariableReturnMappingSolution()

template<ComputeStage compute_stage>
virtual ADSingleVariableReturnMappingSolution< compute_stage >::~ADSingleVariableReturnMappingSolution ( )
inlinevirtual

Definition at line 45 of file ADSingleVariableReturnMappingSolution.h.

45 {}

Member Function Documentation

◆ 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
scalarCurrent value of the inelastic strain increment
scalar_incrementIncremental change in scalar from the previous iteration
scalar_oldPrevious value of scalar
min_permissible_scalarMinimum permissible value of scalar
max_permissible_scalarMaximum permissible value of scalar
iter_outputOutput stream

Definition at line 323 of file ADSingleVariableReturnMappingSolution.C.

330 {
331  if (scalar > max_permissible_scalar)
332  {
333  scalar_increment = (max_permissible_scalar - scalar_old) / 2.0;
334  scalar = scalar_old + scalar_increment;
335  if (iter_output)
336  *iter_output << "Scalar greater than maximum (" << max_permissible_scalar
337  << ") adjusted scalar=" << scalar << " scalar_increment=" << scalar_increment
338  << std::endl;
339  }
340  else if (scalar < min_permissible_scalar)
341  {
342  scalar_increment = (min_permissible_scalar - scalar_old) / 2.0;
343  scalar = scalar_old + scalar_increment;
344  if (iter_output)
345  *iter_output << "Scalar less than minimum (" << min_permissible_scalar
346  << ") adjusted scalar=" << scalar << " scalar_increment=" << scalar_increment
347  << std::endl;
348  }
349 }

◆ computeDerivative()

template<ComputeStage compute_stage>
virtual ADReal ADSingleVariableReturnMappingSolution< compute_stage >::computeDerivative ( const ADReal &  effective_trial_stress,
const ADReal &  scalar 
)
protectedpure virtual

Compute the derivative of the residual as a function of the scalar variable.

The residual should be in strain increment units for all models for consistency.

Parameters
effective_trial_stressEffective trial stress
scalarInelastic strain increment magnitude being solved for

Implemented in ADPowerLawCreepStressUpdate< compute_stage >.

◆ computeReferenceResidual()

template<ComputeStage compute_stage>
virtual Real ADSingleVariableReturnMappingSolution< compute_stage >::computeReferenceResidual ( const ADReal &  effective_trial_stress,
const ADReal &  scalar 
)
protectedpure virtual

Compute a reference quantity to be used for checking relative convergence.

This should be in strain increment units for all models for consistency.

Parameters
effective_trial_stressEffective trial stress
scalarInelastic strain increment magnitude being solved for

Implemented in ADRadialReturnStressUpdate< compute_stage >.

◆ computeResidual()

template<ComputeStage compute_stage>
virtual ADReal ADSingleVariableReturnMappingSolution< compute_stage >::computeResidual ( const ADReal &  effective_trial_stress,
const ADReal &  scalar 
)
protectedpure virtual

Compute the residual for a predicted value of the scalar.

This residual should be in strain increment units for all models for consistency.

Parameters
effective_trial_stressEffective trial stress
scalarInelastic strain increment magnitude being solved for

Implemented in ADPowerLawCreepStressUpdate< compute_stage >.

◆ converged()

template<ComputeStage compute_stage>
bool ADSingleVariableReturnMappingSolution< compute_stage >::converged ( const ADReal &  residual,
const Real  reference 
)
private

Check to see whether the residual is within the convergence limits.

Parameters
residualCurrent value of the residual
referenceCurrent value of the reference quantity
Returns
Whether the model converged

Definition at line 290 of file ADSingleVariableReturnMappingSolution.C.

292 {
293  const Real residual = MetaPhysicL::raw_value(ad_residual);
294  return (std::abs(residual) <= _absolute_tolerance ||
295  std::abs(residual / reference) <= _relative_tolerance);
296 }
Real _absolute_tolerance
Absolute convergence tolerance.
Real _relative_tolerance
Relative convergence tolerance.

◆ convergedAcceptable()

template<ComputeStage compute_stage>
bool ADSingleVariableReturnMappingSolution< compute_stage >::convergedAcceptable ( const unsigned int  it,
const Real  reference 
)
private

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
residualCurrent iteration count
residualCurrent value of the residual
referenceCurrent value of the reference quantity
Returns
Whether the model converged

Definition at line 300 of file ADSingleVariableReturnMappingSolution.C.

302 {
303  // Require that we have at least done _num_resids evaluations before we allow for
304  // acceptable convergence
305  if (it < _num_resids)
306  return false;
307 
308  // Check to see whether the residual has dropped by convergence_history_factor over
309  // the last _num_resids iterations. If it has (which means it's still making progress),
310  // don't consider it to be converged within the acceptable limits.
311  const Real convergence_history_factor = 10.0;
312  if (std::abs(_residual * convergence_history_factor) <
313  std::abs(_residual_history[(it + 1) % _num_resids]))
314  return false;
315 
316  // Now that it's determined that progress is not being made, treat it as converged if
317  // we're within the acceptable convergence limits
318  return converged(_residual / _acceptable_multiplier, reference);
319 }
bool converged(const ADReal &residual, const Real reference)
Check to see whether the residual is within the convergence limits.
std::vector< Real > _residual_history
History of residuals used to check whether progress is still being made on decreasing the residual...
Real _acceptable_multiplier
Multiplier applied to relative and absolute tolerances for acceptable convergence.
const std::size_t _num_resids
Number of residuals to be stored in history.

◆ initialGuess()

template<ComputeStage compute_stage>
virtual ADReal ADSingleVariableReturnMappingSolution< compute_stage >::initialGuess ( const ADReal &  )
inlineprotectedvirtual

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_stressEffective trial stress

Definition at line 79 of file ADSingleVariableReturnMappingSolution.h.

79 { return 0.0; }

◆ internalSolve()

template<ComputeStage compute_stage>
ADSingleVariableReturnMappingSolution< compute_stage >::SolveState ADSingleVariableReturnMappingSolution< compute_stage >::internalSolve ( const ADReal  effective_trial_stress,
ADReal &  scalar,
std::stringstream *  iter_output = nullptr 
)
private

Method called from within this class to perform the actual return mappping iterations.

Parameters
effective_trial_stressEffective trial stress
scalarInelastic strain increment magnitude being solved for
iter_outputOutput stream – if null, no output is produced
Returns
Whether the solution was successful

Definition at line 152 of file ADSingleVariableReturnMappingSolution.C.

154 {
155  scalar = initialGuess(effective_trial_stress);
156  ADReal scalar_old = scalar;
157  ADReal scalar_increment = 0.0;
158  const ADReal min_permissible_scalar = minimumPermissibleValue(effective_trial_stress);
159  const ADReal max_permissible_scalar = maximumPermissibleValue(effective_trial_stress);
160  ADReal scalar_upper_bound = max_permissible_scalar;
161  ADReal scalar_lower_bound = min_permissible_scalar;
162  _iteration = 0;
163 
164  _initial_residual = _residual = computeResidual(effective_trial_stress, scalar);
165 
166  ADReal residual_old = _residual;
167  Real init_resid_sign = MathUtils::sign(MetaPhysicL::raw_value(_residual));
168  Real reference_residual = computeReferenceResidual(effective_trial_stress, scalar);
169 
170  if (converged(_residual, reference_residual))
171  {
172  iterationFinalize(scalar);
173  outputIterationStep(iter_output, effective_trial_stress, scalar, reference_residual);
174  return SolveState::SUCCESS;
175  }
176 
177  _residual_history.assign(_num_resids, std::numeric_limits<Real>::max());
178  _residual_history[0] = MetaPhysicL::raw_value(_residual);
179 
180  while (_iteration < _max_its && !converged(_residual, reference_residual) &&
181  !convergedAcceptable(_iteration, reference_residual))
182  {
183  scalar_increment = -_residual / computeDerivative(effective_trial_stress, scalar);
184  scalar = scalar_old + scalar_increment;
185 
186  if (_check_range)
187  checkPermissibleRange(scalar,
188  scalar_increment,
189  scalar_old,
190  min_permissible_scalar,
191  max_permissible_scalar,
192  iter_output);
193 
194  _residual = computeResidual(effective_trial_stress, scalar);
195  reference_residual = computeReferenceResidual(effective_trial_stress, scalar);
196  iterationFinalize(scalar);
197 
198  if (_bracket_solution)
199  updateBounds(
200  scalar, _residual, init_resid_sign, scalar_upper_bound, scalar_lower_bound, iter_output);
201 
202  if (converged(_residual, reference_residual))
203  {
204  outputIterationStep(iter_output, effective_trial_stress, scalar, reference_residual);
205  break;
206  }
207  else
208  {
209  bool modified_increment = false;
210 
211  // Line Search
212  if (_line_search)
213  {
214  if (residual_old - _residual != 0.0)
215  {
216  ADReal alpha = residual_old / (residual_old - _residual);
217  alpha = MathUtils::clamp(alpha, 1.0e-2, 1.0);
218 
219  if (alpha != 1.0)
220  {
221  modified_increment = true;
222  scalar_increment *= alpha;
223  if (iter_output)
224  *iter_output << " Line search alpha = " << alpha
225  << " increment = " << scalar_increment << std::endl;
226  }
227  }
228  }
229 
230  if (_bracket_solution)
231  {
232  // Check to see whether trial scalar_increment is outside the bounds, and set it to a point
233  // within the bounds if it is
234  if (scalar_old + scalar_increment >= scalar_upper_bound ||
235  scalar_old + scalar_increment <= scalar_lower_bound)
236  {
237  if (scalar_upper_bound != max_permissible_scalar &&
238  scalar_lower_bound != min_permissible_scalar)
239  {
240  const Real frac = 0.5;
241  scalar_increment =
242  (1.0 - frac) * scalar_lower_bound + frac * scalar_upper_bound - scalar_old;
243  modified_increment = true;
244  if (iter_output)
245  *iter_output << " Trial scalar_increment exceeded bounds. Setting between "
246  "lower/upper bounds. frac: "
247  << frac << std::endl;
248  }
249  }
250  }
251 
252  // Update the trial scalar and recompute residual if the line search or bounds checking
253  // modified the increment
254  if (modified_increment)
255  {
256  scalar = scalar_old + scalar_increment;
257  _residual = computeResidual(effective_trial_stress, scalar);
258  reference_residual = computeReferenceResidual(effective_trial_stress, scalar);
259  iterationFinalize(scalar);
260 
261  if (_bracket_solution)
262  updateBounds(scalar,
263  _residual,
264  init_resid_sign,
265  scalar_upper_bound,
266  scalar_lower_bound,
267  iter_output);
268  }
269  }
270 
271  outputIterationStep(iter_output, effective_trial_stress, scalar, reference_residual);
272 
273  ++_iteration;
274  residual_old = _residual;
275  scalar_old = scalar;
276  _residual_history[_iteration % _num_resids] = MetaPhysicL::raw_value(_residual);
277  }
278 
279  if (std::isnan(_residual) || std::isinf(MetaPhysicL::raw_value(_residual)))
280  return SolveState::NAN_INF;
281 
282  if (_iteration == _max_its)
284 
285  return SolveState::SUCCESS;
286 }
virtual ADReal initialGuess(const ADReal &)
Compute an initial guess for the value of the scalar.
virtual ADReal maximumPermissibleValue(const ADReal &effective_trial_stress) const
Compute the maximum permissible value of the scalar.
virtual ADReal minimumPermissibleValue(const ADReal &effective_trial_stress) const
Compute the minimum permissible value of the scalar.
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.
ADReal _initial_residual
Residual values, kept as members to retain solver state for summary outputting.
virtual ADReal computeResidual(const ADReal &effective_trial_stress, const ADReal &scalar)=0
Compute the residual for a predicted value of the scalar.
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...
bool _line_search
Whether to use line searches to improve convergence.
bool converged(const ADReal &residual, const Real reference)
Check to see whether the residual is within the convergence limits.
const unsigned int _max_its
Maximum number of return mapping iterations.
virtual void iterationFinalize(ADReal)
Finalize internal state variables for a model for a given iteration.
virtual Real computeReferenceResidual(const ADReal &effective_trial_stress, const ADReal &scalar)=0
Compute a reference quantity to be used for checking relative convergence.
bool _bracket_solution
Whether to save upper and lower bounds of root for scalar, and set solution to the midpoint between t...
std::vector< Real > _residual_history
History of residuals used to check whether progress is still being made on decreasing the residual...
bool _check_range
Whether to check to see whether iterative solution is within admissible range, and set within that ra...
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 std::size_t _num_resids
Number of residuals to be stored in history.
bool convergedAcceptable(const unsigned int it, const Real reference)
Check to see whether the residual is within acceptable convergence limits.
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...

◆ iterationFinalize()

template<ComputeStage compute_stage>
virtual void ADSingleVariableReturnMappingSolution< compute_stage >::iterationFinalize ( ADReal  )
inlineprotectedvirtual

Finalize internal state variables for a model for a given iteration.

Parameters
scalarInelastic strain increment magnitude being solved for

Definition at line 111 of file ADSingleVariableReturnMappingSolution.h.

111 {}

◆ maximumPermissibleValue()

template<ComputeStage compute_stage>
ADReal ADSingleVariableReturnMappingSolution< compute_stage >::maximumPermissibleValue ( const ADReal &  effective_trial_stress) const
protectedvirtual

Compute the maximum permissible value of the scalar.

For some models, the magnitude of this may be known.

Parameters
effective_trial_stressEffective trial stress

Reimplemented in ADRadialReturnStressUpdate< compute_stage >.

Definition at line 86 of file ADSingleVariableReturnMappingSolution.C.

88 {
89  return std::numeric_limits<Real>::max();
90 }

◆ minimumPermissibleValue()

template<ComputeStage compute_stage>
ADReal ADSingleVariableReturnMappingSolution< compute_stage >::minimumPermissibleValue ( const ADReal &  effective_trial_stress) const
protectedvirtual

Compute the minimum permissible value of the scalar.

For some models, the magnitude of this may be known.

Parameters
effective_trial_stressEffective trial stress

Reimplemented in ADRadialReturnStressUpdate< compute_stage >.

Definition at line 78 of file ADSingleVariableReturnMappingSolution.C.

80 {
81  return std::numeric_limits<Real>::lowest();
82 }

◆ 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 
)
privatevirtual

Output information for a single iteration step to build the convergence history of the model.

Parameters
iter_outputOutput stream
itCurrent iteration count
effective_trial_stressEffective trial stress
scalarInelastic strain increment magnitude being solved for
residualCurrent value of the residual
referenceCurrent value of the reference quantity

Definition at line 381 of file ADSingleVariableReturnMappingSolution.C.

386 {
387  if (iter_output)
388  {
389  const unsigned int it = _iteration;
390  const Real residual = MetaPhysicL::raw_value(_residual);
391 
392  *iter_output << " iteration=" << it
393  << " trial_stress=" << MetaPhysicL::raw_value(effective_trial_stress)
394  << " scalar=" << MetaPhysicL::raw_value(scalar) << " residual=" << residual
395  << " ref_res=" << reference_residual
396  << " rel_res=" << std::abs(MetaPhysicL::raw_value(residual)) / reference_residual
397  << " rel_tol=" << _relative_tolerance << " abs_res=" << std::abs(residual)
398  << " abs_tol=" << _absolute_tolerance << '\n';
399  }
400 }
Real _absolute_tolerance
Absolute convergence tolerance.
Real _relative_tolerance
Relative convergence tolerance.

◆ outputIterationSummary()

template<ComputeStage compute_stage>
void ADSingleVariableReturnMappingSolution< compute_stage >::outputIterationSummary ( std::stringstream *  iter_output,
const unsigned int  total_it 
)
protectedvirtual

Output summary information for the convergence history of the model.

Parameters
iter_outputOutput stream
total_itTotal iteration count

Reimplemented in ADRadialReturnStressUpdate< compute_stage >.

Definition at line 404 of file ADSingleVariableReturnMappingSolution.C.

Referenced by ADRadialReturnStressUpdate< compute_stage >::outputIterationSummary().

406 {
407  if (iter_output)
408  *iter_output << "In " << total_it << " iterations the residual went from " << _initial_residual
409  << " to " << _residual << " in '" << _svrms_name << "'.\n";
410 }
ADReal _initial_residual
Residual values, kept as members to retain solver state for summary outputting.
const std::string _svrms_name
MOOSE input name of the object performing the solve.

◆ returnMappingSolve()

template<ComputeStage compute_stage>
void ADSingleVariableReturnMappingSolution< compute_stage >::returnMappingSolve ( const ADReal &  effective_trial_stress,
ADReal &  scalar,
const ConsoleStream &  console 
)
protected

Perform the return mapping iterations.

Parameters
effective_trial_stressEffective trial stress
scalarInelastic strain increment magnitude being solved for
consoleConsole output

Definition at line 94 of file ADSingleVariableReturnMappingSolution.C.

96 {
97  // construct the stringstream here only if the debug level is set to ALL
98  std::stringstream * iter_output =
99  (_internal_solve_output_on == InternalSolveOutput::ALWAYS) ? new std::stringstream : nullptr;
100 
101  // do the internal solve and capture iteration info during the first round
102  // iff full history output is requested regardless of whether the solve failed or succeeded
103  auto solve_state = internalSolve(effective_trial_stress,
104  scalar,
105  _internal_solve_full_iteration_history ? iter_output : nullptr);
106  if (solve_state != SolveState::SUCCESS &&
108  {
109  // output suppressed by user, throw immediately
111  throw MooseException("");
112 
113  // user expects some kind of output, if necessary setup output stream now
114  if (!iter_output)
115  iter_output = new std::stringstream;
116 
117  // add the appropriate error message to the output
118  switch (solve_state)
119  {
120  case SolveState::NAN_INF:
121  *iter_output << "Encountered inf or nan in material return mapping iterations.\n";
122  break;
123 
125  *iter_output << "Exceeded maximum iterations in material return mapping iterations.\n";
126  break;
127 
128  default:
129  mooseError("Unhandled solver state");
130  }
131 
132  // if full history output is only requested for failed solves we have to repeat
133  // the solve a second time
135  internalSolve(effective_trial_stress, scalar, iter_output);
136 
137  // Append summary and throw exception
138  outputIterationSummary(iter_output, _iteration);
139  throw MooseException(iter_output->str());
140  }
141 
143  {
144  // the solve did not fail but the user requested debug output anyways
145  outputIterationSummary(iter_output, _iteration);
146  console << iter_output->str();
147  }
148 }
virtual void outputIterationSummary(std::stringstream *iter_output, const unsigned int total_it)
Output summary information for the convergence history of the model.
enum ADSingleVariableReturnMappingSolution::InternalSolveOutput _internal_solve_output_on
const bool _internal_solve_full_iteration_history
Whether to output iteration information all the time (regardless of whether iterations converge) ...
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.

◆ 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
scalarCurrent value of the inelastic strain increment
residualCurrent value of the residual
init_resid_signSign of the initial value of the residual
scalar_upper_boundUpper bound value of scalar
scalar_lower_boundLower bound value of scalar
iter_outputOutput stream

Definition at line 353 of file ADSingleVariableReturnMappingSolution.C.

359 {
360  // Update upper/lower bounds as applicable
361  if (residual * init_resid_sign < 0.0 && scalar < scalar_upper_bound)
362  {
363  scalar_upper_bound = MetaPhysicL::raw_value(scalar);
364  if (scalar_upper_bound < scalar_lower_bound)
365  {
366  scalar_upper_bound = scalar_lower_bound;
367  scalar_lower_bound = 0.0;
368  if (iter_output)
369  *iter_output << " Corrected for scalar_upper_bound < scalar_lower_bound" << std::endl;
370  }
371  }
372  // Don't permit setting scalar_lower_bound > scalar_upper_bound (but do permit the reverse).
373  // This ensures that if we encounter multiple roots, we pick the lowest one.
374  else if (residual * init_resid_sign > 0.0 && scalar > scalar_lower_bound &&
375  scalar < scalar_upper_bound)
376  scalar_lower_bound = MetaPhysicL::raw_value(scalar);
377 }

Member Data Documentation

◆ _absolute_tolerance

template<ComputeStage compute_stage>
Real ADSingleVariableReturnMappingSolution< compute_stage >::_absolute_tolerance
private

Absolute convergence tolerance.

Definition at line 156 of file ADSingleVariableReturnMappingSolution.h.

◆ _acceptable_multiplier

template<ComputeStage compute_stage>
Real ADSingleVariableReturnMappingSolution< compute_stage >::_acceptable_multiplier
private

Multiplier applied to relative and absolute tolerances for acceptable convergence.

Definition at line 159 of file ADSingleVariableReturnMappingSolution.h.

◆ _bracket_solution

template<ComputeStage compute_stage>
bool ADSingleVariableReturnMappingSolution< compute_stage >::_bracket_solution
protected

Whether to save upper and lower bounds of root for scalar, and set solution to the midpoint between those bounds if outside them.

Definition at line 128 of file ADSingleVariableReturnMappingSolution.h.

◆ _check_range

template<ComputeStage compute_stage>
bool ADSingleVariableReturnMappingSolution< compute_stage >::_check_range
protected

Whether to check to see whether iterative solution is within admissible range, and set within that range if outside.

Definition at line 121 of file ADSingleVariableReturnMappingSolution.h.

◆ _initial_residual

template<ComputeStage compute_stage>
ADReal ADSingleVariableReturnMappingSolution< compute_stage >::_initial_residual
private

Residual values, kept as members to retain solver state for summary outputting.

Definition at line 171 of file ADSingleVariableReturnMappingSolution.h.

◆ _internal_solve_full_iteration_history

template<ComputeStage compute_stage>
const bool ADSingleVariableReturnMappingSolution< compute_stage >::_internal_solve_full_iteration_history
private

Whether to output iteration information all the time (regardless of whether iterations converge)

Definition at line 150 of file ADSingleVariableReturnMappingSolution.h.

◆ _internal_solve_output_on

template<ComputeStage compute_stage>
enum ADSingleVariableReturnMappingSolution::InternalSolveOutput ADSingleVariableReturnMappingSolution< compute_stage >::_internal_solve_output_on
private

◆ _iteration

template<ComputeStage compute_stage>
unsigned int ADSingleVariableReturnMappingSolution< compute_stage >::_iteration
private

iteration number

Definition at line 168 of file ADSingleVariableReturnMappingSolution.h.

◆ _line_search

template<ComputeStage compute_stage>
bool ADSingleVariableReturnMappingSolution< compute_stage >::_line_search
protected

Whether to use line searches to improve convergence.

Definition at line 124 of file ADSingleVariableReturnMappingSolution.h.

◆ _max_its

template<ComputeStage compute_stage>
const unsigned int ADSingleVariableReturnMappingSolution< compute_stage >::_max_its
private

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 147 of file ADSingleVariableReturnMappingSolution.h.

◆ _num_resids

template<ComputeStage compute_stage>
const std::size_t ADSingleVariableReturnMappingSolution< compute_stage >::_num_resids
private

Number of residuals to be stored in history.

Definition at line 162 of file ADSingleVariableReturnMappingSolution.h.

◆ _relative_tolerance

template<ComputeStage compute_stage>
Real ADSingleVariableReturnMappingSolution< compute_stage >::_relative_tolerance
private

Relative convergence tolerance.

Definition at line 153 of file ADSingleVariableReturnMappingSolution.h.

◆ _residual

template<ComputeStage compute_stage>
ADReal ADSingleVariableReturnMappingSolution< compute_stage >::_residual
private

Definition at line 172 of file ADSingleVariableReturnMappingSolution.h.

◆ _residual_history

template<ComputeStage compute_stage>
std::vector<Real> ADSingleVariableReturnMappingSolution< compute_stage >::_residual_history
private

History of residuals used to check whether progress is still being made on decreasing the residual.

Definition at line 165 of file ADSingleVariableReturnMappingSolution.h.

◆ _svrms_name

template<ComputeStage compute_stage>
const std::string ADSingleVariableReturnMappingSolution< compute_stage >::_svrms_name
private

MOOSE input name of the object performing the solve.

Definition at line 176 of file ADSingleVariableReturnMappingSolution.h.


The documentation for this class was generated from the following files: