Skip to content

Commit fc05995

Browse files
format
1 parent 4f933bc commit fc05995

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/NonlinearSolve.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import ArrayInterfaceCore
1414

1515
abstract type AbstractNonlinearSolveAlgorithm <: SciMLBase.AbstractNonlinearAlgorithm end
1616
abstract type AbstractBracketingAlgorithm <: AbstractNonlinearSolveAlgorithm end
17-
abstract type AbstractNewtonAlgorithm{CS, AD, FDT, ST, CJ} <: AbstractNonlinearSolveAlgorithm end
17+
abstract type AbstractNewtonAlgorithm{CS, AD, FDT, ST, CJ} <:
18+
AbstractNonlinearSolveAlgorithm end
1819
abstract type AbstractImmutableNonlinearSolver <: AbstractNonlinearSolveAlgorithm end
1920

2021
include("utils.jl")

src/raphson.jl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
struct NewtonRaphson{CS, AD, FDT, L, P, ST, CJ} <: AbstractNewtonAlgorithm{CS, AD, FDT, ST, CJ}
1+
struct NewtonRaphson{CS, AD, FDT, L, P, ST, CJ} <:
2+
AbstractNewtonAlgorithm{CS, AD, FDT, ST, CJ}
23
linsolve::L
34
precs::P
45
end
56

67
function NewtonRaphson(; chunk_size = Val{0}(), autodiff = Val{true}(),
7-
standardtag = Val{true}(), concrete_jac = nothing,
8-
diff_type = Val{:forward}, linsolve = nothing, precs = DEFAULT_PRECS)
8+
standardtag = Val{true}(), concrete_jac = nothing,
9+
diff_type = Val{:forward}, linsolve = nothing, precs = DEFAULT_PRECS)
910
NewtonRaphson{_unwrap_val(chunk_size), _unwrap_val(autodiff), diff_type,
10-
typeof(linsolve), typeof(precs), _unwrap_val(standardtag),
11-
_unwrap_val(concrete_jac)}(linsolve, precs)
11+
typeof(linsolve), typeof(precs), _unwrap_val(standardtag),
12+
_unwrap_val(concrete_jac)}(linsolve, precs)
1213
end
1314

1415
mutable struct NewtonRaphsonCache{ufType, L, jType, uType, JC}
@@ -22,7 +23,7 @@ end
2223
function dolinsolve(precs::P, linsolve; A = nothing, linu = nothing, b = nothing,
2324
du = nothing, u = nothing, p = nothing, t = nothing,
2425
weight = nothing, solverdata = nothing,
25-
reltol = nothing) where P
26+
reltol = nothing) where {P}
2627
A !== nothing && (linsolve = LinearSolve.set_A(linsolve, A))
2728
b !== nothing && (linsolve = LinearSolve.set_b(linsolve, b))
2829
linu !== nothing && (linsolve = LinearSolve.set_u(linsolve, linu))
@@ -33,7 +34,7 @@ function dolinsolve(precs::P, linsolve; A = nothing, linu = nothing, b = nothing
3334
linsolve.Pr
3435

3536
_Pl, _Pr = precs(linsolve.A, du, u, p, nothing, A !== nothing, Plprev, Prprev,
36-
solverdata)
37+
solverdata)
3738
if (_Pl !== nothing || _Pr !== nothing)
3839
_weight = weight === nothing ?
3940
(linsolve.Pr isa Diagonal ? linsolve.Pr.diag : linsolve.Pr.inner.diag) :
@@ -68,7 +69,7 @@ function wrapprecs(_Pl, _Pr, weight)
6869
end
6970

7071
function alg_cache(alg::NewtonRaphson, f, u, p, ::Val{true})
71-
uf = JacobianWrapper(f,p)
72+
uf = JacobianWrapper(f, p)
7273
J = false .* u .* u'
7374

7475
linprob = LinearProblem(W, _vec(zero(u)); u0 = _vec(zero(u)))
@@ -103,12 +104,12 @@ function perform_step(solver::NewtonImmutableSolver, alg::NewtonRaphson, ::Val{t
103104
@unpack J, linsolve, du1 = cache
104105
calc_J!(J, solver, cache)
105106
# u = u - J \ fu
106-
linsolve = dolinsolve(alg.precs, solver.linsolve, A = J, b = fu, u = du1,
107+
linsolve = dolinsolve(alg.precs, solver.linsolve, A = J, b = fu, u = du1,
107108
p = p, reltol = solver.tol)
108-
@set! cache.linsolve = linsolve
109+
@set! cache.linsolve = linsolve
109110
@. u = u - du1
110111
f(fu, u, p)
111-
112+
112113
if solver.internalnorm(solver.fu) < solver.tol
113114
@set! solver.force_stop = true
114115
end

0 commit comments

Comments
 (0)