|
|
|
|
|
Nonlinear problems can be solved in a variety of ways in GetDP:
|
|
|
* By writing the nonlinear iteration explicitly in the `Resolution` operations
|
|
|
* By using the `IterativeLoop` function in `Resolution`
|
|
|
* By using the `IterativeLoopN` function in `Resolution`
|
|
|
|
|
|
The explicit specification in `Resolution` operations is the most flexible solution, but is also the most involved. See the [`helix.pro`](https://gitlab.onelab.info/doc/models/blob/master/Superconductors/helix.pro) high-temperature superconducting cable model for an example. `IterativeLoop` and `IterativeLoopN` hide some of the complexity, by automatically assessing the convergence by looking at the changes in the result after each iteration. If the changes (error) is below a certain limit, the result is converged and the loop ends. `IterativeLoop` uses an empirical algorithm for calculating the error whereas `IterativeLoopN` allows to specify in detail the error calculation and the allowed tolerances.
|
|
|
|
|
|
## Explicit writing of nonlinear iterations
|
|
|
|
|
|
To be written.
|
|
|
|
|
|
## `IterativeLoop`
|
|
|
|
|
|
To be written
|
|
|
|
|
|
## `IterativeLoopN`
|
|
|
|
|
|
A typical usage of IterativeLoopN is shown in the following piece of code:
|
|
|
|
|
|
```cpp
|
|
|
Resolution {
|
|
|
{ Name ElectroThermal;
|
|
|
System {
|
|
|
{ Name SystemT; NameOfFormulation FormulationT; }
|
|
|
{ Name SystemV; NameOfFormulation FormulationV; }
|
|
|
}
|
|
|
Operation {
|
|
|
InitSolution[SystemT];
|
|
|
InitSolution[SystemV];
|
|
|
|
|
|
IterativeLoopN[NbrMaxIter, NL_Relax,
|
|
|
System { { SystemT, ReltolT, AbstolT, Solution LinfNorm }
|
|
|
{ SystemV, ReltolV, AbstolV, Solution MeanL2Norm } }
|
|
|
PostOperation { { V_Top, ReltolP, AbstolP, MeanL1Norm } } ]
|
|
|
{
|
|
|
Generate[SystemV];
|
|
|
Solve[SystemV];
|
|
|
Generate[SystemT];
|
|
|
Solve[SystemT];
|
|
|
}
|
|
|
|
|
|
SaveSolution[SystemV];
|
|
|
SaveSolution[SystemT];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
The parameters are:
|
|
|
|
|
|
* Maximum iterations: Maximum number of iterations
|
|
|
* NL_Relax: Relaxation factor (multiplies the iterative correction \deltax for Newton's method)
|
|
|
* System / PostOperation: Keyword System indicates that the quantity of interest are all DOFs of the given system. In addition or as an alternative you can specify post-operation results as quantities of interest by the keyword PostOperation.
|
|
|
* System / post-operation name: Here the name of the system / post-operation of interest is declared.
|
|
|
* Relative tolerance: Relative tolerance for the quantity of interest.
|
|
|
* Absolute tolerance: Absolute tolerance for the quantity of interest.
|
|
|
* Assessed object: Possible choices in case of a specified system: Solution, Residual, RecalcResidual. For specified post-operations this has to be omitted. Residual and RecalcResidual can only be used for Newton's method. Residual assesses the residual from the last iteration whereas RecalcResidual calculates the residual once again after each iteration. This means that with Residual usually one extra iteration is performed, but RecalcResidual causes higher computational effort per iteration.
|
|
|
* Error norm: Type of the error norm. Possible choices are: L1Norm, MeanL1Norm, L2Norm, MeanL2Norm, LinfNorm (→ see definitions below).
|
|
|
|
|
|
### Comparison of system vs. post-operation
|
|
|
|
|
|
* When a system is specified then all DOFs of this system are assessed, but they do not necessarily correspond to the values of the quantities of the formulation directly (e.g. in case of higher order basis functions).
|
|
|
* In case of several quantities in a formulation they can be assessed individually by a specified post-operation.
|
|
|
* With post-operations it's also possible to assess different regions individually.
|
|
|
* Also derived quantities can be assessed with a specified post-operation.
|
|
|
* Performing a post-operation each iteration can be time consuming for large problems.
|
|
|
|
|
|
### Error Norm
|
|
|
|
|
|
For each quantity of interest $`x_i`$ an error ratio $`q_i`$ is calculated:
|
|
|
|
|
|
$`q_i = \frac{|\Delta x_i|}{\epsilon_{abs} + \epsilon_{rel}|x_i|}`$
|
|
|
|
|
|
As the error ratio is calculated for each quantity of interest (e.g. one q per DOF of a given system) we need a norm in order to assess the overall error ratio. There are several norm types available for `IterativeLoopN`:
|
|
|
|
|
|
* L1 Norm: $`\|q\|_{L1} = \sum_{i=1}^n |q_i|`$
|
|
|
* Mean L1 Norm: $`\|q\|_{Mean L1} = \frac 1n \sum_{i=1}^n |q_i|`$
|
|
|
* L2 Norm: $`\|q\|_{L2} = \sqrt{\sum_{i=1}^n \left( q_i \right)^2}`$
|
|
|
* Mean L2 Norm: $`\|q\|_{Mean L2} = \sqrt{\frac 1n \sum_{i=1}^n \left( q_i \right)^2}`$
|
|
|
* Linfinity Norm: $`\|q\|_\infty = \max \left( |q_i| \right)`$
|
|
|
|
|
|
### General Hints
|
|
|
|
|
|
* If you specify several Systems and/or post-operations then usually only the largest $`\|q\|`$ is printed. If the verbosity level is set higher than 5 then $`\|q\|`$ is printed for each system or post-operation.
|
|
|
* If you start GetDP within Gmsh then the largest $\`|q\|`$ (ILmaxErrorRatio) can be plotted nicely.
|
|
|
|
|
|
### Complete Example
|
|
|
|
|
|
Here a complete example is given for a electro-thermal problem. We have an object consisting of two materials. On top a uniform current source is applied. The dissipated power is heating the body. The bottom of the body is kept at a fix temperature. The electrical conductivity is temperature dependent.
|
|
|
|
|
|
Geometry: [https://onelab.info/trac/getdp/attachment/wiki/IterativeLoopN/ElectroThermal_Sim.geo]
|
|
|
Problem: [https://onelab.info/trac/getdp/attachment/wiki/IterativeLoopN/ElectroThermal_Sim.pro]
|
|
|
[ElectroThermal_Sim.jpg] |
|
|
\ No newline at end of file |