Skip to content

Commit

Permalink
Added caches for CG solver
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Sep 7, 2023
1 parent 93addb6 commit 19921de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/LinearSolvers/IterativeLinearSolvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ function Gridap.Algebra.numerical_setup(::IterativeLinearSolverType,
IterativeLinearSolverNS(ss.solver,A,nothing)
end

function Gridap.Algebra.numerical_setup(::CGIterativeSolverType,
ss::IterativeLinearSolverSS,
A::AbstractMatrix)
x = allocate_col_vector(A)
caches = IterativeSolvers.CGStateVariables(zero(x), similar(x), similar(x))
return IterativeLinearSolverNS(ss.solver,A,caches)
end

function Gridap.Algebra.numerical_setup(::SSORIterativeSolverType,
ss::IterativeLinearSolverSS,
A::AbstractMatrix)
Expand Down Expand Up @@ -131,8 +139,8 @@ function Gridap.Algebra.solve!(::CGIterativeSolverType,
x::AbstractVector,
ns::IterativeLinearSolverNS,
y::AbstractVector)
A, kwargs = ns.A, ns.solver.kwargs
return cg!(x,A,y;kwargs...)
A, kwargs, caches = ns.A, ns.solver.kwargs, ns.caches
return cg!(x,A,y;kwargs...,statevars=caches)
end

function Gridap.Algebra.solve!(::GMRESIterativeSolverType,
Expand Down
3 changes: 1 addition & 2 deletions src/PatchBasedSmoothers/mpi/PatchFESpaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ function prolongate!(x::PVector,
if is_consistent
map(prolongate!,partition(x),local_views(Ph),partition(y))
else
# Communicate ghosts
# Transfer ghosts while copying owned dofs
rows = axes(y,1)
t = consistent!(y)
# Start copying owned dofs
map(partition(x),local_views(Ph),partition(y),own_to_local(rows)) do x,Ph,y,ids
prolongate!(x,Ph,y;dof_ids=ids)
end
Expand Down

0 comments on commit 19921de

Please sign in to comment.