Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:gridap/GridapSolvers.jl into hig…
Browse files Browse the repository at this point in the history
…h-order-gmg
  • Loading branch information
JordiManyer committed Dec 5, 2023
2 parents f1feba4 + 6730951 commit 696565c
Show file tree
Hide file tree
Showing 22 changed files with 55 additions and 55 deletions.
10 changes: 5 additions & 5 deletions src/LinearSolvers/GMGLinearSolvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function setup_finest_level_cache(mh::ModelHierarchy,smatrices::Vector{<:Abstrac
parts = get_level_parts(mh,1)
if i_am_in(parts)
Ah = smatrices[1]
rh = allocate_col_vector(Ah)
rh = allocate_in_domain(Ah)
cache = rh
end
return cache
Expand Down Expand Up @@ -168,14 +168,14 @@ function setup_coarsest_solver_cache(mh::ModelHierarchy,coarsest_solver::PETScLi
end

function allocate_level_work_vectors(mh::ModelHierarchy,smatrices::Vector{<:AbstractMatrix},lev::Integer)
dxh = allocate_col_vector(smatrices[lev])
Adxh = allocate_row_vector(smatrices[lev])
dxh = allocate_in_domain(smatrices[lev])
Adxh = allocate_in_range(smatrices[lev])

cparts = get_level_parts(mh,lev+1)
if i_am_in(cparts)
AH = smatrices[lev+1]
rH = allocate_col_vector(AH)
dxH = allocate_col_vector(AH)
rH = allocate_in_domain(AH)
dxH = allocate_in_domain(AH)
else
rH = nothing
dxH = nothing
Expand Down
6 changes: 3 additions & 3 deletions src/LinearSolvers/IterativeLinearSolvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ end
function Gridap.Algebra.numerical_setup(::CGIterativeSolverType,
ss::IterativeLinearSolverSS,
A::AbstractMatrix)
x = allocate_col_vector(A)
x = allocate_in_domain(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)
x = allocate_row_vector(A)
b = allocate_col_vector(A)
x = allocate_in_range(A)
b = allocate_in_domain(A)
ω = ss.solver.args[]
maxiter = ss.solver.kwargs[:maxiter]
caches = IterativeSolvers.ssor_iterable(x,A,b,ω;maxiter=maxiter)
Expand Down
8 changes: 4 additions & 4 deletions src/LinearSolvers/Krylov/CGSolvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ mutable struct CGNumericalSetup <: Gridap.Algebra.NumericalSetup
end

function get_solver_caches(solver::CGSolver,A::AbstractMatrix)
w = allocate_col_vector(A)
p = allocate_col_vector(A)
z = allocate_col_vector(A)
r = allocate_col_vector(A)
w = allocate_in_domain(A)
p = allocate_in_domain(A)
z = allocate_in_domain(A)
r = allocate_in_domain(A)
return (w,p,z,r)
end

Expand Down
6 changes: 3 additions & 3 deletions src/LinearSolvers/Krylov/FGMRESSolvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ end
function get_solver_caches(solver::FGMRESSolver,A)
m = solver.m

V = [allocate_col_vector(A) for i in 1:m+1]
Z = [allocate_col_vector(A) for i in 1:m]
zl = allocate_col_vector(A)
V = [allocate_in_domain(A) for i in 1:m+1]
Z = [allocate_in_domain(A) for i in 1:m]
zl = allocate_in_domain(A)

H = zeros(m+1,m) # Hessenberg matrix
g = zeros(m+1) # Residual vector
Expand Down
6 changes: 3 additions & 3 deletions src/LinearSolvers/Krylov/GMRESSolvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ end
function get_solver_caches(solver::GMRESSolver,A)
m, Pl, Pr = solver.m, solver.Pl, solver.Pr

V = [allocate_col_vector(A) for i in 1:m+1]
zr = !isa(Pr,Nothing) ? allocate_col_vector(A) : nothing
zl = allocate_col_vector(A)
V = [allocate_in_domain(A) for i in 1:m+1]
zr = !isa(Pr,Nothing) ? allocate_in_domain(A) : nothing
zl = allocate_in_domain(A)

H = zeros(m+1,m) # Hessenberg matrix
g = zeros(m+1) # Residual vector
Expand Down
8 changes: 4 additions & 4 deletions src/LinearSolvers/Krylov/MINRESSolvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ end
function get_solver_caches(solver::MINRESSolver,A)
Pl, Pr = solver.Pl, solver.Pr

V = [allocate_col_vector(A) for i in 1:3]
W = [allocate_col_vector(A) for i in 1:3]
zr = !isa(Pr,Nothing) ? allocate_col_vector(A) : nothing
zl = !isa(Pl,Nothing) ? allocate_col_vector(A) : nothing
V = [allocate_in_domain(A) for i in 1:3]
W = [allocate_in_domain(A) for i in 1:3]
zr = !isa(Pr,Nothing) ? allocate_in_domain(A) : nothing
zl = !isa(Pl,Nothing) ? allocate_in_domain(A) : nothing

H = zeros(4) # Hessenberg matrix
g = zeros(2) # Residual vector
Expand Down
4 changes: 2 additions & 2 deletions src/LinearSolvers/RichardsonSmoothers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ mutable struct RichardsonSmootherNumericalSetup{A,B,C,D} <: Gridap.Algebra.Numer
end

function Gridap.Algebra.numerical_setup(ss::RichardsonSmootherSymbolicSetup, A::AbstractMatrix)
Adx = allocate_row_vector(A)
dx = allocate_col_vector(A)
Adx = allocate_in_range(A)
dx = allocate_in_domain(A)
Mns = numerical_setup(ss.Mss,A)
return RichardsonSmootherNumericalSetup(ss.smoother,A,Adx,dx,Mns)
end
Expand Down
6 changes: 3 additions & 3 deletions src/LinearSolvers/SchurComplementSolvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ struct SchurComplementNumericalSetup{A,B,C} <: Gridap.Algebra.NumericalSetup
end

function get_shur_complement_caches(B::AbstractMatrix,C::AbstractMatrix)
du = allocate_col_vector(C)
bu = allocate_col_vector(C)
bp = allocate_col_vector(B)
du = allocate_in_domain(C)
bu = allocate_in_domain(C)
bp = allocate_in_domain(B)
return du,bu,bp
end

Expand Down
4 changes: 2 additions & 2 deletions src/LinearSolvers/SymGaussSeidelSmoothers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ struct SymGaussSeidelNumericalSetup{A,B,C,D} <: Gridap.Algebra.NumericalSetup
end

function _gs_get_caches(A::AbstractMatrix)
dx = allocate_col_vector(A)
Adx = allocate_row_vector(A)
dx = allocate_in_domain(A)
Adx = allocate_in_range(A)
return dx, Adx
end

Expand Down
2 changes: 1 addition & 1 deletion src/MultilevelTools/DistributedGridTransferOperators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function _get_dual_projection_cache(lev::Int,sh::FESpaceHierarchy,qdegree::Int,s
Mh_ns = numerical_setup(symbolic_setup(solver,Mh),Mh)

assem = SparseMatrixAssembler(UH,UH)
rh = allocate_col_vector(Mh)
rh = allocate_in_domain(Mh)
cache_refine = model_h, Uh, UH, Mh_ns, rh, uh, assem, dΩhH
else
model_h = get_model_before_redist(mh,lev)
Expand Down
4 changes: 2 additions & 2 deletions src/PatchBasedSmoothers/seq/PatchBasedLinearSolvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ function Gridap.Algebra.numerical_setup(ss::PatchBasedSymbolicSetup,A::AbstractM
Ap_ns = numerical_setup(symbolic_setup(solver.local_solver,Ap),Ap)

# Caches
rp = allocate_row_vector(Ap)
dxp = allocate_col_vector(Ap)
rp = allocate_in_range(Ap)
dxp = allocate_in_domain(Ap)
caches = (rp,dxp)

return PatchBasedSmootherNumericalSetup(solver,Ap_ns,weights,caches)
Expand Down
6 changes: 3 additions & 3 deletions test/LinearSolvers/BlockDiagonalSmoothersTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module BlockDiagonalSmoothersTests

using Test
using Gridap
using Gridap.MultiField
using Gridap.MultiField, Gridap.Algebra
using BlockArrays
using LinearAlgebra
using FillArrays
Expand Down Expand Up @@ -118,7 +118,7 @@ function main_driver(D,model,solvers)
BDSss = symbolic_setup(BDS,A)
BDSns = numerical_setup(BDSss,A)

x = allocate_col_vector(A)
x = allocate_in_domain(A)
x = cg!(x,A,b;verbose=true,Pl=BDSns,reltol=1.0e-12)
@test is_same_vector(x,x_star,Xb,X)

Expand All @@ -127,7 +127,7 @@ function main_driver(D,model,solvers)
BDSss = symbolic_setup(BDS,A)
BDSns = numerical_setup(BDSss,A)

x = allocate_col_vector(A)
x = allocate_in_domain(A)
x = cg!(x,A,b;verbose=true,Pl=BDSns,reltol=1.0e-12)
@test is_same_vector(x,x_star,Xb,X)
end
Expand Down
2 changes: 1 addition & 1 deletion test/LinearSolvers/GMGTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using IterativeSolvers
using FillArrays

using Gridap
using Gridap.ReferenceFEs
using Gridap.ReferenceFEs, Gridap.Algebra
using PartitionedArrays
using GridapDistributed
using GridapP4est
Expand Down
4 changes: 2 additions & 2 deletions test/LinearSolvers/IterativeSolversWrappersTests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module IterativeSolversWrappersTests

using Test
using Gridap
using Gridap, Gridap.Algebra
using IterativeSolvers
using LinearAlgebra
using SparseArrays
Expand All @@ -18,7 +18,7 @@ function test_solver(solver,op,Uh,dΩ)
A, b = get_matrix(op), get_vector(op);
ns = numerical_setup(symbolic_setup(solver,A),A)

x = allocate_col_vector(A)
x = allocate_in_domain(A)
solve!(x,ns,b)

u = interpolate(sol,Uh)
Expand Down
4 changes: 2 additions & 2 deletions test/LinearSolvers/KrylovSolversTests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module KrylovSolversTests

using Test
using Gridap
using Gridap, Gridap.Algebra
using GridapDistributed
using PartitionedArrays
using IterativeSolvers
Expand All @@ -16,7 +16,7 @@ function test_solver(solver,op,Uh,dΩ)
A, b = get_matrix(op), get_vector(op);
ns = numerical_setup(symbolic_setup(solver,A),A)

x = allocate_col_vector(A)
x = allocate_in_domain(A)
solve!(x,ns,b)

u = interpolate(sol,Uh)
Expand Down
4 changes: 2 additions & 2 deletions test/LinearSolvers/SchurComplementSolversTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module SchurComplementSolversTests
using Test
using BlockArrays
using Gridap
using Gridap.MultiField
using Gridap.MultiField, Gridap.Algebra
using Gridap.Algebra
using Gridap.Geometry
using Gridap.FESpaces
Expand Down Expand Up @@ -110,7 +110,7 @@ function main(distribute,np)
gmres = GMRESSolver(20;Pr=psc_solver,rtol=1.e-10,verbose=i_am_main(parts))
gmres_ns = numerical_setup(symbolic_setup(gmres,sysmat),sysmat)

x = allocate_col_vector(sysmat)
x = allocate_in_domain(sysmat)
solve!(x,gmres_ns,sysvec)

xh = FEFunction(X,x)
Expand Down
4 changes: 2 additions & 2 deletions test/LinearSolvers/SmoothersTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module SmoothersTests

using Test
using MPI
using Gridap
using Gridap, Gridap.Algebra
using GridapDistributed
using PartitionedArrays
using IterativeSolvers
Expand Down Expand Up @@ -32,7 +32,7 @@ function smoothers_driver(parts,model,P)
ss = symbolic_setup(P,A)
ns = numerical_setup(ss,A)

x = allocate_col_vector(A)
x = allocate_in_domain(A)
x, history = IterativeSolvers.cg!(x,A,b;
verbose=i_am_main(parts),
reltol=1.0e-8,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module DistributedGridTransferOperatorsTests
using MPI
using PartitionedArrays
using Gridap
using Gridap, Gridap.Algebra
using GridapDistributed
using GridapP4est
using Test
Expand Down
2 changes: 1 addition & 1 deletion test/MultilevelTools/ModelHierarchiesTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module ModelHierarchiesTests

using MPI
using Gridap
using Gridap.FESpaces
using Gridap.FESpaces, Gridap.Algebra
using GridapDistributed
using PartitionedArrays
using GridapP4est
Expand Down
2 changes: 1 addition & 1 deletion test/MultilevelTools/RedistributeToolsTests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module RedistributeToolsTests
using MPI
using PartitionedArrays
using Gridap
using Gridap, Gridap.Algebra
using GridapDistributed
using GridapP4est
using Test
Expand Down
2 changes: 1 addition & 1 deletion test/MultilevelTools/RefinementToolsTests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module RefinementToolsTests
using MPI
using PartitionedArrays
using Gridap
using Gridap, Gridap.Algebra
using GridapDistributed
using GridapP4est
using Test
Expand Down
14 changes: 7 additions & 7 deletions test/_dev/GMG/GMGPatchBasedTesting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ end
function test_solver(s,D_j)
ns = numerical_setup(symbolic_setup(s,D_j),D_j)

b = allocate_col_vector(D_j)
x = allocate_col_vector(D_j)
b = allocate_in_domain(D_j)
x = allocate_in_domain(D_j)

fill!(b,1.0)
solve!(x,ns,b)
Expand All @@ -40,9 +40,9 @@ end

function test_smoother(s,D_j)
ns = numerical_setup(symbolic_setup(s,D_j),D_j)
b = allocate_col_vector(D_j)
x = allocate_col_vector(D_j)
r = allocate_row_vector(D_j)
b = allocate_in_domain(D_j)
x = allocate_in_domain(D_j)
r = allocate_in_range(D_j)
fill!(b,1.0)
fill!(x,1.0)
mul!(r,D_j,x)
Expand Down Expand Up @@ -144,7 +144,7 @@ gmg = GMGLinearSolver(mh,
solver = FGMRESSolver(100,gmg;rtol=1e-6,verbose=true)

ns = numerical_setup(symbolic_setup(solver,A),A)
x = allocate_col_vector(A)
x = allocate_in_domain(A)
solve!(x,ns,b)


Expand All @@ -154,5 +154,5 @@ test_smoother(smoothers[1],A)
Pl = LinearSolvers.IdentitySolver()
solver2 = GMRESSolver(1000;Pl=Pl,rtol=1e-6,verbose=true)
ns2 = numerical_setup(symbolic_setup(solver2,A),A)
x2 = allocate_col_vector(A)
x2 = allocate_in_domain(A)
solve!(x2,ns2,b)

0 comments on commit 696565c

Please sign in to comment.