Skip to content

Commit

Permalink
Update cpr.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
moyner committed Feb 21, 2023
1 parent feefc52 commit 92983d8
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/cpr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,25 +188,31 @@ function apply!(x, cpr::CPRPreconditioner, r, arg...)
# Apply preconditioner to pressure part
@tic "p apply" begin
p_rtol = cpr.p_rtol
apply!(Δp, cpr.pressure_precond, r_p)
if !isnothing(p_rtol)
A_p = cpr.A_p
if isnothing(cpr.psolver)
cpr.psolver = FgmresSolver(A_p, r_p)
end
psolve = cpr.psolver
warm_start!(psolve, Δp)
M = Jutul.PrecondWrapper(linear_operator(cpr.pressure_precond))
fgmres!(psolve, A_p, r_p, M = M, rtol = p_rtol, itmax = 20)
@. Δp = psolve.x
end
p_precond = cpr.pressure_precond
cpr_p_apply!(Δp, cpr, p_precond, r_p, p_rtol)
end
@tic "r update" correct_residual_for_dp!(y, x, Δp, bz, cpr.buf, cpr.A_ps)
@tic "s apply" apply!(x, cpr.system_precond, y)
@tic "Δp" increment_pressure!(x, Δp, bz)
end
end


function cpr_p_apply!(Δp, cpr, p_precond, r_p, p_rtol)
apply!(Δp, p_precond, r_p)
if !isnothing(p_rtol)
A_p = cpr.A_p
if isnothing(cpr.psolver)
cpr.psolver = FgmresSolver(A_p, r_p)
end
psolve = cpr.psolver
warm_start!(psolve, Δp)
M = Jutul.PrecondWrapper(linear_operator(p_precond))
fgmres!(psolve, A_p, r_p, M = M, rtol = p_rtol, itmax = 20)
@. Δp = psolve.x
end
end

reservoir_residual(lsys) = lsys.r
reservoir_jacobian(lsys) = lsys.jac

Expand Down

0 comments on commit 92983d8

Please sign in to comment.