Skip to content

Commit bb8c550

Browse files
authored
switch to symbol API (#28)
1 parent ff4d9da commit bb8c550

File tree

5 files changed

+18
-19
lines changed

5 files changed

+18
-19
lines changed

examples/bratu.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fig
5959
uₖ, _ = newton_krylov!(
6060
bratu!,
6161
copy(u₀), (dx, λ), similar(u₀);
62-
Workspace = CgWorkspace,
62+
algo = :cg,
6363
)
6464

6565
ϵ = abs2.(uₖ .- reference)
@@ -85,15 +85,15 @@ end
8585
_, stats = newton_krylov(
8686
bratu,
8787
copy(u₀), (dx, λ);
88-
Workspace = CgWorkspace
88+
algo = :cg
8989
)
9090
stats
9191

9292
# ## Solving with a fixed forcing
9393
_, stats = newton_krylov!(
9494
bratu!,
9595
copy(u₀), (dx, λ), similar(u₀);
96-
Workspace = CgWorkspace,
96+
algo = :cg,
9797
forcing = NewtonKrylov.Fixed(0.1)
9898
)
9999
stats
@@ -102,7 +102,7 @@ stats
102102
_, stats = newton_krylov!(
103103
bratu!,
104104
copy(u₀), (dx, λ), similar(u₀);
105-
Workspace = CgWorkspace,
105+
algo = :cg,
106106
forcing = nothing
107107
)
108108
stats
@@ -112,7 +112,7 @@ stats
112112
# _, stats = newton_krylov!(
113113
# bratu!,
114114
# copy(u₀), (dx, λ), similar(u₀);
115-
# Workspace = GmresWorkspace,
115+
# algo = :gmres,
116116
# )
117117
# stats
118118
# ```
@@ -121,7 +121,7 @@ stats
121121
_, stats = newton_krylov!(
122122
bratu!,
123123
copy(u₀), (dx, λ), similar(u₀);
124-
Workspace = GmresWorkspace,
124+
algo = :gmres,
125125
N = (J) -> ilu(collect(J)), # Assembles the full Jacobian
126126
krylov_kwargs = (; ldiv = true)
127127
)
@@ -131,7 +131,7 @@ stats
131131
_, stats = newton_krylov!(
132132
bratu!,
133133
copy(u₀), (dx, λ), similar(u₀);
134-
Workspace = FgmresWorkspace,
134+
algo = :fgmres,
135135
N = (J) -> ilu(collect(J)), # Assembles the full Jacobian
136136
krylov_kwargs = (; ldiv = true)
137137
)
@@ -151,7 +151,7 @@ end
151151
_, stats = newton_krylov!(
152152
bratu!,
153153
copy(u₀), (dx, λ), similar(u₀);
154-
Workspace = FgmresWorkspace,
154+
algo = :fgmres,
155155
N = (J) -> GmresPreconditioner(J, 5),
156156
)
157157
stats
@@ -161,7 +161,7 @@ stats
161161
# newton_krylov!(
162162
# bratu!,
163163
# copy(u₀), (dx, λ), similar(u₀);
164-
# Workspace = CglsWorkspace, # CgneWorkspace
164+
# algo = :cgls, # Cgne
165165
# krylov_kwargs = (; verbose=1)
166166
# )
167167
# ```
@@ -171,7 +171,7 @@ stats
171171
# bratu!,
172172
# copy(u₀), (dx, λ), similar(u₀);
173173
# verbose = 1,
174-
# Workspace = BicgstabWorkspace, # L=2
174+
# algo = :bicgstab, # L=2
175175
# η_max = nothing
176176
# )
177177
# ```

examples/bratu_ka.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fig
6363
uₖ, _ = newton_krylov!(
6464
bratu!,
6565
copy(u₀), (dx, λ), similar(u₀);
66-
Workspace = CgWorkspace,
66+
algo = :cg,
6767
)
6868

6969
ϵ = abs2.(uₖ .- reference)

examples/bvp.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function BVP_solve(n = 801, T = Float64)
5353

5454
bvpout, stats = newton_krylov!(
5555
Fbvp!, U0, (force, tv, tvdag, h, n), res,
56-
Workspace = FgmresWorkspace,
56+
algo = :fgmres,
5757
N = (J) -> GmresPreconditioner(J, 30),
5858
)
5959
return (; bvpout, tv, stats)

examples/implicit.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,9 @@ end
5151

5252
# ## Non-adaptive time stepping
5353

54-
import Krylov
55-
5654
function solve(
5755
G!, f!, uₙ, p, Δt, ts; callback = _ -> nothing,
58-
verbose = 0, Workspace = Krylov.GmresWorkspace, krylov_kwargs = (;)
56+
verbose = 0, algo = :gmres, krylov_kwargs = (;)
5957
)
6058
u = copy(uₙ)
6159
du = zero(uₙ)
@@ -68,7 +66,7 @@ function solve(
6866
end
6967
_, stats = newton_krylov!(
7068
F!, u, (uₙ, Δt, du, p, t), res;
71-
verbose, Workspace, tol_abs = 6.0e-6, krylov_kwargs
69+
verbose, algo, tol_abs = 6.0e-6, krylov_kwargs
7270
)
7371
if !stats.solved
7472
@warn "non linear solve failed marching on" t stats

src/NewtonKrylov.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ function newton_krylov!(
292292
max_niter = 50,
293293
forcing::Union{Forcing, Nothing} = EisenstatWalker(),
294294
verbose = 0,
295-
Workspace = GmresWorkspace,
295+
algo = :gmres,
296296
M = nothing,
297297
N = nothing,
298298
krylov_kwargs = (;),
@@ -309,12 +309,13 @@ function newton_krylov!(
309309
η = inital(forcing)
310310
end
311311

312-
verbose > 0 && @info "Jacobian-Free Newton-Krylov" Workspace res₀ = n_res tol tol_rel tol_abs η
312+
verbose > 0 && @info "Jacobian-Free Newton-Krylov" algo res₀ = n_res tol tol_rel tol_abs η
313313

314314
J = JacobianOperator(F!, res, u, p)
315315

316+
# TODO: Refactor to provide method that re-uses the cache here.
316317
kc = KrylovConstructor(res)
317-
workspace = Workspace(kc)
318+
workspace = krylov_workspace(algo, kc)
318319

319320
stats = Stats(0, 0, n_res)
320321
while n_res > tol && stats.outer_iterations <= max_niter

0 commit comments

Comments
 (0)