Skip to content

Commit

Permalink
Add back in vec.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy E Kozdon committed Jul 19, 2021
1 parent 276cdb4 commit 6037119
Show file tree
Hide file tree
Showing 5 changed files with 280 additions and 123 deletions.
2 changes: 1 addition & 1 deletion src/PETSc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end
include("init.jl")
include("viewer.jl")
include("options.jl")
# include("vec.jl")
include("vec.jl")
# include("mat.jl")
# include("matshell.jl")
# include("ksp.jl")
Expand Down
47 changes: 46 additions & 1 deletion src/sys.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const CPetscObject = Ptr{Cvoid}

const UnionPetscTypes = Union{Options}
const UnionPetscTypes = Union{Options, AbstractVec}

# allows us to pass PETSc_XXX objects directly into CXXX ccall signatures
Base.cconvert(::Type{CPetscObject}, obj::UnionPetscTypes) = obj
Expand All @@ -10,3 +10,48 @@ Base.unsafe_convert(::Type{CPetscObject}, obj::UnionPetscTypes) = obj.ptr
function Base.unsafe_convert(::Type{Ptr{CPetscObject}}, obj::UnionPetscTypes)
convert(Ptr{CPetscObject}, pointer_from_objref(obj))
end

function getcomm(
obj::Union{AbstractVec{PetscLib}},
) where {PetscLib}
comm = MPI.Comm()
LibPETSc.PetscObjectGetComm(PetscLib, obj, comm)

#XXX We should really increase the petsc reference counter.
# But for for some reason the PETSc says that this communicator is
# unknown
#=
# Call the PetscCommDuplicate to increase reference count
@chk ccall(
(:PetscCommDuplicate, $libpetsc),
PetscErrorCode,
(MPI.MPI_Comm, Ptr{MPI.MPI_Comm}, Ptr{Cvoid}),
comm,
comm,
C_NULL,
)
# Register PetscCommDestroy to decriment the reference count
finalizer(PetscCommDestroy, comm)
=#

return comm
end

#=
#XXX Not sure why this doesn't work
@for_libpetsc begin
function PetscCommDestroy(
comm::MPI.Comm
)
@show comm.val
@chk ccall(
(:PetscCommDestroy, $libpetsc),
PetscErrorCode,
(Ptr{MPI.MPI_Comm},),
comm,
)
return nothing
end
end
=#
Loading

0 comments on commit 6037119

Please sign in to comment.