selah_newton
SELAH, L1: Newton's method for the implicit stages of pointwise stiff terms, diagonal or block-diagonal per cell.
An implicit stage solves U = E + gamma R(U) (a fixed-point stage of the stepper: stage_gamma(k), gamma = dt stage_gamma(k), E = explicit_part()). When the stiff part of R couples only the components of one cell (a relaxation, a chemical source, a collision term), the Jacobian of R is block-diagonal: one ncomp x ncomp block per cell. The Newton iteration U <- U - (I - gamma J)^{-1} (U - E - gamma R(U)) is then a small dense solve per cell, independent of its neighbours: no linear solver across cells, no reduction but the convergence test.
newton_solver is driven by its caller (the stepper's reverse-communication contract, decision D1 of #11): inside a fixed-point stage, the caller evaluates R at the stage state, then calls update, which makes the Newton step in place and returns the step's largest scaled correction on its box; the caller reduces it (a max over its boxes and ranks) and asks converged. Two Jacobians:
NEWTON_BLOCK: the caller writes the blocks, jac(cell, v, w) = dR_v/dy_w, an array shaped like the field with one more dimension of the components (as the stepper's registers): its LU with partial pivoting is made per cell;NEWTON_DIAGONAL: each component depends on itself only (to the solver's accuracy), dR_v/dy_v by one difference quotient:perturbwrites the state y + h (h = sqrt(eps) max(|y|, scale)), the caller evaluates R there too.
The correction's scale is atol + rtol |y| per element; converged(dmax) is dmax <= 1, the caller's maximum of update's results. A converged iterate is the stage's state: the caller evaluates R there once more (the stage's residual), and the stepper's update E + gamma R(U) returns U to the tolerance (with iterations=2, the stage the last one). Every array is device resident in a device build; no mask (a masked cell's residual is the caller's).
Source: src/lib/selah_newton.F90
Dependencies
Contents
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
NEWTON_DIAGONAL | integer(kind=I4P) | parameter | dR_v/dy_v by a difference quotient. |
NEWTON_BLOCK | integer(kind=I4P) | parameter | The caller's ncomp x ncomp block per cell. |
NEWTON_MAX_BLOCK | integer(kind=I4P) | parameter | The largest block (components of the box). |
Derived Types
newton_solver
Newton's method on U = E + gamma R(U), cell by cell.
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
jacobian | integer(kind=I4P) | NEWTON_DIAGONAL or NEWTON_BLOCK. | |
atol | real(kind=R_P) | Absolute part of the correction's scale. | |
rtol | real(kind=R_P) | Relative part. | |
scale | real(kind=R_P) | The diagonal form's typical |y| (the smallest perturbation's scale). | |
max_iterations | integer(kind=I4P) | Iterations before converged stops the run. | |
iterations | integer(kind=I4P) | Updates since start. |
Type-Bound Procedures
| Name | Attributes | Description |
|---|---|---|
initialize | pass(self) | Choose the Jacobian and the tolerances. |
start | pass(self) | A new solve. |
perturb | pass(self) | The diagonal form's perturbed state y + h. |
update | pass(self) | One Newton step in place; the box's largest scaled correction. |
converged | pass(self) | The reduced correction is within the tolerance. |
newton_solver%initialize
The Jacobian's form and the tolerances (defaults: atol 1e-12, rtol 1e-10, scale 1, 10 iterations).
subroutine initialize(self, jacobian, atol, rtol, scale, max_iterations)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(newton_solver) | inout | Solver. | |
jacobian | integer(kind=I4P) | in | NEWTON_DIAGONAL or NEWTON_BLOCK. | |
atol | real(kind=R_P) | in | optional | Absolute tolerance. |
rtol | real(kind=R_P) | in | optional | Relative tolerance. |
scale | real(kind=R_P) | in | optional | Typical |y| (diagonal form). |
max_iterations | integer(kind=I4P) | in | optional | Iterations allowed. |
newton_solver%start
A new solve: the iterations counted from zero.
subroutine start(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(newton_solver) | inout | Solver. |
newton_solver%perturb
The diagonal form's perturbed state over the box, yp = y + h, h = sqrt(eps) max(|y|, scale): the caller evaluates R(yp) into a register of its own and gives it to update with yp.
subroutine perturb(self, bx, y, yp)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(newton_solver) | in | Solver. | |
bx | type(box) | in | Box. | |
y | real(kind=R_P) | in | State. | |
yp | real(kind=R_P) | inout | Perturbed state. |
newton_solver%update
One Newton step over the box, in place: y = y - (I - gam J)^{-1} (y - e - gam r), r = R(y); J from jac (NEWTON_BLOCK) or from the difference quotient (rp - r)/(yp - y) (NEWTON_DIAGONAL, rp = R(yp), yp from perturb). Returns the box's largest |correction| / (atol + rtol |y|), for the caller to reduce.
Returns: real(kind=R_P)
function update(self, bx, gam, e, r, y, jac, rp, yp) result(dmax)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(newton_solver) | inout | Solver. | |
bx | type(box) | in | Box. | |
gam | real(kind=R_P) | in | gamma = dt stage_gamma(k). | |
e | real(kind=R_P) | in | Explicit part E. | |
r | real(kind=R_P) | in | R(y). | |
y | real(kind=R_P) | inout | Iterate, updated. | |
jac | real(kind=R_P) | in | optional | Blocks dR_v/dy_w (NEWTON_BLOCK). |
rp | real(kind=R_P) | in | optional | R(yp) (NEWTON_DIAGONAL). |
yp | real(kind=R_P) | in | optional | Perturbed state (NEWTON_DIAGONAL). |
Call graph
newton_solver%converged
The caller's maximum of update's results over its boxes and ranks is within the tolerance (dmax <= 1); an error stop past max_iterations.
Returns: logical
function converged(self, dmax) result(yes)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(newton_solver) | in | Solver. | |
dmax | real(kind=R_P) | in | Reduced largest scaled correction. |