From 1df3755825c8230427168c6a9975b84aa9f03993 Mon Sep 17 00:00:00 2001 From: JordiManyer Date: Mon, 4 Dec 2023 17:53:49 +1100 Subject: [PATCH 1/2] Renamed allocate_X_vector --- src/LinearSolvers/GMGLinearSolvers.jl | 10 +++++----- src/LinearSolvers/IterativeLinearSolvers.jl | 6 +++--- src/LinearSolvers/Krylov/CGSolvers.jl | 8 ++++---- src/LinearSolvers/Krylov/FGMRESSolvers.jl | 6 +++--- src/LinearSolvers/Krylov/GMRESSolvers.jl | 6 +++--- src/LinearSolvers/Krylov/MINRESSolvers.jl | 8 ++++---- src/LinearSolvers/RichardsonSmoothers.jl | 4 ++-- src/LinearSolvers/SchurComplementSolvers.jl | 6 +++--- src/LinearSolvers/SymGaussSeidelSmoothers.jl | 4 ++-- .../DistributedGridTransferOperators.jl | 2 +- .../seq/PatchBasedLinearSolvers.jl | 4 ++-- test/LinearSolvers/BlockDiagonalSmoothersTests.jl | 4 ++-- .../LinearSolvers/IterativeSolversWrappersTests.jl | 2 +- test/LinearSolvers/KrylovSolversTests.jl | 2 +- test/LinearSolvers/SchurComplementSolversTests.jl | 2 +- test/LinearSolvers/SmoothersTests.jl | 2 +- test/_dev/GMG/GMGPatchBasedTesting.jl | 14 +++++++------- 17 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/LinearSolvers/GMGLinearSolvers.jl b/src/LinearSolvers/GMGLinearSolvers.jl index f38600f5..4b8651d7 100644 --- a/src/LinearSolvers/GMGLinearSolvers.jl +++ b/src/LinearSolvers/GMGLinearSolvers.jl @@ -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 @@ -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 diff --git a/src/LinearSolvers/IterativeLinearSolvers.jl b/src/LinearSolvers/IterativeLinearSolvers.jl index 91469999..b3d9d4b6 100644 --- a/src/LinearSolvers/IterativeLinearSolvers.jl +++ b/src/LinearSolvers/IterativeLinearSolvers.jl @@ -85,7 +85,7 @@ 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 @@ -93,8 +93,8 @@ 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) diff --git a/src/LinearSolvers/Krylov/CGSolvers.jl b/src/LinearSolvers/Krylov/CGSolvers.jl index 73f42d17..5735d859 100644 --- a/src/LinearSolvers/Krylov/CGSolvers.jl +++ b/src/LinearSolvers/Krylov/CGSolvers.jl @@ -29,10 +29,10 @@ mutable struct CGNumericalSetup <: Gridap.Algebra.NumericalSetup end function get_solver_caches(solver::CGSolver,A) - 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 diff --git a/src/LinearSolvers/Krylov/FGMRESSolvers.jl b/src/LinearSolvers/Krylov/FGMRESSolvers.jl index d14bcd62..f9cc9f7a 100644 --- a/src/LinearSolvers/Krylov/FGMRESSolvers.jl +++ b/src/LinearSolvers/Krylov/FGMRESSolvers.jl @@ -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 diff --git a/src/LinearSolvers/Krylov/GMRESSolvers.jl b/src/LinearSolvers/Krylov/GMRESSolvers.jl index 88967db0..9a816b56 100644 --- a/src/LinearSolvers/Krylov/GMRESSolvers.jl +++ b/src/LinearSolvers/Krylov/GMRESSolvers.jl @@ -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 diff --git a/src/LinearSolvers/Krylov/MINRESSolvers.jl b/src/LinearSolvers/Krylov/MINRESSolvers.jl index 6eb68140..fcf4504b 100644 --- a/src/LinearSolvers/Krylov/MINRESSolvers.jl +++ b/src/LinearSolvers/Krylov/MINRESSolvers.jl @@ -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 diff --git a/src/LinearSolvers/RichardsonSmoothers.jl b/src/LinearSolvers/RichardsonSmoothers.jl index b3832f54..b343e80d 100644 --- a/src/LinearSolvers/RichardsonSmoothers.jl +++ b/src/LinearSolvers/RichardsonSmoothers.jl @@ -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 diff --git a/src/LinearSolvers/SchurComplementSolvers.jl b/src/LinearSolvers/SchurComplementSolvers.jl index 08188354..38f94aa1 100644 --- a/src/LinearSolvers/SchurComplementSolvers.jl +++ b/src/LinearSolvers/SchurComplementSolvers.jl @@ -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 diff --git a/src/LinearSolvers/SymGaussSeidelSmoothers.jl b/src/LinearSolvers/SymGaussSeidelSmoothers.jl index 841eac96..22bdfbdc 100644 --- a/src/LinearSolvers/SymGaussSeidelSmoothers.jl +++ b/src/LinearSolvers/SymGaussSeidelSmoothers.jl @@ -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 diff --git a/src/MultilevelTools/DistributedGridTransferOperators.jl b/src/MultilevelTools/DistributedGridTransferOperators.jl index 84f492e8..a47384cf 100644 --- a/src/MultilevelTools/DistributedGridTransferOperators.jl +++ b/src/MultilevelTools/DistributedGridTransferOperators.jl @@ -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) diff --git a/src/PatchBasedSmoothers/seq/PatchBasedLinearSolvers.jl b/src/PatchBasedSmoothers/seq/PatchBasedLinearSolvers.jl index 41124973..530a0982 100644 --- a/src/PatchBasedSmoothers/seq/PatchBasedLinearSolvers.jl +++ b/src/PatchBasedSmoothers/seq/PatchBasedLinearSolvers.jl @@ -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) diff --git a/test/LinearSolvers/BlockDiagonalSmoothersTests.jl b/test/LinearSolvers/BlockDiagonalSmoothersTests.jl index bd73281e..d3d7c3c3 100644 --- a/test/LinearSolvers/BlockDiagonalSmoothersTests.jl +++ b/test/LinearSolvers/BlockDiagonalSmoothersTests.jl @@ -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) @@ -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 diff --git a/test/LinearSolvers/IterativeSolversWrappersTests.jl b/test/LinearSolvers/IterativeSolversWrappersTests.jl index 9fba4611..2c0db8f0 100644 --- a/test/LinearSolvers/IterativeSolversWrappersTests.jl +++ b/test/LinearSolvers/IterativeSolversWrappersTests.jl @@ -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) diff --git a/test/LinearSolvers/KrylovSolversTests.jl b/test/LinearSolvers/KrylovSolversTests.jl index 66c9c542..cd21a360 100644 --- a/test/LinearSolvers/KrylovSolversTests.jl +++ b/test/LinearSolvers/KrylovSolversTests.jl @@ -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) diff --git a/test/LinearSolvers/SchurComplementSolversTests.jl b/test/LinearSolvers/SchurComplementSolversTests.jl index 2e9b4e2c..5ce1ba08 100644 --- a/test/LinearSolvers/SchurComplementSolversTests.jl +++ b/test/LinearSolvers/SchurComplementSolversTests.jl @@ -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) diff --git a/test/LinearSolvers/SmoothersTests.jl b/test/LinearSolvers/SmoothersTests.jl index 15b94301..3f008183 100644 --- a/test/LinearSolvers/SmoothersTests.jl +++ b/test/LinearSolvers/SmoothersTests.jl @@ -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, diff --git a/test/_dev/GMG/GMGPatchBasedTesting.jl b/test/_dev/GMG/GMGPatchBasedTesting.jl index 8e99623c..bf94e4b8 100644 --- a/test/_dev/GMG/GMGPatchBasedTesting.jl +++ b/test/_dev/GMG/GMGPatchBasedTesting.jl @@ -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) @@ -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) @@ -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) @@ -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) From 673095117f9f8975838c438722fcb490a65cdd87 Mon Sep 17 00:00:00 2001 From: JordiManyer Date: Tue, 5 Dec 2023 11:39:43 +1100 Subject: [PATCH 2/2] Fixed tests --- test/LinearSolvers/BlockDiagonalSmoothersTests.jl | 2 +- test/LinearSolvers/GMGTests.jl | 2 +- test/LinearSolvers/IterativeSolversWrappersTests.jl | 2 +- test/LinearSolvers/KrylovSolversTests.jl | 2 +- test/LinearSolvers/SchurComplementSolversTests.jl | 2 +- test/LinearSolvers/SmoothersTests.jl | 2 +- test/MultilevelTools/DistributedGridTransferOperatorsTests.jl | 2 +- test/MultilevelTools/ModelHierarchiesTests.jl | 2 +- test/MultilevelTools/RedistributeToolsTests.jl | 2 +- test/MultilevelTools/RefinementToolsTests.jl | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/LinearSolvers/BlockDiagonalSmoothersTests.jl b/test/LinearSolvers/BlockDiagonalSmoothersTests.jl index d3d7c3c3..b862bc79 100644 --- a/test/LinearSolvers/BlockDiagonalSmoothersTests.jl +++ b/test/LinearSolvers/BlockDiagonalSmoothersTests.jl @@ -2,7 +2,7 @@ module BlockDiagonalSmoothersTests using Test using Gridap -using Gridap.MultiField +using Gridap.MultiField, Gridap.Algebra using BlockArrays using LinearAlgebra using FillArrays diff --git a/test/LinearSolvers/GMGTests.jl b/test/LinearSolvers/GMGTests.jl index 6666ea4f..d0f014f1 100644 --- a/test/LinearSolvers/GMGTests.jl +++ b/test/LinearSolvers/GMGTests.jl @@ -7,7 +7,7 @@ using IterativeSolvers using FillArrays using Gridap -using Gridap.ReferenceFEs +using Gridap.ReferenceFEs, Gridap.Algebra using PartitionedArrays using GridapDistributed using GridapP4est diff --git a/test/LinearSolvers/IterativeSolversWrappersTests.jl b/test/LinearSolvers/IterativeSolversWrappersTests.jl index 2c0db8f0..c6a469e5 100644 --- a/test/LinearSolvers/IterativeSolversWrappersTests.jl +++ b/test/LinearSolvers/IterativeSolversWrappersTests.jl @@ -1,7 +1,7 @@ module IterativeSolversWrappersTests using Test -using Gridap +using Gridap, Gridap.Algebra using IterativeSolvers using LinearAlgebra using SparseArrays diff --git a/test/LinearSolvers/KrylovSolversTests.jl b/test/LinearSolvers/KrylovSolversTests.jl index cd21a360..f0857fe2 100644 --- a/test/LinearSolvers/KrylovSolversTests.jl +++ b/test/LinearSolvers/KrylovSolversTests.jl @@ -1,7 +1,7 @@ module KrylovSolversTests using Test -using Gridap +using Gridap, Gridap.Algebra using GridapDistributed using PartitionedArrays using IterativeSolvers diff --git a/test/LinearSolvers/SchurComplementSolversTests.jl b/test/LinearSolvers/SchurComplementSolversTests.jl index 5ce1ba08..37c0f248 100644 --- a/test/LinearSolvers/SchurComplementSolversTests.jl +++ b/test/LinearSolvers/SchurComplementSolversTests.jl @@ -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 diff --git a/test/LinearSolvers/SmoothersTests.jl b/test/LinearSolvers/SmoothersTests.jl index 3f008183..00eed34d 100644 --- a/test/LinearSolvers/SmoothersTests.jl +++ b/test/LinearSolvers/SmoothersTests.jl @@ -2,7 +2,7 @@ module SmoothersTests using Test using MPI -using Gridap +using Gridap, Gridap.Algebra using GridapDistributed using PartitionedArrays using IterativeSolvers diff --git a/test/MultilevelTools/DistributedGridTransferOperatorsTests.jl b/test/MultilevelTools/DistributedGridTransferOperatorsTests.jl index ae25ea7f..d5695b24 100644 --- a/test/MultilevelTools/DistributedGridTransferOperatorsTests.jl +++ b/test/MultilevelTools/DistributedGridTransferOperatorsTests.jl @@ -1,7 +1,7 @@ module DistributedGridTransferOperatorsTests using MPI using PartitionedArrays -using Gridap +using Gridap, Gridap.Algebra using GridapDistributed using GridapP4est using Test diff --git a/test/MultilevelTools/ModelHierarchiesTests.jl b/test/MultilevelTools/ModelHierarchiesTests.jl index 69203ca1..90cc3c2f 100644 --- a/test/MultilevelTools/ModelHierarchiesTests.jl +++ b/test/MultilevelTools/ModelHierarchiesTests.jl @@ -2,7 +2,7 @@ module ModelHierarchiesTests using MPI using Gridap -using Gridap.FESpaces +using Gridap.FESpaces, Gridap.Algebra using GridapDistributed using PartitionedArrays using GridapP4est diff --git a/test/MultilevelTools/RedistributeToolsTests.jl b/test/MultilevelTools/RedistributeToolsTests.jl index 490b970a..f8cbf44f 100644 --- a/test/MultilevelTools/RedistributeToolsTests.jl +++ b/test/MultilevelTools/RedistributeToolsTests.jl @@ -1,7 +1,7 @@ module RedistributeToolsTests using MPI using PartitionedArrays -using Gridap +using Gridap, Gridap.Algebra using GridapDistributed using GridapP4est using Test diff --git a/test/MultilevelTools/RefinementToolsTests.jl b/test/MultilevelTools/RefinementToolsTests.jl index 83573953..d7399319 100644 --- a/test/MultilevelTools/RefinementToolsTests.jl +++ b/test/MultilevelTools/RefinementToolsTests.jl @@ -1,7 +1,7 @@ module RefinementToolsTests using MPI using PartitionedArrays -using Gridap +using Gridap, Gridap.Algebra using GridapDistributed using GridapP4est using Test