From e2485da86d50ef19196bd53b4743bc549e512128 Mon Sep 17 00:00:00 2001 From: amartin Date: Mon, 25 Oct 2021 13:11:43 +1100 Subject: [PATCH 1/2] Upgrading to Gridap 0.17 --- Project.toml | 4 ++-- src/PETScAssembly.jl | 16 ++-------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/Project.toml b/Project.toml index 6df6848..6c11929 100644 --- a/Project.toml +++ b/Project.toml @@ -14,11 +14,11 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" SparseMatricesCSR = "a0a7dd2c-ebf4-11e9-1f05-cf50bc540ca1" [compat] -Gridap = "0.16" +Gridap = "0.17" MPI = "0.14, 0.15, 0.16" PETSc_jll = "3.13" +PartitionedArrays = "0.2.4" SparseMatricesCSR = "0.6.1" -PartitionedArrays = "0.2.1" julia = "1.3" [extras] diff --git a/src/PETScAssembly.jl b/src/PETScAssembly.jl index 2d950b4..ea09b80 100644 --- a/src/PETScAssembly.jl +++ b/src/PETScAssembly.jl @@ -2,17 +2,6 @@ # Some methods from the Gridap.Algebra interface # not sure if all are needed.... -function Algebra.fill_entries!(a::PETScMatrix,v) - @notimplementedif v!=0 - @check_error_code PETSC.MatZeroEntries(a.mat[]) - a -end - -function Algebra.fill_entries!(a::PETScVector,v) - fill!(a,v) - a -end - function Algebra.copy_entries!(a::PETScVector,b::PETScVector) if a!==b @check_error_code PETSC.VecCopy(b.vec[],a.vec[]) @@ -27,12 +16,12 @@ function Algebra.copy_entries!(a::PETScMatrix,b::PETScMatrix) a end -function Algebra.scale_entries!(a::PETScVector,b) +function LinearAlgebra.rmul!(a::PETScVector,b) @check_error_code PETSC.VecScale(a.vec[],PetscScalar(b)) a end -function Algebra.scale_entries!(a::PETScMatrix,b) +function LinearAlgebra.rmul!(a::PETScMatrix,b) @check_error_code PETSC.MatScale(a.mat[],PetscScalar(b)) a end @@ -301,4 +290,3 @@ function Algebra.create_from_nz(a::PETScMatrix) @check_error_code PETSC.MatAssemblyEnd(a.mat[],PETSC.MAT_FINAL_ASSEMBLY) a end - From 3f877c7179f4ae9c72e8521095b1b08cddd527eb Mon Sep 17 00:00:00 2001 From: amartin Date: Mon, 25 Oct 2021 13:29:04 +1100 Subject: [PATCH 2/2] * Replacing forgotten fill_entries!/scale_entries! in tests. * Readding implementation of LinearAlgebra.fillstored! for PETScMatrix --- src/PETScAssembly.jl | 10 ++++++++-- test/PETScAssemblyTests.jl | 9 +++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/PETScAssembly.jl b/src/PETScAssembly.jl index ea09b80..6799d94 100644 --- a/src/PETScAssembly.jl +++ b/src/PETScAssembly.jl @@ -2,6 +2,12 @@ # Some methods from the Gridap.Algebra interface # not sure if all are needed.... +function LinearAlgebra.fillstored!(a::PETScMatrix,v) + @notimplementedif v!=zero(typeof(v)) + @check_error_code PETSC.MatZeroEntries(a.mat[]) + a +end + function Algebra.copy_entries!(a::PETScVector,b::PETScVector) if a!==b @check_error_code PETSC.VecCopy(b.vec[],a.vec[]) @@ -16,12 +22,12 @@ function Algebra.copy_entries!(a::PETScMatrix,b::PETScMatrix) a end -function LinearAlgebra.rmul!(a::PETScVector,b) +function LinearAlgebra.rmul!(a::PETScVector,b::Number) @check_error_code PETSC.VecScale(a.vec[],PetscScalar(b)) a end -function LinearAlgebra.rmul!(a::PETScMatrix,b) +function LinearAlgebra.rmul!(a::PETScMatrix,b::Number) @check_error_code PETSC.MatScale(a.mat[],PetscScalar(b)) a end diff --git a/test/PETScAssemblyTests.jl b/test/PETScAssemblyTests.jl index 980bb49..9285df0 100644 --- a/test/PETScAssemblyTests.jl +++ b/test/PETScAssemblyTests.jl @@ -7,6 +7,7 @@ using Gridap.Arrays using GridapPETSc using GridapPETSc: PetscScalar, PetscInt using SparseArrays +using LinearAlgebra options = "-info" @@ -74,10 +75,10 @@ GridapPETSc.with(args=split(options)) do display(d) e = copy(d) - scale_entries!(d,PetscScalar(2)) + rmul!(d,PetscScalar(2)) @test d == 2*e @test nnz(d) == nnz(e) - fill_entries!(d,zero(PetscScalar)) + LinearAlgebra.fillstored!(d,zero(PetscScalar)) @test d == zeros(PetscScalar,size(d)) Tv = PETScVector @@ -106,9 +107,9 @@ GridapPETSc.with(args=split(options)) do display(d) e = copy(d) - scale_entries!(d,PetscScalar(2)) + rmul!(d,PetscScalar(2)) @test d == 2*e - fill_entries!(d,zero(PetscScalar)) + fill!(d,zero(PetscScalar)) @test d == zeros(PetscScalar,length(d)) end