# Reference Residual Problem

Problem that checks for convergence relative to a user-supplied reference quantity rather than the initial residual

## Description

By default, MOOSE checks convergence using relative and absolute criteria. Once the residual drops below either an absolute tolerance, or the residual divided by the initial residual for the current time step drops below a relative tolerance, the solution is considered converged. This works well for many problems, but in cases where the solution changes minimally between time steps, the initial residual can be very small, making the relative convergence check much too stringent.

The ReferenceResidualProblem checks for convergence by comparing the residual to a different reference quantity (instead of the initial residual). The the user supplies a reference quantity in the form of a set of AuxVariables that contain physically meaningful quantities that can be used in a relative convergence check. Because the solution variables can have significantly different scaling, the convergence check performed in ReferenceResidualProblem checks convergence of the solution variables individually. When the norm of the residual for each solution variable is less than either the relative tolerance times the norm of the corresponding reference variable or the absolute tolerance, the solution is considered converged.

For some cases, it is more appropriate to group several variables together to check convergence of their grouped solution rather than checking the convergence of the variables individually. For example, in 2D and 3D mechanics solutions, there are multiple displacement variables, and because they have similar physical meaning, it often makes sense to treat them as one vector, which helps avoid issues that may be encountered if the model configuration is such that the reactions in one direction are much lower than in other directions.

When variables are grouped together, the norm of the grouped residual for those variables is used to check convergence. The optional parameter group_variables is used to provide one or more lists of variable names which are to be grouped together.

Use of this procedure requires that the user provide physically meaningful reference quantities. The vector of the reaction loads (in the case of mechanics) or integrated fluxes (in the case of diffusion problems) is typically suitable for this purpose, as it provides a measure of the loading applied to the system. To compute these, an AuxVariable must be set up corresponding to each solution variable, and the save_in option is used in each Kernel to assemble the residual into that vector. When the solution is converged, that AuxVariable will contain values that are close to zero everywhere except for where boundary conditions are applied.

Since relative convergence is computed differently with this approach, the nonlinear relative tolerance required to achieve the same error is typically different than with the default approach in MOOSE, and the differences will vary by the problem. The code user must evaluate the behavior of their model to ensure that appropriate tolerances are being used.

## Example Input syntax

[Problem]
type = ReferenceResidualProblem
solution_variables = 'disp_x disp_y disp_z temp'
reference_residual_variables = 'saved_x saved_y saved_z saved_t'
[]

(modules/combined/test/tests/reference_residual/reference_residual.i)

where additional AuxVariables for the displacements (e.g. x, y, and z) and temperature must be created, as shown below

[AuxVariables]
[./saved_x]
[../]
[./saved_y]
[../]
[./saved_z]
[../]
[./saved_t]
[../]
[]

(modules/combined/test/tests/reference_residual/reference_residual.i)

and then called in the respective kernels. For the displacement reference residual saved variables, the option save_in is set in the Tensor Mechanics Action

[Modules/TensorMechanics/Master]
[./all]
volumetric_locking_correction = true
incremental = true
save_in = 'saved_x saved_y saved_z'
eigenstrain_names = thermal_expansion
strain = FINITE
decomposition_method = EigenSolution
[../]
[]

(modules/combined/test/tests/reference_residual/reference_residual.i)

and the temperature saved variable is applied in the heat conduction kernel

[Kernels]
[./heat]
type = HeatConduction
variable = temp
save_in = saved_t
[../]
[]

(modules/combined/test/tests/reference_residual/reference_residual.i)

## Example Input syntax to group variables

[Problem]
type = ReferenceResidualProblem
solution_variables = 'disp_x disp_y scalar_strain_zz1 scalar_strain_zz2'
reference_residual_variables = 'saved_x saved_y saved_scalar_strain_zz1 saved_scalar_strain_zz2'
group_variables = 'disp_x disp_y;
scalar_strain_zz1 scalar_strain_zz2'
[]

(modules/combined/test/tests/reference_residual/group_variables.i)

Multiple groupings of variables can be provided in group_variables by separating them by semicolon. Convergence for those variables that are not given in group_variables is checked individually. A given variable can only be included in one group.

## Input Parameters

• material_coverage_checkTrueSet to false to disable material->subdomain coverage check

Default:True

C++ Type:bool

Options:

Description:Set to false to disable material->subdomain coverage check

• error_on_jacobian_nonzero_reallocationFalseThis causes PETSc to error if it had to reallocate memory in the Jacobian matrix due to not having enough nonzeros

Default:False

C++ Type:bool

Options:

Description:This causes PETSc to error if it had to reallocate memory in the Jacobian matrix due to not having enough nonzeros

• restart_file_baseFile base name used for restart (e.g. / or /LATEST to grab the latest file available)

C++ Type:FileNameNoExtension

Options:

Description:File base name used for restart (e.g. / or /LATEST to grab the latest file available)

• null_space_dimension0The dimension of the nullspace

Default:0

C++ Type:unsigned int

Options:

Description:The dimension of the nullspace

