Skip to content

Commit d394eec

Browse files
committed
add a few more PC things
1 parent 90142c3 commit d394eec

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

src/PETSc.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function PetscInitialized()
7272
end
7373

7474
function PetscFinalize()
75+
println("finalizing PETSc")
7576
gc() # call garbage collection to force all PETSc objects be destroy that are queued up for destruction
7677
return ccall( (:PetscFinalize, libpetsclocation),Int32,());
7778
end

src/petsc_error.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ end
3636
# tell Petsc abut the Error handler
3737
cfunc = cfunction(error_handler, PetscErrorCode, (comm_type, Int32, Ptr{UInt8}, Ptr{UInt8}, PetscErrorCode, PetscErrorType, Ptr{UInt8}, Ptr{Void}) )
3838
ctx = C_NULL
39-
ierr = ccall( (:PetscPushErrorHandler, petsc), PetscErrorCode, (Ptr{Void}, Ptr{Void}), cfunc, ctx)
39+
#ierr = ccall( (:PetscPushErrorHandler, petsc), PetscErrorCode, (Ptr{Void}, Ptr{Void}), cfunc, ctx)
4040

4141

4242
function chkerrq(i::PetscErrorCode)

src/petsc_ksp.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
export KSP, KSPSetOperators, KSPSetFromOptions, KSPSolve, KSPSetUp
2+
export KSP, KSPSetOperators, KSPSetFromOptions, KSPSolve, KSPSolveTranspose, KSPSetUp, KSP_NULL
33

44
export KSPGetConvergedReason, PetscView, KSPSetType, KSPGetType, KSPSetTolerances, KSPGetTolerances, KSPSetInitialGuessNonzero, KSPGetInitialGuessNonzero, KSPGetResidualNorm
55

src/petsc_mat.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ end
192192
end
193193

194194
function MatSetOption(mat::PetscMat,arg2::MatOption,arg3::Union{Integer, Bool})
195+
println("mat.pobj = ", mat.pobj)
195196
ierr = ccall((:MatSetOption, libpetsclocation),PetscErrorCode, (Ptr{Void},MatOption,PetscBool), mat.pobj, arg2, arg3)
196197

197198
if ierr != 0

src/petsc_pc.jl

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
export PC, PCCreate, KSPGetPC, KSPSetPC, PCSetType, PCGetType, PCFactorSetUseInPlace, PCFactorGetUseInPlace, PCSetReusePreconditioner, PCGetReusePreconditioner, PCFactorSetAllowDiagonalFill, PCFactorGetAllowDiagonalFill, PCFactorSetLevels, PCFactorGetLevels, PCSetReusePreconditioner, PCGetReusePreconditioner, PCBJacobiGetSubKSP, PCFactorSetFill, PCJacobiSetType, PCJacobiGetType
1+
export PC, PCCreate, PCSetFromOptions, KSPGetPC, KSPSetPC, PCSetType, PCGetType, PCFactorSetUseInPlace, PCFactorGetUseInPlace, PCSetReusePreconditioner, PCGetReusePreconditioner, PCFactorSetAllowDiagonalFill, PCFactorGetAllowDiagonalFill, PCFactorSetLevels, PCFactorGetLevels, PCSetReusePreconditioner, PCGetReusePreconditioner, PCBJacobiGetSubKSP, PCFactorSetFill, PCJacobiSetType, PCJacobiGetType
22

33
# Shell PC
4-
export PCShellSetApply, PCShellSetSetUp, PCShellSetContext, PCShellGetContext
4+
export PCShellSetApply, PCShellSetApplyTranspose, PCShellSetSetUp,
5+
PCShellSetContext, PCShellGetContext
56

67
# developer PC interface
7-
export PCApply, PCApplyTranspose, PCApplyTransposeExists
8+
export PCApply, PCSetUp, PCApplyTranspose, PCApplyTransposeExists
89

910
# preconditioner contex
1011
# the KSP object creates the PC contex, so we don't provide a constructor
@@ -16,11 +17,23 @@ global const PC_NULL = PC(C_NULL)
1617

1718
function PCCreate(comm::MPI.Comm)
1819
arg2 = Ref{Ptr{Void}}()
19-
ccall((:PCCreate,petsc),PetscErrorCode,(comjm_type,Ptr{PC}),comm,arg2)
20+
ccall((:PCCreate,petsc),PetscErrorCode,(comm_type,Ptr{Ptr{Void}}),comm,arg2)
2021

2122
return PC(arg2[])
2223
end
2324

25+
function PetscDestroy(arg1::PC)
26+
if arg1.pobj != C_NULL
27+
ccall((:PCDestroy,petsc),PetscErrorCode,(Ptr{Ptr{Void}},),&arg1.pobj)
28+
end
29+
end
30+
31+
32+
function PCSetFromOptions(arg1::PC)
33+
ccall((:PCSetFromOptions,petsc),PetscErrorCode,(Ptr{Void},),arg1.pobj)
34+
end
35+
36+
2437
function KSPGetPC(ksp::KSP)
2538
arr = Array(Ptr{Void}, 1)
2639
ccall((:KSPGetPC,petsc),PetscErrorCode,(Ptr{Void},Ptr{Void}),ksp.pobj, arr)
@@ -47,6 +60,11 @@ function PCShellSetApply(arg1::PC,arg2::Ptr{Void})
4760
ccall((:PCShellSetApply,petsc),PetscErrorCode,(Ptr{Void},Ptr{Void}),arg1.pobj,arg2)
4861
end
4962

63+
function PCShellSetApplyTranspose(arg1::PC,arg2::Ptr{Void})
64+
ccall((:PCShellSetApplyTranspose,petsc),PetscErrorCode,(Ptr{Void},Ptr{Void}),arg1.pobj,arg2)
65+
end
66+
67+
5068
function PCShellSetSetUp(arg1::PC,arg2::Ptr{Void})
5169
ccall((:PCShellSetSetUp,petsc),PetscErrorCode,(Ptr{Void},Ptr{Void}),arg1.pobj,arg2)
5270
end
@@ -151,6 +169,7 @@ function PCJacobiGetType(pc::PC)
151169
end
152170

153171
function PCApply(arg1::PC,arg2::PetscVec,arg3::PetscVec)
172+
println("pc.pobj = ", arg1.pobj)
154173
ccall((:PCApply,petsc),PetscErrorCode,(Ptr{Void},Ptr{Void},Ptr{Void}),arg1.pobj ,arg2.pobj, arg3.pobj)
155174
end
156175

@@ -165,5 +184,8 @@ function PCApplyTransposeExists(arg1::PC)
165184
return arg2[] == 1
166185
end
167186

187+
function PCSetUp(arg1::PC)
188+
ccall((:PCSetUp,petsc),PetscErrorCode,(Ptr{Void},),arg1.pobj)
189+
end
168190

169191

0 commit comments

Comments
 (0)