Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline update! and hoist gamma check #195

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/nl_solvers/newtons_method.jl
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,3 @@ function solve_newton!(alg::NewtonsMethod, cache, x, f!, j! = nothing)
end
end
end

function update!(alg::NewtonsMethod, cache, signal::UpdateSignal, j!)
(; update_j) = alg
(; update_j_cache, j) = cache
if (!isnothing(j)) && needs_update!(update_j, update_j_cache, signal)
j!(j)
end
end
16 changes: 10 additions & 6 deletions src/solvers/imex_ark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,16 @@ function step_u!(integrator, cache::IMEXARKCache)

if !isnothing(T_imp!) && !isnothing(newtons_method)
NVTX.@range "update!" color = colorant"yellow" begin
update!(
newtons_method,
newtons_method_cache,
NewTimeStep(t),
jacobian -> isnothing(γ) ? sdirk_error(name) : T_imp!.Wfact(jacobian, u, p, dt * γ, t),
)
(; update_j) = newtons_method
(; update_j_cache) = newtons_method_cache
jacobian = newtons_method_cache.j
if (!isnothing(jacobian)) && needs_update!(update_j, update_j_cache, NewTimeStep(t))
if γ isa Nothing
sdirk_error(name)
else
T_imp!.Wfact(jacobian, u, p, dt * γ, t)
end
end
end
end

Expand Down
16 changes: 10 additions & 6 deletions src/solvers/imex_ssprk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ function step_u!(integrator, cache::IMEXSSPRKCache)
s = length(b_imp)

if !isnothing(T_imp!) && !isnothing(newtons_method)
update!(
newtons_method,
newtons_method_cache,
NewTimeStep(t),
jacobian -> isnothing(γ) ? sdirk_error(name) : T_imp!.Wfact(jacobian, u, p, dt * γ, t),
)
(; update_j) = newtons_method
(; update_j_cache) = newtons_method_cache
jacobian = newtons_method_cache.j
if (!isnothing(jacobian)) && needs_update!(update_j, update_j_cache, NewTimeStep(t))
if γ isa Nothing
sdirk_error(name)
else
T_imp!.Wfact(jacobian, u, p, dt * γ, t)
end
end
end

@. U = u
Expand Down
Loading