-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5ed50d
commit fef1637
Showing
31 changed files
with
336 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
framework/doc/content/source/convergence/IterationCountConvergence.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# IterationCountConvergence | ||
|
||
This [Convergence](Convergence/index.md) specifies: | ||
|
||
- $\ell_\text{max}$, the maximum number of iterations, | ||
via [!param](/Convergence/IterationCountConvergence/max_iterations), and | ||
- $\ell_\text{min}$, the minimum number of iterations, | ||
via [!param](/Convergence/IterationCountConvergence/min_iterations). | ||
|
||
If [!param](/Convergence/IterationCountConvergence/converge_at_max_iterations) | ||
is set to `true`, then the solve will converge when $\ell = \ell_\text{max}$ | ||
instead of diverge. | ||
|
||
Other `Convergence` objects may inherit from this class and override | ||
`checkConvergenceInner(iter)` instead of the usual `checkConvergence(iter)`, | ||
to inherit the iteration bounds. An example is [/PostprocessorConvergence.md]. | ||
|
||
!syntax parameters /Convergence/IterationCountConvergence | ||
|
||
!syntax inputs /Convergence/IterationCountConvergence | ||
|
||
!syntax children /Convergence/IterationCountConvergence |
20 changes: 20 additions & 0 deletions
20
framework/doc/content/source/convergence/PostprocessorConvergence.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# PostprocessorConvergence | ||
|
||
This [Convergence](Convergence/index.md) derives from [/IterationCountConvergence.md] | ||
and compares a [Postprocessor](Postprocessors/index.md) value $y$ to a tolerance $\tau$: | ||
|
||
!equation | ||
y \leq \tau \,. | ||
|
||
For this to work as expected, the `execute_on` parameter of the post-processor | ||
must include values that trigger execution before the desired check. For example, for nonlinear | ||
convergence, the value `NONLINEAR_CONVERGENCE` should be used. | ||
|
||
Typically the post-processor used should attempt to approximate the error in a system, | ||
such as [/AverageVariableChange.md]. | ||
|
||
!syntax parameters /Convergence/PostprocessorConvergence | ||
|
||
!syntax inputs /Convergence/PostprocessorConvergence | ||
|
||
!syntax children /Convergence/PostprocessorConvergence |
11 changes: 3 additions & 8 deletions
11
framework/doc/content/source/convergence/ReferenceResidualConvergence.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 45 additions & 25 deletions
70
framework/doc/content/source/convergence/ResidualConvergence.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,130 @@ | ||
# Convergence system | ||
# Convergence System | ||
|
||
The Convergence system provides the infrastructure for creating MOOSE objects that interact with the | ||
solvers to give the user more control over the application behaviour. | ||
The Convergence system allows users to customize the stopping criteria for the | ||
iteration in various solves: | ||
|
||
## Description | ||
- Nonlinear system solves | ||
- Linear system solves (not yet implemented) | ||
- Steady-state detection in [Transient.md] (not yet implemented) | ||
- Fixed point solves (not yet implemented) | ||
|
||
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 there are some scenarios that are problematic, where the user may desire | ||
interaction with the solver at runtime for better control or analysis. | ||
Instead of supplying convergence-related parameters directly to the executioner, | ||
the user creates `Convergence` objects whose names are then supplied to the | ||
executioner, e.g., | ||
|
||
Currently this object supports algebraic two types of convergence | ||
[/ResidualConvergence.md] and | ||
[ReferenceResidualConvergence.md]. | ||
``` | ||
[Convergence] | ||
[my_convergence1] | ||
type = MyCustomConvergenceClass | ||
# some convergence parameters, like tolerances | ||
[] | ||
[] | ||
### +Methods supported+ | ||
[Executioner] | ||
type = Steady | ||
nonlinear_convergence = my_convergence1 | ||
[] | ||
``` | ||
|
||
- [/ResidualConvergence.md] tracks the residual decay across iterations. This MOOSE object interfaces directly with the PETSc callback function at each iteration and allows the user to prescribe additional requirements and tests which can be performed at every iteration step. | ||
Currently only the nonlinear solve convergence is supported, but others are planned | ||
for the near future. | ||
|
||
- [ReferenceResidualConvergence.md] uses a user-specified reference vector for convergence checks, instead of the initial residual. This is beneficial when solution variables have different scaling. Convergence is achieved when the $L_2$ norm of each solution variable’s residual is less than either the relative tolerance times the $L_2$ norm of the corresponding reference variable or the absolute tolerance. As this method computes relative convergence differently, the required nonlinear relative tolerance to achieve the same error can vary from the default approach in MOOSE. Users must ensure appropriate tolerances are used. | ||
## Available Classes | ||
|
||
The `Convergence` classes provided by MOOSE are the following: | ||
|
||
- [/ResidualConvergence.md]: The default convergence criteria, which includes | ||
several convergence criteria combined together. | ||
- [/ReferenceResidualConvergence.md]: Like `ResidualConvergence`, but | ||
uses a custom norm to define the relative residual convergence criteria. | ||
[/ReferenceResidualProblem.md] uses this as its convergence criteria. | ||
- [/IterationCountConvergence.md]: Specifies minimum and maximum numbers of iterations. | ||
- [/PostprocessorConvergence.md]: Compares the value of a | ||
[Postprocessor](Postprocessors/index.md) to a tolerance. | ||
|
||
## Convergence Criteria Design Considerations | ||
|
||
Here we provide some considerations to make in designing convergence criteria | ||
and choosing appropriate parameter values. | ||
Consider a system of algebraic system of equations | ||
|
||
!equation | ||
\mathbf{r}(\mathbf{u}) = \mathbf{0} \,, | ||
|
||
where $\mathbf{u}$ is the unknown solution vector, and $\mathbf{r}$ is the residual | ||
function. To solve this system using an iterative method, we must decide on | ||
criteria to stop the iteration. | ||
In general, iteration for a solve should halt when the approximate solution $\tilde{\mathbf{u}}$ | ||
has reached a satisfactory level of error $\mathbf{e} \equiv \tilde{\mathbf{u}} - \mathbf{u}$, | ||
using a condition such as | ||
|
||
!equation id=error_criteria | ||
\|\mathbf{e}\| \leq \tau_u \,, | ||
|
||
where $\|\cdot\|$ denotes some norm, and $\tau_u$ denotes some tolerance. | ||
Unfortunately, since we do not know $\mathbf{u}$, the error $\mathbf{e}$ is | ||
also unknown and thus may not be computed directly. Thus some approximation of | ||
the condition [!eqref](error_criteria) must be made. This may entail some | ||
approximation of the error $\mathbf{e}$ or some criteria which implies the | ||
desired criteria. For example, a very common approach is to use a residual | ||
criteria such as | ||
|
||
!equation | ||
\|\mathbf{r}\| \leq \tau_{r,\text{abs}} \,. | ||
|
||
While it is true that $\|\mathbf{r}\| = 0$ implies $\|\mathbf{e}\| = 0$, a | ||
zero-tolerance is impractical, and the translation between the tolerance | ||
$\tau_u$ to the tolerance is $\tau_r$ is difficult. The "acceptable" absolute | ||
residual tolerance is tricky to determine and is highly dependent on the | ||
equations being solved. To attempt to circumvent this issue, relative residual | ||
criteria have been used, dividing the residual norm by another value in an | ||
attempt to normalize it. A common approach that has been used is to use the | ||
initial residual vector $\mathbf{r}_0$ to normalize: | ||
|
||
!equation | ||
\frac{\|\mathbf{r}\|}{\|\mathbf{r}_0\|} \leq \tau_{r,\text{rel}} \,, | ||
|
||
where $\tau_{r,\text{rel}}$ is the relative residual tolerance. The disadvantage | ||
with this particular choice is that this is highly dependent on how good the | ||
initial guess is: if the initial guess is very good, it will be nearly impossible | ||
to converge to the tolerance, and if the initial guess is very bad, it will be | ||
too easy to converge to the tolerance, resulting in an erroneous solution. | ||
|
||
Some other considerations are the following: | ||
|
||
- Consider round-off error: if error ever reaches values around round-off error, | ||
the solve should definitely be considered converged, as iterating further | ||
provides no benefit. | ||
- Consider the other sources of error in the model that produced the system of | ||
algebraic equations that you're solving. For example, if solving a system of | ||
partial differential equations, consider the model error and the discretization | ||
error; it is not beneficial to require algebraic error less than the other | ||
sources of error. | ||
- Since each convergence criteria typically has some weak point where they break | ||
down, it is usually advisable to use a combination of criteria. | ||
|
||
For more information on convergence criteria, see [!cite](rao2018stopping) for | ||
example. | ||
|
||
!alert tip title=Create your own convergence action | ||
The `Convergence` system provides a lot of flexibility by providing several | ||
pieces that can be combined together to create a desired set of convergence | ||
criteria. Since this may involve a large number of objects (including objects | ||
from other systems), it may be beneficial to create an [Action](/Action.md) | ||
to create more compact and convenient syntax for your application. | ||
|
||
## Implementing a New Convergence Class | ||
|
||
`Convergence` objects are responsible for overriding the virtual method | ||
|
||
``` | ||
MooseConvergenceStatus checkConvergence(unsigned int iter) | ||
``` | ||
|
||
The returned type `MooseConvergenceStatus` is one of the following values: | ||
|
||
- `CONVERGED`: The system has converged. | ||
- `DIVERGED`: The system has diverged. | ||
- `ITERATING`: The system has neither converged nor diverged and thus will | ||
continue to iterate. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.