Skip to content

Commit

Permalink
Removed superfluous accesses to .ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
fverdugo committed Jan 21, 2022
1 parent a8dc6bd commit dede442
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/PETScArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function Finalize(a::PETScVector)
if a.comm == MPI.COMM_SELF
@check_error_code PETSC.VecDestroy(a.vec)
else
@check_error_code PETSC.PetscObjectRegisterDestroy(a.vec[].ptr)
@check_error_code PETSC.PetscObjectRegisterDestroy(a.vec[])
end
a.initialized = false
@assert Threads.threadid() == 1
Expand Down Expand Up @@ -120,7 +120,7 @@ function _copy!(a::Vector,b::Vec)
ni = length(a)
ix = collect(PetscInt,0:(ni-1))
v = convert(Vector{PetscScalar},a)
@check_error_code PETSC.VecGetValues(b.ptr,ni,ix,v)
@check_error_code PETSC.VecGetValues(b,ni,ix,v)
if !(v === a)
a .= v
end
Expand All @@ -135,12 +135,12 @@ function _copy!(a::Vec,b::Vector)
ni = length(b)
ix = collect(PetscInt,0:(ni-1))
v = convert(Vector{PetscScalar},b)
@check_error_code PETSC.VecSetValues(a.ptr,ni,ix,v,PETSC.INSERT_VALUES)
@check_error_code PETSC.VecSetValues(a,ni,ix,v,PETSC.INSERT_VALUES)
end

function _get_local_oh_vector(a::Vec)
v=PETScVector(MPI.COMM_SELF)
@check_error_code PETSC.VecGhostGetLocalForm(a.ptr,v.vec)
@check_error_code PETSC.VecGhostGetLocalForm(a,v.vec)
if v.vec[] != C_NULL # a is a ghosted vector
v.ownership=a
Init(v)
Expand Down Expand Up @@ -198,7 +198,7 @@ function Finalize(a::PETScMatrix)
if a.comm == MPI.COMM_SELF
@check_error_code PETSC.MatDestroy(a.mat)
else
@check_error_code PETSC.PetscObjectRegisterDestroy(a.mat[].ptr)
@check_error_code PETSC.PetscObjectRegisterDestroy(a.mat[])
end
a.initialized = false
@assert Threads.threadid() == 1
Expand Down Expand Up @@ -308,16 +308,16 @@ function _copy!(petscmat::Mat,mat::Matrix)
for i=1:size(mat)[1]
row[1]=PetscInt(i-1)
vals .= view(mat,i,:)
PETSC.MatSetValues(petscmat.ptr,
PETSC.MatSetValues(petscmat,
PetscInt(1),
row,
n,
cols,
vals,
PETSC.INSERT_VALUES)
end
@check_error_code PETSC.MatAssemblyBegin(petscmat.ptr, PETSC.MAT_FINAL_ASSEMBLY)
@check_error_code PETSC.MatAssemblyEnd(petscmat.ptr, PETSC.MAT_FINAL_ASSEMBLY)
@check_error_code PETSC.MatAssemblyBegin(petscmat, PETSC.MAT_FINAL_ASSEMBLY)
@check_error_code PETSC.MatAssemblyEnd(petscmat, PETSC.MAT_FINAL_ASSEMBLY)
end

function _copy!(petscmat::Mat,mat::AbstractSparseMatrix)
Expand All @@ -341,16 +341,16 @@ function _copy!(petscmat::Mat,mat::AbstractSparseMatrix)
end
vals = view(a,ia[i]+1:ia[i+1])
PETSC.MatSetValues(
petscmat.ptr,
petscmat,
PetscInt(1),
row,
ia[i+1]-ia[i],
cols,
vals,
PETSC.INSERT_VALUES)
end
@check_error_code PETSC.MatAssemblyBegin(petscmat.ptr, PETSC.MAT_FINAL_ASSEMBLY)
@check_error_code PETSC.MatAssemblyEnd(petscmat.ptr, PETSC.MAT_FINAL_ASSEMBLY)
@check_error_code PETSC.MatAssemblyBegin(petscmat, PETSC.MAT_FINAL_ASSEMBLY)
@check_error_code PETSC.MatAssemblyEnd(petscmat, PETSC.MAT_FINAL_ASSEMBLY)
end


Expand Down

0 comments on commit dede442

Please sign in to comment.