www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
SingleVariableReturnMappingSolution Class Referenceabstract

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

#include <SingleVariableReturnMappingSolution.h>

Inheritance diagram for SingleVariableReturnMappingSolution:
[legend]

Public Member Functions

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

Protected Member Functions

void returnMappingSolve (const Real effective_trial_stress, Real &scalar, const ConsoleStream &console)
 Perform the return mapping iterations. More...
 
virtual Real minimumPermissibleValue (const Real effective_trial_stress) const
 Compute the minimum permissible value of the scalar. More...
 
virtual Real maximumPermissibleValue (const Real effective_trial_stress) const
 Compute the maximum permissible value of the scalar. More...
 
virtual Real initialGuess (const Real)
 Compute an initial guess for the value of the scalar. More...
 
virtual Real computeResidual (const Real effective_trial_stress, const Real scalar)=0
 Compute the residual for a predicted value of the scalar. More...
 
virtual Real computeDerivative (const Real effective_trial_stress, const Real scalar)=0
 Compute the derivative of the residual as a function of the scalar variable. More...
 
virtual Real computeReferenceResidual (const Real effective_trial_stress, const Real scalar)=0
 Compute a reference quantity to be used for checking relative convergence. More...
 
virtual void iterationFinalize (Real)
 Finalize internal state variables for a model for a given iteration. More...
 
virtual void outputIterationStep (std::stringstream *iter_output, const unsigned int it, const Real effective_trial_stress, const Real scalar, const Real residual, const Real reference_residual)
 Output information for a single iteration step to build the convergence history of the model. 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 Real effective_trial_stress, Real &scalar, std::stringstream *iter_output=nullptr)
 Method called from within this class to perform the actual return mappping iterations. More...
 
bool converged (const Real residual, const Real reference)
 Check to see whether the residual is within the convergence limits. More...
 
bool convergedAcceptable (const unsigned int it, const Real residual, const Real reference)
 Check to see whether the residual is within acceptable convergence limits. More...
 
void checkPermissibleRange (Real &scalar, Real &scalar_increment, const Real scalar_old, const Real min_permissible_scalar, const Real 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 Real scalar, const Real residual, const Real init_resid_sign, Real &scalar_upper_bound, Real &scalar_lower_bound, std::stringstream *iter_output)
 Update the upper and lower bounds of the root for the effective inelastic strain. More...
 

Private Attributes

enum SingleVariableReturnMappingSolution::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...
 
Real _initial_residual
 Residual values, kept as members to retain solver state for summary outputting. More...
 
Real _residual
 

Detailed Description

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

Definition at line 25 of file SingleVariableReturnMappingSolution.h.

Member Enumeration Documentation

◆ InternalSolveOutput

Enumerator
NEVER 
ON_ERROR 
ALWAYS 

Definition at line 129 of file SingleVariableReturnMappingSolution.h.

130  {
131  NEVER,
132  ON_ERROR,
133  ALWAYS
enum SingleVariableReturnMappingSolution::InternalSolveOutput _internal_solve_output_on

◆ SolveState

Enumerator
SUCCESS 
NAN_INF 
EXCEEDED_ITERATIONS 

Definition at line 136 of file SingleVariableReturnMappingSolution.h.

137  {
138  SUCCESS,
139  NAN_INF,
140  EXCEEDED_ITERATIONS
141  };

Constructor & Destructor Documentation

◆ SingleVariableReturnMappingSolution()

SingleVariableReturnMappingSolution::SingleVariableReturnMappingSolution ( const InputParameters &  parameters)

Definition at line 54 of file SingleVariableReturnMappingSolution.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 }
const unsigned int _max_its
Maximum number of return mapping iterations.
Real _acceptable_multiplier
Multiplier applied to relative and absolute tolerances for acceptable convergence.
enum SingleVariableReturnMappingSolution::InternalSolveOutput _internal_solve_output_on
const std::string _svrms_name
MOOSE input name of the object performing the solve.
const bool _internal_solve_full_iteration_history
Whether to output iteration information all the time (regardless of whether iterations converge) ...
bool _line_search
Whether to use line searches to improve convergence.
std::vector< Real > _residual_history
History of residuals used to check whether progress is still being made on decreasing the residual...
Real _relative_tolerance
Relative convergence tolerance.
const std::size_t _num_resids
Number of residuals to be stored in history.
bool _check_range
Whether to check to see whether iterative solution is within admissible range, and set within that ra...
Real _absolute_tolerance
Absolute convergence tolerance.
Real _initial_residual
Residual values, kept as members to retain solver state for summary outputting.
bool _bracket_solution
Whether to save upper and lower bounds of root for scalar, and set solution to the midpoint between t...

