Skip to content

Commit 6d991de

Browse files
Rename run for newton method
1 parent 9019f83 commit 6d991de

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/solvers/imex_ark.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,13 @@ function step_u!(integrator, cache::IMEXARKCache)
130130
@. residual = temp + dt * a_imp[i, i] * residual - Ui
131131
end
132132
implicit_equation_jacobian! = (jacobian, Ui) -> T_imp!.Wfact(jacobian, Ui, p, dt * a_imp[i, i], t_imp)
133-
run!(newtons_method, newtons_method_cache, U[i], implicit_equation_residual!, implicit_equation_jacobian!)
133+
solve_newton!(
134+
newtons_method,
135+
newtons_method_cache,
136+
U[i],
137+
implicit_equation_residual!,
138+
implicit_equation_jacobian!,
139+
)
134140
end
135141

136142
# We do not need to DSS U[i] again because the implicit solve should

src/solvers/newtons_method.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ end
466466
467467
Solves the equation `f(x) = 0`, using the Jacobian (or an approximation of the
468468
Jacobian) `j(x) = f'(x)` if it is available. This is done by calling
469-
`run!(::NewtonsMethod, cache, x, f!, j! = nothing)`, where `f!(f, x)` is a
469+
`solve_newton!(::NewtonsMethod, cache, x, f!, j! = nothing)`, where `f!(f, x)` is a
470470
function that sets `f(x)` in-place and, if it is specified, `j!(j, x)` is a
471471
function that sets `j(x)` in-place. The `x` passed to Newton's method is
472472
modified in-place, and its initial value is used as a starting guess for the
@@ -508,7 +508,7 @@ If `j(x)` changes sufficiently slowly, `update_j` may be changed from
508508
`UpdateEvery(NewNewtonIteration)` to some other `UpdateSignalHandler` that
509509
gets triggered less frequently, such as `UpdateEvery(NewNewtonSolve)`. This
510510
can be used to make the approximation `j(x[n]) ≈ j(x₀)`, where `x₀` is a
511-
previous value of `x[n]` (possibly even a value from a previous `run!` of
511+
previous value of `x[n]` (possibly even a value from a previous `solve_newton!` of
512512
Newton's method). When Newton's method uses such an approximation, it is called
513513
the "chord method".
514514
@@ -558,7 +558,7 @@ function allocate_cache(alg::NewtonsMethod, x_prototype, j_prototype = nothing)
558558
)
559559
end
560560

561-
function run!(alg::NewtonsMethod, cache, x, f!, j! = nothing)
561+
function solve_newton!(alg::NewtonsMethod, cache, x, f!, j! = nothing)
562562
(; max_iters, update_j, krylov_method, convergence_checker, verbose) = alg
563563
(; update_j_cache, krylov_method_cache, convergence_checker_cache) = cache
564564
(; Δx, f, j) = cache

test/test_newtons_method.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using ClimaTimeSteppers, LinearAlgebra, Random, Test
2+
import ClimaTimeSteppers as CTS
23

34
function linear_equation(FT, n)
45
rng = MersenneTwister(1)
@@ -60,7 +61,7 @@ end
6061
x = copy(x_init)
6162
j_prototype = similar(x, length(x), length(x))
6263
cache = allocate_cache(alg, x, use_j ? j_prototype : nothing)
63-
run!(alg, cache, x, f!, use_j ? j! : nothing)
64+
CTS.solve_newton!(alg, cache, x, f!, use_j ? j! : nothing)
6465
@test norm(x .- x_exact) / norm(x_exact) < rtol
6566
end
6667
end

0 commit comments

Comments
 (0)