Skip to content

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: perturb writes 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 ​

NameTypeAttributesDescription
NEWTON_DIAGONALinteger(kind=I4P)parameterdR_v/dy_v by a difference quotient.
NEWTON_BLOCKinteger(kind=I4P)parameterThe caller's ncomp x ncomp block per cell.
NEWTON_MAX_BLOCKinteger(kind=I4P)parameterThe largest block (components of the box).

Derived Types ​

newton_solver ​

Newton's method on U = E + gamma R(U), cell by cell.

Components

NameTypeAttributesDescription
jacobianinteger(kind=I4P)NEWTON_DIAGONAL or NEWTON_BLOCK.
atolreal(kind=R_P)Absolute part of the correction's scale.
rtolreal(kind=R_P)Relative part.
scalereal(kind=R_P)The diagonal form's typical |y| (the smallest perturbation's scale).
max_iterationsinteger(kind=I4P)Iterations before converged stops the run.
iterationsinteger(kind=I4P)Updates since start.

Type-Bound Procedures

NameAttributesDescription
initializepass(self)Choose the Jacobian and the tolerances.
startpass(self)A new solve.
perturbpass(self)The diagonal form's perturbed state y + h.
updatepass(self)One Newton step in place; the box's largest scaled correction.
convergedpass(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).

fortran
subroutine initialize(self, jacobian, atol, rtol, scale, max_iterations)

Arguments

NameTypeIntentAttributesDescription
selfclass(newton_solver)inoutSolver.
jacobianinteger(kind=I4P)inNEWTON_DIAGONAL or NEWTON_BLOCK.
atolreal(kind=R_P)inoptionalAbsolute tolerance.
rtolreal(kind=R_P)inoptionalRelative tolerance.
scalereal(kind=R_P)inoptionalTypical |y| (diagonal form).
max_iterationsinteger(kind=I4P)inoptionalIterations allowed.

newton_solver%start ​

A new solve: the iterations counted from zero.

fortran
subroutine start(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(newton_solver)inoutSolver.

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.

fortran
subroutine perturb(self, bx, y, yp)

Arguments

NameTypeIntentAttributesDescription
selfclass(newton_solver)inSolver.
bxtype(box)inBox.
yreal(kind=R_P)inState.
ypreal(kind=R_P)inoutPerturbed 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)

fortran
function update(self, bx, gam, e, r, y, jac, rp, yp) result(dmax)

Arguments

NameTypeIntentAttributesDescription
selfclass(newton_solver)inoutSolver.
bxtype(box)inBox.
gamreal(kind=R_P)ingamma = dt stage_gamma(k).
ereal(kind=R_P)inExplicit part E.
rreal(kind=R_P)inR(y).
yreal(kind=R_P)inoutIterate, updated.
jacreal(kind=R_P)inoptionalBlocks dR_v/dy_w (NEWTON_BLOCK).
rpreal(kind=R_P)inoptionalR(yp) (NEWTON_DIAGONAL).
ypreal(kind=R_P)inoptionalPerturbed 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

fortran
function converged(self, dmax) result(yes)

Arguments

NameTypeIntentAttributesDescription
selfclass(newton_solver)inSolver.
dmaxreal(kind=R_P)inReduced largest scaled correction.