... | ... | @@ -121,9 +121,32 @@ Examples: |
|
|
|
|
|
## Built-in `IterativeLoop` function
|
|
|
|
|
|
This section will explain the `GenerateJac` and `SolveJac` functions, that automate parts of the implementation of Newton-Raphson and Picard iterations in conjunction with the `JacNL` equation term specifier and the `IterativeLoop` resolution function.
|
|
|
The `IterativeLoop` resolution function
|
|
|
```
|
|
|
IterativeLoop [exp-cst,exp,exp-cst<,exp-cst>] { resolution-op }
|
|
|
````
|
|
|
can be used in the `Operations` of a `Resolution` instead of the explicit `While` loop, in order to hide some of the algorithmic complexity when the nonlinearity is of the form $`\mathbf{F}(\mathbf{x}) := \mathbf{A}(\mathbf{x}) \mathbf{x} - \mathbf{b}(\mathbf{x})`$. The parameters of `IterativeLoop` are: the maximum number of iterations $`k_{max}`$ (if no convergence), the relative error $`\varepsilon`$ to achieve and the relaxation factor $`\gamma_k`$ that multiplies the iterative correction. (The optional parameter is a flag for testing purposes.) The `resolution-op` field contains the operations that have to be performed at each iteration.
|
|
|
|
|
|
During a Newton-Raphson iteration, the system $`\mathbf{J}(\mathbf{x}_{k-1}) \mathbf{\delta x}_k
|
|
|
= \mathbf{b}(\mathbf{x}_{k-1}) - \mathbf{A}(\mathbf{x}_{k-1}) \mathbf{x}_{k-1}`$ has to be generated and then solved consecutively. These steps are done by using the `GenerateJac` and `SolveJac` functions inside the `resolution-op` field of an `IterativeLoop` command. These two functions are briefly described hereafter:
|
|
|
|
|
|
```
|
|
|
GenerateJac [system-id]
|
|
|
```
|
|
|
Generate the system of equations `system-id` using a Jacobian matrix $`\mathbf{J}`$.
|
|
|
|
|
|
```
|
|
|
SolveJac [system-id]
|
|
|
```
|
|
|
Solve the system of equations `system-id` using a Jacobian matrix $`\mathbf{J}`$ (system of which the unknowns are corrections $`\mathbf{\delta x}`$ of the current solution $`\mathbf{x}`$). Then, Increment the solution ($`\mathbf{x}=\mathbf{x}+\mathbf{\delta x}`$) and compute the relative error $`\mathbf{\delta x}/\mathbf{x}`$.
|
|
|
|
|
|
In GetDP, the system of equations that has to be generated and solved is expressed in an "Equation"-block of a `.pro' file. When calling `GenerateJac`, the Jacobian matrix $`\mathbf{J}`$ is built by assembling the matrix $`\mathbf{A}`$ whith the additionnal terms incorporated in a $`\mathbf{JacNL}`$ function in the formulation of a nonlinear problem. In other words, by definition:
|
|
|
```math
|
|
|
\mathbf{J} := \mathbf{A} + \mathbf{JacNL}
|
|
|
```
|
|
|
where $`\mathbf{JacNL}`$ stands for the elements included in a `JacNL` equation block while $`\mathbf{A}`$ gathers the classical terms that are not attached to a `JacNL` equation block. In case the problem is linear, i.e. when the $`\mathbf{A}`$-matrix does not depend on the unknowns $`\mathbf{x}`$, the Jacobian matrix reduces to $`\mathbf{J} = \mathbf{A}`$ so that the $`\mathbf{JacNL}`$ part vanishes. In the light of this, it is obvious that the $`\mathbf{JacNL}`$ is used to represent the nonlinear part of the Jacobian matrix. This allows to write the equation blocks once, for both linear and nonlinear problems!
|
|
|
|
|
|
Integrate here material from http://onelab.info/wiki/Nonlinear_problems_in_GetDP
|
|
|
Integrate here additional material from http://onelab.info/wiki/Nonlinear_problems_in_GetDP (this wiki will eventually dissappear).
|
|
|
|
|
|
## Built-in `IterativeLoopN` function
|
|
|
|
... | ... | |