◆ ~SingleVariableReturnMappingSolution()

virtual SingleVariableReturnMappingSolution::~SingleVariableReturnMappingSolution ( )
inlinevirtual

Definition at line 29 of file SingleVariableReturnMappingSolution.h.

29 {}

Member Function Documentation

◆ checkPermissibleRange()

void SingleVariableReturnMappingSolution::checkPermissibleRange ( Real &  scalar,
Real &  scalar_increment,
const Real  scalar_old,
const Real  min_permissible_scalar,
const Real  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 355 of file SingleVariableReturnMappingSolution.C.

Referenced by internalSolve().

361 {
362  if (scalar > max_permissible_scalar)
363  {
364  scalar_increment = (max_permissible_scalar - scalar_old) / 2.0;
365  scalar = scalar_old + scalar_increment;
366  if (iter_output)
367  *iter_output << "Scalar greater than maximum (" << max_permissible_scalar
368  << ") adjusted scalar=" << scalar << " scalar_increment=" << scalar_increment
369  << std::endl;
370  }
371  else if (scalar < min_permissible_scalar)
372  {
373  scalar_increment = (min_permissible_scalar - scalar_old) / 2.0;
374  scalar = scalar_old + scalar_increment;
375  if (iter_output)
376  *iter_output << "Scalar less than minimum (" << min_permissible_scalar
377  << ") adjusted scalar=" << scalar << " scalar_increment=" << scalar_increment
378  << std::endl;
379  }
380 }

◆ computeDerivative()

virtual Real SingleVariableReturnMappingSolution::computeDerivative ( const Real  effective_trial_stress,
const Real  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 IsotropicPlasticityStressUpdate, PowerLawCreepStressUpdate, IsotropicPlasticity, CLSHPlasticModel, and PowerLawCreepModel.

Referenced by RadialReturnCreepStressUpdateBase::computeStressDerivative(), and internalSolve().

◆ computeReferenceResidual()

virtual Real SingleVariableReturnMappingSolution::computeReferenceResidual ( const Real  effective_trial_stress,
const Real  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 RadialReturnStressUpdate, and ReturnMappingModel.

Referenced by internalSolve().

◆ computeResidual()

virtual Real SingleVariableReturnMappingSolution::computeResidual ( const Real  effective_trial_stress,
const Real  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 IsotropicPlasticityStressUpdate, PowerLawCreepStressUpdate, IsotropicPlasticity, CLSHPlasticModel, and PowerLawCreepModel.

Referenced by internalSolve().

◆ converged()

bool SingleVariableReturnMappingSolution::converged ( const Real  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 297 of file SingleVariableReturnMappingSolution.C.

Referenced by convergedAcceptable(), and internalSolve().

298 {
299  return (std::abs(residual) <= _absolute_tolerance ||
300  std::abs(residual / reference) <= _relative_tolerance);
301 }
Real _relative_tolerance
Relative convergence tolerance.
Real _absolute_tolerance
Absolute convergence tolerance.

◆ convergedAcceptable()

bool SingleVariableReturnMappingSolution::convergedAcceptable ( const unsigned int  it,
const Real  residual,
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 304 of file SingleVariableReturnMappingSolution.C.

Referenced by internalSolve().

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

◆ initialGuess()

virtual Real SingleVariableReturnMappingSolution::initialGuess ( const Real  )
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 63 of file SingleVariableReturnMappingSolution.h.

Referenced by internalSolve().

63 { return 0.0; }

◆ internalSolve()

SingleVariableReturnMappingSolution::SolveState SingleVariableReturnMappingSolution::internalSolve ( const Real  effective_trial_stress,
Real &  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 149 of file SingleVariableReturnMappingSolution.C.

Referenced by returnMappingSolve().

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

◆ iterationFinalize()

virtual void SingleVariableReturnMappingSolution::iterationFinalize ( Real  )
inlineprotectedvirtual

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

Parameters
scalarInelastic strain increment magnitude being solved for

Reimplemented in IsotropicPlasticityStressUpdate, IsotropicPlasticity, and CLSHPlasticModel.

Definition at line 93 of file SingleVariableReturnMappingSolution.h.

Referenced by internalSolve().

93 {}

◆ maximumPermissibleValue()

Real SingleVariableReturnMappingSolution::maximumPermissibleValue ( const Real  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 RadialReturnStressUpdate.

Definition at line 84 of file SingleVariableReturnMappingSolution.C.

Referenced by internalSolve().

86 {
87  return std::numeric_limits<Real>::max();
88 }

◆ minimumPermissibleValue()

Real SingleVariableReturnMappingSolution::minimumPermissibleValue ( const Real  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 ReturnMappingModel, and RadialReturnStressUpdate.

Definition at line 77 of file SingleVariableReturnMappingSolution.C.

Referenced by internalSolve().

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

◆ outputIterationStep()

void SingleVariableReturnMappingSolution::outputIterationStep ( std::stringstream *  iter_output,
const unsigned int  it,
const Real  effective_trial_stress,
const Real  scalar,
const Real  residual,
const Real  reference_residual 
)
protectedvirtual

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 327 of file SingleVariableReturnMappingSolution.C.

Referenced by internalSolve().

333 {
334  if (iter_output)
335  {
336  *iter_output << " iteration=" << it << " trial_stress=" << effective_trial_stress
337  << " scalar=" << scalar << " residual=" << residual
338  << " ref_res=" << reference_residual
339  << " rel_res=" << std::abs(residual) / reference_residual
340  << " rel_tol=" << _relative_tolerance << " abs_res=" << std::abs(residual)
341  << " abs_tol=" << _absolute_tolerance << '\n';
342  }
343 }
Real _relative_tolerance
Relative convergence tolerance.
Real _absolute_tolerance
Absolute convergence tolerance.

◆ outputIterationSummary()

void SingleVariableReturnMappingSolution::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 RadialReturnStressUpdate, and ReturnMappingModel.

Definition at line 346 of file SingleVariableReturnMappingSolution.C.

Referenced by ReturnMappingModel::outputIterationSummary(), RadialReturnStressUpdate::outputIterationSummary(), and returnMappingSolve().

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

◆ returnMappingSolve()

void SingleVariableReturnMappingSolution::returnMappingSolve ( const Real  effective_trial_stress,
Real &  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 91 of file SingleVariableReturnMappingSolution.C.

Referenced by ReturnMappingModel::computeStress(), and RadialReturnStressUpdate::updateState().

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

◆ updateBounds()

void SingleVariableReturnMappingSolution::updateBounds ( const Real  scalar,
const Real  residual,
const Real  init_resid_sign,
Real &  scalar_upper_bound,
Real &  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 383 of file SingleVariableReturnMappingSolution.C.

Referenced by internalSolve().

389 {
390  // Update upper/lower bounds as applicable
391  if (residual * init_resid_sign < 0.0 && scalar < scalar_upper_bound)
392  {
393  scalar_upper_bound = scalar;
394  if (scalar_upper_bound < scalar_lower_bound)
395  {
396  scalar_upper_bound = scalar_lower_bound;
397  scalar_lower_bound = 0.0;
398  if (iter_output)
399  *iter_output << " Corrected for scalar_upper_bound < scalar_lower_bound" << std::endl;
400  }
401  }
402  // Don't permit setting scalar_lower_bound > scalar_upper_bound (but do permit the reverse).
403  // This ensures that if we encounter multiple roots, we pick the lowest one.
404  else if (residual * init_resid_sign > 0.0 && scalar > scalar_lower_bound &&
405  scalar < scalar_upper_bound)
406  scalar_lower_bound = scalar;
407 }

Member Data Documentation

◆ _absolute_tolerance

Real SingleVariableReturnMappingSolution::_absolute_tolerance
private

Absolute convergence tolerance.

Definition at line 154 of file SingleVariableReturnMappingSolution.h.

Referenced by converged(), and outputIterationStep().

◆ _acceptable_multiplier

Real SingleVariableReturnMappingSolution::_acceptable_multiplier
private

Multiplier applied to relative and absolute tolerances for acceptable convergence.

Definition at line 157 of file SingleVariableReturnMappingSolution.h.

Referenced by convergedAcceptable().

◆ _bracket_solution

bool SingleVariableReturnMappingSolution::_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 126 of file SingleVariableReturnMappingSolution.h.

Referenced by internalSolve().

◆ _check_range

bool SingleVariableReturnMappingSolution::_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 119 of file SingleVariableReturnMappingSolution.h.

Referenced by internalSolve().

◆ _initial_residual

Real SingleVariableReturnMappingSolution::_initial_residual
private

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

Definition at line 169 of file SingleVariableReturnMappingSolution.h.

Referenced by internalSolve(), and outputIterationSummary().

◆ _internal_solve_full_iteration_history

const bool SingleVariableReturnMappingSolution::_internal_solve_full_iteration_history
private

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

Definition at line 148 of file SingleVariableReturnMappingSolution.h.

Referenced by returnMappingSolve().

◆ _internal_solve_output_on

enum SingleVariableReturnMappingSolution::InternalSolveOutput SingleVariableReturnMappingSolution::_internal_solve_output_on
private

Referenced by returnMappingSolve().

◆ _iteration

unsigned int SingleVariableReturnMappingSolution::_iteration
private

iteration number

Definition at line 166 of file SingleVariableReturnMappingSolution.h.

Referenced by internalSolve(), and returnMappingSolve().

◆ _line_search

bool SingleVariableReturnMappingSolution::_line_search
protected

Whether to use line searches to improve convergence.

Definition at line 122 of file SingleVariableReturnMappingSolution.h.

Referenced by internalSolve().

◆ _max_its

const unsigned int SingleVariableReturnMappingSolution::_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 145 of file SingleVariableReturnMappingSolution.h.

Referenced by internalSolve().

◆ _num_resids

const std::size_t SingleVariableReturnMappingSolution::_num_resids
private

Number of residuals to be stored in history.

Definition at line 160 of file SingleVariableReturnMappingSolution.h.

Referenced by convergedAcceptable(), and internalSolve().

◆ _relative_tolerance

Real SingleVariableReturnMappingSolution::_relative_tolerance
private

Relative convergence tolerance.

Definition at line 151 of file SingleVariableReturnMappingSolution.h.

Referenced by converged(), and outputIterationStep().

◆ _residual

Real SingleVariableReturnMappingSolution::_residual
private

Definition at line 170 of file SingleVariableReturnMappingSolution.h.

Referenced by internalSolve(), and outputIterationSummary().

◆ _residual_history

std::vector<Real> SingleVariableReturnMappingSolution::_residual_history
private

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

Definition at line 163 of file SingleVariableReturnMappingSolution.h.

Referenced by convergedAcceptable(), and internalSolve().

◆ _svrms_name

const std::string SingleVariableReturnMappingSolution::_svrms_name
private

MOOSE input name of the object performing the solve.

Definition at line 174 of file SingleVariableReturnMappingSolution.h.

Referenced by outputIterationSummary().


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