• acceptable_multiplier1Multiplier applied to relative tolerance for acceptable limit

Default:1

C++ Type:double

Options:

Description:Multiplier applied to relative tolerance for acceptable limit

• use_nonlinearTrueDetermines whether to use a Nonlinear vs a Eigenvalue system (Automatically determined based on executioner)

Default:True

C++ Type:bool

Options:

Description:Determines whether to use a Nonlinear vs a Eigenvalue system (Automatically determined based on executioner)

• force_restartFalseEXPERIMENTAL: If true, a sub_app may use a restart file instead of using of using the master backup file

Default:False

C++ Type:bool

Options:

Description:EXPERIMENTAL: If true, a sub_app may use a restart file instead of using of using the master backup file

• extra_tag_vectorsExtra vectors to add to the system that can be filled by objects which compute residuals and Jacobians (Kernels, BCs, etc.) by setting tags on them.

C++ Type:std::vector

Options:

Description:Extra vectors to add to the system that can be filled by objects which compute residuals and Jacobians (Kernels, BCs, etc.) by setting tags on them.

• ignore_zeros_in_jacobianFalseDo not explicitly store zero values in the Jacobian matrix if true

Default:False

C++ Type:bool

Options:

Description:Do not explicitly store zero values in the Jacobian matrix if true

• skip_nl_system_checkFalseTrue to skip the NonlinearSystem check for work to do (e.g. Make sure that there are variables to solve for).

Default:False

C++ Type:bool

Options:

Description:True to skip the NonlinearSystem check for work to do (e.g. Make sure that there are variables to solve for).

• parallel_barrier_messagingTrueDisplays messaging from parallel barrier notifications when executing or transferring to/from Multiapps (default: true)

Default:True

C++ Type:bool

Options:

Description:Displays messaging from parallel barrier notifications when executing or transferring to/from Multiapps (default: true)

• transpose_null_space_dimension0The dimension of the transpose nullspace

Default:0

C++ Type:unsigned int

Options:

Description:The dimension of the transpose nullspace

• near_null_space_dimension0The dimension of the near nullspace

Default:0

C++ Type:unsigned int

Options:

Description:The dimension of the near nullspace

• group_variablesName of variables that are grouped together to check convergence. (Multiple groups can be provided, separated by semicolon)

C++ Type:std::vector>

Options:

Description:Name of variables that are grouped together to check convergence. (Multiple groups can be provided, separated by semicolon)

• acceptable_iterations0Iterations after which convergence to acceptable limits is accepted

Default:0

C++ Type:int

Options:

Description:Iterations after which convergence to acceptable limits is accepted

• rz_coord_axisYThe rotation axis (X | Y) for axisymetric coordinates

Default:Y

C++ Type:MooseEnum

Options:X Y

Description:The rotation axis (X | Y) for axisymetric coordinates

• skip_additional_restart_dataFalseTrue to skip additional data in equation system for restart. It is useful for starting a transient calculation with a steady-state solution

Default:False

C++ Type:bool

Options:

Description:True to skip additional data in equation system for restart. It is useful for starting a transient calculation with a steady-state solution

• coord_typeXYZType of the coordinate system per block param

Default:XYZ

C++ Type:MultiMooseEnum

Options:XYZ RZ RSPHERICAL

Description:Type of the coordinate system per block param

• solution_variablesSet of solution variables to be checked for relative convergence

C++ Type:std::vector

Options:

Description:Set of solution variables to be checked for relative convergence

• kernel_coverage_checkTrueSet to false to disable kernel->subdomain coverage check

Default:True

C++ Type:bool

Options:

Description:Set to false to disable kernel->subdomain coverage check

• reference_residual_variablesSet of variables that provide reference residuals for relative convergence check

C++ Type:std::vector

Options:

Description:Set of variables that provide reference residuals for relative convergence check

• solveTrueWhether or not to actually solve the Nonlinear system. This is handy in the case that all you want to do is execute AuxKernels, Transfers, etc. without actually solving anything

Default:True

C++ Type:bool

Options:

Description:Whether or not to actually solve the Nonlinear system. This is handy in the case that all you want to do is execute AuxKernels, Transfers, etc. without actually solving anything

• extra_tag_matricesExtra matrices to add to the system that can be filled by objects which compute residuals and Jacobians (Kernels, BCs, etc.) by setting tags on them.

C++ Type:std::vector

Options:

Description:Extra matrices to add to the system that can be filled by objects which compute residuals and Jacobians (Kernels, BCs, etc.) by setting tags on them.

• blockBlock IDs for the coordinate systems

C++ Type:std::vector

Options:

Description:Block IDs for the coordinate systems

### Optional Parameters

• control_tagsAdds user-defined labels for accessing object parameters via control logic.

C++ Type:std::vector

Options:

Description:Adds user-defined labels for accessing object parameters via control logic.

• enableTrueSet the enabled status of the MooseObject.

Default:True

C++ Type:bool

Options:

Description:Set the enabled status of the MooseObject.