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

Removing Allocation for Inexact Jacobian #266

Merged
merged 5 commits into from
Nov 1, 2023
Merged
Changes from 1 commit
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
15 changes: 11 additions & 4 deletions src/pseudotransient.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,17 @@ end
function perform_step!(cache::PseudoTransientCache{true})
@unpack u, u_prev, fu1, f, p, alg, J, linsolve, du, alpha, tc_storage = cache
jacobian!!(J, cache)
J_new = J - (1 / alpha) * I
if J isa SciMLBase.AbstractSciMLOperator
J = J - (1 / alpha) * I
else
J .= J - (1 / alpha) * I
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end
#J_new = J - (1 / alpha) * I
yonatanwesen marked this conversation as resolved.
Show resolved Hide resolved

termination_condition = cache.termination_condition(tc_storage)

# u = u - J \ fu
linres = dolinsolve(alg.precs, linsolve; A = J_new, b = _vec(fu1), linu = _vec(du),
linres = dolinsolve(alg.precs, linsolve; A = J, b = _vec(fu1), linu = _vec(du),
p, reltol = cache.abstol)
cache.linsolve = linres.cache
@. u = u - du
Expand Down Expand Up @@ -147,11 +152,13 @@ function perform_step!(cache::PseudoTransientCache{false})
termination_condition = cache.termination_condition(tc_storage)

cache.J = jacobian!!(cache.J, cache)

cache.J = cache.J - (1 / alpha) * I
# u = u - J \ fu
if linsolve === nothing
cache.du = fu1 / (cache.J - (1 / alpha) * I)
cache.du = fu1 / (cache.J)
yonatanwesen marked this conversation as resolved.
Show resolved Hide resolved
else
linres = dolinsolve(alg.precs, linsolve; A = cache.J - (1 / alpha) * I,
linres = dolinsolve(alg.precs, linsolve; A = cache.J,
b = _vec(fu1),
yonatanwesen marked this conversation as resolved.
Show resolved Hide resolved
linu = _vec(cache.du), p, reltol = cache.abstol)
cache.linsolve = linres.cache
Expand Down
Loading